1 package org.simantics.scl.compiler.elaboration.expressions;
3 import org.simantics.scl.compiler.elaboration.contexts.SimplificationContext;
4 import org.simantics.scl.compiler.elaboration.contexts.TranslationContext;
5 import org.simantics.scl.compiler.elaboration.contexts.TypingContext;
6 import org.simantics.scl.compiler.errors.Locations;
7 import org.simantics.scl.compiler.internal.parsing.types.TypeAst;
8 import org.simantics.scl.compiler.types.Type;
9 import org.simantics.scl.compiler.types.exceptions.MatchException;
11 import gnu.trove.map.hash.TObjectIntHashMap;
12 import gnu.trove.set.hash.THashSet;
13 import gnu.trove.set.hash.TIntHashSet;
15 public class ETypeAnnotation extends SimplifiableExpression {
20 public ETypeAnnotation(Expression value, TypeAst typeAst) {
22 this.typeAst = typeAst;
25 public ETypeAnnotation(long loc, Expression value, Type type) {
31 public void collectRefs(TObjectIntHashMap<Object> allRefs, TIntHashSet refs) {
32 value.collectRefs(allRefs, refs);
36 public void collectVars(TObjectIntHashMap<Variable> allVars,
38 value.collectVars(allVars, vars);
42 protected void updateType() throws MatchException {
47 public void collectFreeVariables(THashSet<Variable> vars) {
48 value.collectFreeVariables(vars);
52 public Expression simplify(SimplificationContext context) {
53 return value.simplify(context);
57 public Expression resolve(TranslationContext context) {
58 value = value.resolve(context);
59 type = context.toType(typeAst);
64 public Expression resolveAsPattern(TranslationContext context) {
65 value = value.resolveAsPattern(context);
66 type = context.toType(typeAst);
71 public Expression inferType(TypingContext context) {
72 return value.checkType(context, type);
76 public void collectEffects(THashSet<Type> effects) {
77 value.collectEffects(effects);
81 public void setLocationDeep(long loc) {
82 if(location == Locations.NO_LOCATION) {
84 value.setLocationDeep(loc);
89 public void accept(ExpressionVisitor visitor) {
93 public Expression getValue() {
98 public void forVariables(VariableProcedure procedure) {
99 value.forVariables(procedure);
103 public Expression accept(ExpressionTransformer transformer) {
104 return transformer.transform(this);