]> gerrit.simantics Code Review - simantics/platform.git/blob
2febc404f2e967f87d71f28573bf578e74196dfe
[simantics/platform.git] /
1 package org.simantics.scl.compiler.elaboration.expressions.accessor;
2
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.elaboration.expressions.Expression;
7 import org.simantics.scl.compiler.elaboration.expressions.Variable;
8 import org.simantics.scl.compiler.errors.Locations;
9 import org.simantics.scl.compiler.types.Types;
10
11 import gnu.trove.map.hash.TObjectIntHashMap;
12 import gnu.trove.set.hash.TIntHashSet;
13
14 public class ExpressionAccessor extends FieldAccessor {
15     public Expression fieldName;
16
17     public ExpressionAccessor(char accessSeparator, Expression fieldName) {
18         super(accessSeparator);
19         this.fieldName = fieldName;
20     }
21     
22     @Override
23     public void collectVars(TObjectIntHashMap<Variable> allVars,
24             TIntHashSet vars) {
25         fieldName.collectVars(allVars, vars);
26     }
27     
28     @Override
29     public void resolve(TranslationContext context) {
30         fieldName = fieldName.resolve(context);
31     }
32     
33     @Override
34     public void simplify(SimplificationContext context) {
35         fieldName = fieldName.simplify(context);
36     }
37     
38     @Override
39     public void checkType(TypingContext context) {
40         fieldName = fieldName.checkType(context, Types.STRING);
41     }
42
43     @Override
44     public Expression asExpression() {
45         return fieldName;
46     }
47
48     @Override
49     public void setLocationDeep(long loc) {
50         if(location == Locations.NO_LOCATION) {
51             location = loc;
52             fieldName.setLocationDeep(loc);
53         }
54     }
55     
56     @Override
57     public void accept(FieldAccessorVisitor visitor) {
58         visitor.visit(this);
59     }
60 }