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 collectRefs(TObjectIntHashMap<Object> allRefs,
31 fieldName.collectRefs(allRefs, refs);
35 public void collectVars(TObjectIntHashMap<Variable> allVars,
37 fieldName.collectVars(allVars, vars);
41 public void resolve(TranslationContext context) {
42 fieldName = fieldName.resolve(context);
46 public void simplify(SimplificationContext context) {
47 fieldName = fieldName.simplify(context);
51 public void checkType(TypingContext context) {
52 fieldName = fieldName.checkType(context, Types.STRING);
56 public Expression asExpression() {
61 public void setLocationDeep(long loc) {
62 if(location == Locations.NO_LOCATION) {
64 fieldName.setLocationDeep(loc);
69 public void accept(FieldAccessorVisitor visitor) {