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.errors.Locations;
9 import org.simantics.scl.compiler.types.Types;
11 import gnu.trove.map.hash.TObjectIntHashMap;
12 import gnu.trove.set.hash.THashSet;
13 import gnu.trove.set.hash.TIntHashSet;
15 public class ExpressionAccessor extends FieldAccessor {
16 public Expression fieldName;
18 public ExpressionAccessor(char accessSeparator, Expression fieldName) {
19 super(accessSeparator);
20 this.fieldName = fieldName;
24 public void collectFreeVariables(THashSet<Variable> vars) {
25 fieldName.collectFreeVariables(vars);
29 public void collectVars(TObjectIntHashMap<Variable> allVars,
31 fieldName.collectVars(allVars, vars);
35 public void resolve(TranslationContext context) {
36 fieldName = fieldName.resolve(context);
40 public void simplify(SimplificationContext context) {
41 fieldName = fieldName.simplify(context);
45 public void checkType(TypingContext context) {
46 fieldName = fieldName.checkType(context, Types.STRING);
50 public Expression asExpression() {
55 public void setLocationDeep(long loc) {
56 if(location == Locations.NO_LOCATION) {
58 fieldName.setLocationDeep(loc);
63 public void accept(FieldAccessorVisitor visitor) {