X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.scl.compiler%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Felaboration%2Fexpressions%2FETypeAnnotation.java;fp=bundles%2Forg.simantics.scl.compiler%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Felaboration%2Fexpressions%2FETypeAnnotation.java;h=654b4ef1f47555395924b0ac3f7db94a22417cbc;hp=cfeab99f4e0b783c171ecf8ac61a874d09f99a43;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hpb=24e2b34260f219f0d1644ca7a138894980e25b14 diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ETypeAnnotation.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ETypeAnnotation.java old mode 100755 new mode 100644 index cfeab99f4..654b4ef1f --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ETypeAnnotation.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ETypeAnnotation.java @@ -1,114 +1,114 @@ -package org.simantics.scl.compiler.elaboration.expressions; - -import org.simantics.scl.compiler.elaboration.contexts.SimplificationContext; -import org.simantics.scl.compiler.elaboration.contexts.TranslationContext; -import org.simantics.scl.compiler.elaboration.contexts.TypingContext; -import org.simantics.scl.compiler.errors.Locations; -import org.simantics.scl.compiler.internal.elaboration.utils.ExpressionDecorator; -import org.simantics.scl.compiler.internal.parsing.types.TypeAst; -import org.simantics.scl.compiler.types.Type; -import org.simantics.scl.compiler.types.exceptions.MatchException; - -import gnu.trove.map.hash.TObjectIntHashMap; -import gnu.trove.set.hash.THashSet; -import gnu.trove.set.hash.TIntHashSet; - -public class ETypeAnnotation extends SimplifiableExpression { - Expression value; - Type type; - TypeAst typeAst; - - public ETypeAnnotation(Expression value, TypeAst typeAst) { - this.value = value; - this.typeAst = typeAst; - } - - public ETypeAnnotation(long loc, Expression value, Type type) { - super(loc); - this.value = value; - this.type = type; - } - - public void collectRefs(TObjectIntHashMap allRefs, TIntHashSet refs) { - value.collectRefs(allRefs, refs); - } - - @Override - public void collectVars(TObjectIntHashMap allVars, - TIntHashSet vars) { - value.collectVars(allVars, vars); - } - - @Override - protected void updateType() throws MatchException { - setType(type); - } - - @Override - public void collectFreeVariables(THashSet vars) { - value.collectFreeVariables(vars); - } - - @Override - public Expression simplify(SimplificationContext context) { - return value.simplify(context); - } - - @Override - public Expression resolve(TranslationContext context) { - value = value.resolve(context); - type = context.toType(typeAst); - return this; - } - - @Override - public Expression resolveAsPattern(TranslationContext context) { - value = value.resolveAsPattern(context); - type = context.toType(typeAst); - return this; - } - - @Override - public Expression inferType(TypingContext context) { - return value.checkType(context, type); - } - - @Override - public Expression decorate(ExpressionDecorator decorator) { - value = value.decorate(decorator); - return decorator.decorate(this); - } - - @Override - public void collectEffects(THashSet effects) { - value.collectEffects(effects); - } - - @Override - public void setLocationDeep(long loc) { - if(location == Locations.NO_LOCATION) { - location = loc; - value.setLocationDeep(loc); - } - } - - @Override - public void accept(ExpressionVisitor visitor) { - visitor.visit(this); - } - - public Expression getValue() { - return value; - } - - @Override - public void forVariables(VariableProcedure procedure) { - value.forVariables(procedure); - } - - @Override - public Expression accept(ExpressionTransformer transformer) { - return transformer.transform(this); - } - -} +package org.simantics.scl.compiler.elaboration.expressions; + +import org.simantics.scl.compiler.elaboration.contexts.SimplificationContext; +import org.simantics.scl.compiler.elaboration.contexts.TranslationContext; +import org.simantics.scl.compiler.elaboration.contexts.TypingContext; +import org.simantics.scl.compiler.errors.Locations; +import org.simantics.scl.compiler.internal.elaboration.utils.ExpressionDecorator; +import org.simantics.scl.compiler.internal.parsing.types.TypeAst; +import org.simantics.scl.compiler.types.Type; +import org.simantics.scl.compiler.types.exceptions.MatchException; + +import gnu.trove.map.hash.TObjectIntHashMap; +import gnu.trove.set.hash.THashSet; +import gnu.trove.set.hash.TIntHashSet; + +public class ETypeAnnotation extends SimplifiableExpression { + Expression value; + Type type; + TypeAst typeAst; + + public ETypeAnnotation(Expression value, TypeAst typeAst) { + this.value = value; + this.typeAst = typeAst; + } + + public ETypeAnnotation(long loc, Expression value, Type type) { + super(loc); + this.value = value; + this.type = type; + } + + public void collectRefs(TObjectIntHashMap allRefs, TIntHashSet refs) { + value.collectRefs(allRefs, refs); + } + + @Override + public void collectVars(TObjectIntHashMap allVars, + TIntHashSet vars) { + value.collectVars(allVars, vars); + } + + @Override + protected void updateType() throws MatchException { + setType(type); + } + + @Override + public void collectFreeVariables(THashSet vars) { + value.collectFreeVariables(vars); + } + + @Override + public Expression simplify(SimplificationContext context) { + return value.simplify(context); + } + + @Override + public Expression resolve(TranslationContext context) { + value = value.resolve(context); + type = context.toType(typeAst); + return this; + } + + @Override + public Expression resolveAsPattern(TranslationContext context) { + value = value.resolveAsPattern(context); + type = context.toType(typeAst); + return this; + } + + @Override + public Expression inferType(TypingContext context) { + return value.checkType(context, type); + } + + @Override + public Expression decorate(ExpressionDecorator decorator) { + value = value.decorate(decorator); + return decorator.decorate(this); + } + + @Override + public void collectEffects(THashSet effects) { + value.collectEffects(effects); + } + + @Override + public void setLocationDeep(long loc) { + if(location == Locations.NO_LOCATION) { + location = loc; + value.setLocationDeep(loc); + } + } + + @Override + public void accept(ExpressionVisitor visitor) { + visitor.visit(this); + } + + public Expression getValue() { + return value; + } + + @Override + public void forVariables(VariableProcedure procedure) { + value.forVariables(procedure); + } + + @Override + public Expression accept(ExpressionTransformer transformer) { + return transformer.transform(this); + } + +}