]> gerrit.simantics Code Review - simantics/platform.git/blob
e4cdd0937f7027e0498f270d79a0126de5676488
[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 collectRefs(TObjectIntHashMap<Object> allRefs,
30             TIntHashSet refs) {
31         fieldName.collectRefs(allRefs, refs);
32     }
33     
34     @Override
35     public void collectVars(TObjectIntHashMap<Variable> allVars,
36             TIntHashSet vars) {
37         fieldName.collectVars(allVars, vars);
38     }
39     
40     @Override
41     public void resolve(TranslationContext context) {
42         fieldName = fieldName.resolve(context);
43     }
44     
45     @Override
46     public void simplify(SimplificationContext context) {
47         fieldName = fieldName.simplify(context);
48     }
49     
50     @Override
51     public void checkType(TypingContext context) {
52         fieldName = fieldName.checkType(context, Types.STRING);
53     }
54
55     @Override
56     public Expression asExpression() {
57         return fieldName;
58     }
59
60     @Override
61     public void setLocationDeep(long loc) {
62         if(location == Locations.NO_LOCATION) {
63             location = loc;
64             fieldName.setLocationDeep(loc);
65         }
66     }
67     
68     @Override
69     public void accept(FieldAccessorVisitor visitor) {
70         visitor.visit(this);
71     }
72 }