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.elaboration.utils.ExpressionDecorator;
8 import org.simantics.scl.compiler.internal.parsing.types.TypeAst;
9 import org.simantics.scl.compiler.types.Type;
10 import org.simantics.scl.compiler.types.exceptions.MatchException;
12 import gnu.trove.map.hash.TObjectIntHashMap;
13 import gnu.trove.set.hash.THashSet;
14 import gnu.trove.set.hash.TIntHashSet;
16 public class ETypeAnnotation extends SimplifiableExpression {
21 public ETypeAnnotation(Expression value, TypeAst typeAst) {
23 this.typeAst = typeAst;
26 public ETypeAnnotation(long loc, Expression value, Type type) {
32 public void collectRefs(TObjectIntHashMap<Object> allRefs, TIntHashSet refs) {
33 value.collectRefs(allRefs, refs);
37 public void collectVars(TObjectIntHashMap<Variable> allVars,
39 value.collectVars(allVars, vars);
43 protected void updateType() throws MatchException {
48 public void collectFreeVariables(THashSet<Variable> vars) {
49 value.collectFreeVariables(vars);
53 public Expression simplify(SimplificationContext context) {
54 return value.simplify(context);
58 public Expression resolve(TranslationContext context) {
59 value = value.resolve(context);
60 type = context.toType(typeAst);
65 public Expression resolveAsPattern(TranslationContext context) {
66 value = value.resolveAsPattern(context);
67 type = context.toType(typeAst);
72 public Expression inferType(TypingContext context) {
73 return value.checkType(context, type);
77 public Expression decorate(ExpressionDecorator decorator) {
78 value = value.decorate(decorator);
79 return decorator.decorate(this);
83 public void collectEffects(THashSet<Type> effects) {
84 value.collectEffects(effects);
88 public void setLocationDeep(long loc) {
89 if(location == Locations.NO_LOCATION) {
91 value.setLocationDeep(loc);
96 public void accept(ExpressionVisitor visitor) {
100 public Expression getValue() {
105 public void forVariables(VariableProcedure procedure) {
106 value.forVariables(procedure);
110 public Expression accept(ExpressionTransformer transformer) {
111 return transformer.transform(this);