]> gerrit.simantics Code Review - simantics/platform.git/blob
0d8da56d45fd194aad28ff83c2104b833ead823e
[simantics/platform.git] /
1 package org.simantics.scl.compiler.elaboration.expressions.accessor;\r
2 \r
3 import gnu.trove.map.hash.TObjectIntHashMap;\r
4 import gnu.trove.set.hash.THashSet;\r
5 import gnu.trove.set.hash.TIntHashSet;\r
6 \r
7 import org.simantics.scl.compiler.elaboration.contexts.SimplificationContext;\r
8 import org.simantics.scl.compiler.elaboration.contexts.TranslationContext;\r
9 import org.simantics.scl.compiler.elaboration.contexts.TypingContext;\r
10 import org.simantics.scl.compiler.elaboration.expressions.Expression;\r
11 import org.simantics.scl.compiler.elaboration.expressions.Variable;\r
12 import org.simantics.scl.compiler.elaboration.expressions.VariableProcedure;\r
13 import org.simantics.scl.compiler.errors.Locations;\r
14 import org.simantics.scl.compiler.internal.elaboration.utils.ExpressionDecorator;\r
15 import org.simantics.scl.compiler.types.Types;\r
16 \r
17 public class ExpressionAccessor extends FieldAccessor {\r
18     public Expression fieldName;\r
19 \r
20     public ExpressionAccessor(Expression fieldName) {\r
21         this.fieldName = fieldName;\r
22     }\r
23     \r
24     @Override\r
25     public void collectFreeVariables(THashSet<Variable> vars) {\r
26         fieldName.collectFreeVariables(vars);\r
27     }\r
28     \r
29     @Override\r
30     public void collectRefs(TObjectIntHashMap<Object> allRefs,\r
31             TIntHashSet refs) {\r
32         fieldName.collectRefs(allRefs, refs);\r
33     }\r
34     \r
35     @Override\r
36     public void collectVars(TObjectIntHashMap<Variable> allVars,\r
37             TIntHashSet vars) {\r
38         fieldName.collectVars(allVars, vars);\r
39     }\r
40     \r
41     @Override\r
42     public void decorate(ExpressionDecorator decorator) {\r
43         fieldName = fieldName.decorate(decorator);\r
44     }\r
45     \r
46     @Override\r
47     public void resolve(TranslationContext context) {\r
48         fieldName = fieldName.resolve(context);\r
49     }\r
50     \r
51     @Override\r
52     public void simplify(SimplificationContext context) {\r
53         fieldName = fieldName.simplify(context);\r
54     }\r
55     \r
56     @Override\r
57     public void checkType(TypingContext context) {\r
58         fieldName = fieldName.checkType(context, Types.STRING);\r
59     }\r
60 \r
61     @Override\r
62     public Expression asExpression() {\r
63         return fieldName;\r
64     }\r
65 \r
66     @Override\r
67     public void setLocationDeep(long loc) {\r
68         if(location == Locations.NO_LOCATION) {\r
69             location = loc;\r
70             fieldName.setLocationDeep(loc);\r
71         }\r
72     }\r
73     \r
74     @Override\r
75     public void accept(FieldAccessorVisitor visitor) {\r
76         visitor.visit(this);\r
77     }\r
78 \r
79     @Override\r
80     public void forVariables(VariableProcedure procedure) {\r
81         fieldName.forVariables(procedure);\r
82     }\r
83 }\r