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