]> gerrit.simantics Code Review - simantics/platform.git/blob
100d3124b27968fec89f09162a94ee3ed5d038aa
[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(Expression fieldName) {
21         this.fieldName = fieldName;
22     }
23     
24     @Override
25     public void collectFreeVariables(THashSet<Variable> vars) {
26         fieldName.collectFreeVariables(vars);
27     }
28     
29     @Override
30     public void collectRefs(TObjectIntHashMap<Object> allRefs,
31             TIntHashSet refs) {
32         fieldName.collectRefs(allRefs, refs);
33     }
34     
35     @Override
36     public void collectVars(TObjectIntHashMap<Variable> allVars,
37             TIntHashSet vars) {
38         fieldName.collectVars(allVars, vars);
39     }
40     
41     @Override
42     public void decorate(ExpressionDecorator decorator) {
43         fieldName = fieldName.decorate(decorator);
44     }
45     
46     @Override
47     public void resolve(TranslationContext context) {
48         fieldName = fieldName.resolve(context);
49     }
50     
51     @Override
52     public void simplify(SimplificationContext context) {
53         fieldName = fieldName.simplify(context);
54     }
55     
56     @Override
57     public void checkType(TypingContext context) {
58         fieldName = fieldName.checkType(context, Types.STRING);
59     }
60
61     @Override
62     public Expression asExpression() {
63         return fieldName;
64     }
65
66     @Override
67     public void setLocationDeep(long loc) {
68         if(location == Locations.NO_LOCATION) {
69             location = loc;
70             fieldName.setLocationDeep(loc);
71         }
72     }
73     
74     @Override
75     public void accept(FieldAccessorVisitor visitor) {
76         visitor.visit(this);
77     }
78
79     @Override
80     public void forVariables(VariableProcedure procedure) {
81         fieldName.forVariables(procedure);
82     }
83 }