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