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