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) {
32 public void collectVars(TObjectIntHashMap<Variable> allVars,
34 value.collectVars(allVars, vars);
38 protected void updateType() throws MatchException {
43 public void collectFreeVariables(THashSet<Variable> vars) {
44 value.collectFreeVariables(vars);
48 public Expression simplify(SimplificationContext context) {
49 return value.simplify(context);
53 public Expression resolve(TranslationContext context) {
54 value = value.resolve(context);
55 type = context.toType(typeAst);
60 public Expression resolveAsPattern(TranslationContext context) {
61 value = value.resolveAsPattern(context);
62 type = context.toType(typeAst);
67 public Expression inferType(TypingContext context) {
68 return value.checkType(context, type);
72 public void setLocationDeep(long loc) {
73 if(location == Locations.NO_LOCATION) {
75 value.setLocationDeep(loc);
80 public void accept(ExpressionVisitor visitor) {
84 public Expression getValue() {
89 public Expression accept(ExpressionTransformer transformer) {
90 return transformer.transform(this);