]> gerrit.simantics Code Review - simantics/platform.git/blob
793bd006531a4bdc87135691360a00ba405eb52d
[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.types.Types;
11
12 import gnu.trove.map.hash.TObjectIntHashMap;
13 import gnu.trove.set.hash.THashSet;
14 import gnu.trove.set.hash.TIntHashSet;
15
16 public class ExpressionAccessor extends FieldAccessor {
17     public Expression fieldName;
18
19     public ExpressionAccessor(char accessSeparator, Expression fieldName) {
20         super(accessSeparator);
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 resolve(TranslationContext context) {
43         fieldName = fieldName.resolve(context);
44     }
45     
46     @Override
47     public void simplify(SimplificationContext context) {
48         fieldName = fieldName.simplify(context);
49     }
50     
51     @Override
52     public void checkType(TypingContext context) {
53         fieldName = fieldName.checkType(context, Types.STRING);
54     }
55
56     @Override
57     public Expression asExpression() {
58         return fieldName;
59     }
60
61     @Override
62     public void setLocationDeep(long loc) {
63         if(location == Locations.NO_LOCATION) {
64             location = loc;
65             fieldName.setLocationDeep(loc);
66         }
67     }
68     
69     @Override
70     public void accept(FieldAccessorVisitor visitor) {
71         visitor.visit(this);
72     }
73
74     @Override
75     public void forVariables(VariableProcedure procedure) {
76         fieldName.forVariables(procedure);
77     }
78 }