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 public class ETypeAnnotation extends SimplifiableExpression {
12 public Expression value;
16 public ETypeAnnotation(Expression value, TypeAst typeAst) {
18 this.typeAst = typeAst;
21 public ETypeAnnotation(long loc, Expression value, Type type) {
28 protected void updateType() throws MatchException {
33 public Expression simplify(SimplificationContext context) {
34 return value.simplify(context);
38 public Expression resolve(TranslationContext context) {
39 value = value.resolve(context);
40 type = context.toType(typeAst);
45 public Expression resolveAsPattern(TranslationContext context) {
46 value = value.resolveAsPattern(context);
47 type = context.toType(typeAst);
52 public Expression inferType(TypingContext context) {
53 return value.checkType(context, type);
57 public void setLocationDeep(long loc) {
58 if(location == Locations.NO_LOCATION) {
60 value.setLocationDeep(loc);
65 public void accept(ExpressionVisitor visitor) {
69 public Expression getValue() {
74 public Expression accept(ExpressionTransformer transformer) {
75 return transformer.transform(this);