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.internal.elaboration.utils.ExpressionDecorator;
11 import org.simantics.scl.compiler.types.Types;
13 import gnu.trove.map.hash.TObjectIntHashMap;
14 import gnu.trove.set.hash.THashSet;
15 import gnu.trove.set.hash.TIntHashSet;
17 public class ExpressionAccessor extends FieldAccessor {
18 public Expression fieldName;
20 public ExpressionAccessor(Expression fieldName) {
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 decorate(ExpressionDecorator decorator) {
43 fieldName = fieldName.decorate(decorator);
47 public void resolve(TranslationContext context) {
48 fieldName = fieldName.resolve(context);
52 public void simplify(SimplificationContext context) {
53 fieldName = fieldName.simplify(context);
57 public void checkType(TypingContext context) {
58 fieldName = fieldName.checkType(context, Types.STRING);
62 public Expression asExpression() {
67 public void setLocationDeep(long loc) {
68 if(location == Locations.NO_LOCATION) {
70 fieldName.setLocationDeep(loc);
75 public void accept(FieldAccessorVisitor visitor) {
80 public void forVariables(VariableProcedure procedure) {
81 fieldName.forVariables(procedure);