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.TIntHashSet;
14 public class ETypeAnnotation extends SimplifiableExpression {
15 public Expression value;
19 public ETypeAnnotation(Expression value, TypeAst typeAst) {
21 this.typeAst = typeAst;
24 public ETypeAnnotation(long loc, Expression value, Type type) {
31 public void collectVars(TObjectIntHashMap<Variable> allVars,
33 value.collectVars(allVars, vars);
37 protected void updateType() throws MatchException {
42 public Expression simplify(SimplificationContext context) {
43 return value.simplify(context);
47 public Expression resolve(TranslationContext context) {
48 value = value.resolve(context);
49 type = context.toType(typeAst);
54 public Expression resolveAsPattern(TranslationContext context) {
55 value = value.resolveAsPattern(context);
56 type = context.toType(typeAst);
61 public Expression inferType(TypingContext context) {
62 return value.checkType(context, type);
66 public void setLocationDeep(long loc) {
67 if(location == Locations.NO_LOCATION) {
69 value.setLocationDeep(loc);
74 public void accept(ExpressionVisitor visitor) {
78 public Expression getValue() {
83 public Expression accept(ExpressionTransformer transformer) {
84 return transformer.transform(this);