1 package org.simantics.scl.compiler.elaboration.expressions.accessor;
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;
12 import gnu.trove.map.hash.TObjectIntHashMap;
13 import gnu.trove.set.hash.THashSet;
14 import gnu.trove.set.hash.TIntHashSet;
16 public class ExpressionAccessor extends FieldAccessor {
17 public Expression fieldName;
19 public ExpressionAccessor(char accessSeparator, Expression fieldName) {
20 super(accessSeparator);
21 this.fieldName = fieldName;
25 public void collectFreeVariables(THashSet<Variable> vars) {
26 fieldName.collectFreeVariables(vars);
30 public void collectRefs(TObjectIntHashMap<Object> allRefs,
32 fieldName.collectRefs(allRefs, refs);
36 public void collectVars(TObjectIntHashMap<Variable> allVars,
38 fieldName.collectVars(allVars, vars);
42 public void resolve(TranslationContext context) {
43 fieldName = fieldName.resolve(context);
47 public void simplify(SimplificationContext context) {
48 fieldName = fieldName.simplify(context);
52 public void checkType(TypingContext context) {
53 fieldName = fieldName.checkType(context, Types.STRING);
57 public Expression asExpression() {
62 public void setLocationDeep(long loc) {
63 if(location == Locations.NO_LOCATION) {
65 fieldName.setLocationDeep(loc);
70 public void accept(FieldAccessorVisitor visitor) {
75 public void forVariables(VariableProcedure procedure) {
76 fieldName.forVariables(procedure);