1 package org.simantics.scl.compiler.elaboration.expressions.accessor;
\r
3 import gnu.trove.map.hash.TObjectIntHashMap;
\r
4 import gnu.trove.set.hash.THashSet;
\r
5 import gnu.trove.set.hash.TIntHashSet;
\r
7 import org.simantics.scl.compiler.elaboration.contexts.SimplificationContext;
\r
8 import org.simantics.scl.compiler.elaboration.contexts.TranslationContext;
\r
9 import org.simantics.scl.compiler.elaboration.contexts.TypingContext;
\r
10 import org.simantics.scl.compiler.elaboration.expressions.Expression;
\r
11 import org.simantics.scl.compiler.elaboration.expressions.Variable;
\r
12 import org.simantics.scl.compiler.elaboration.expressions.VariableProcedure;
\r
13 import org.simantics.scl.compiler.errors.Locations;
\r
14 import org.simantics.scl.compiler.internal.elaboration.utils.ExpressionDecorator;
\r
15 import org.simantics.scl.compiler.types.Types;
\r
17 public class ExpressionAccessor extends FieldAccessor {
\r
18 public Expression fieldName;
\r
20 public ExpressionAccessor(Expression fieldName) {
\r
21 this.fieldName = fieldName;
\r
25 public void collectFreeVariables(THashSet<Variable> vars) {
\r
26 fieldName.collectFreeVariables(vars);
\r
30 public void collectRefs(TObjectIntHashMap<Object> allRefs,
\r
32 fieldName.collectRefs(allRefs, refs);
\r
36 public void collectVars(TObjectIntHashMap<Variable> allVars,
\r
38 fieldName.collectVars(allVars, vars);
\r
42 public void decorate(ExpressionDecorator decorator) {
\r
43 fieldName = fieldName.decorate(decorator);
\r
47 public void resolve(TranslationContext context) {
\r
48 fieldName = fieldName.resolve(context);
\r
52 public void simplify(SimplificationContext context) {
\r
53 fieldName = fieldName.simplify(context);
\r
57 public void checkType(TypingContext context) {
\r
58 fieldName = fieldName.checkType(context, Types.STRING);
\r
62 public Expression asExpression() {
\r
67 public void setLocationDeep(long loc) {
\r
68 if(location == Locations.NO_LOCATION) {
\r
70 fieldName.setLocationDeep(loc);
\r
75 public void accept(FieldAccessorVisitor visitor) {
\r
76 visitor.visit(this);
\r
80 public void forVariables(VariableProcedure procedure) {
\r
81 fieldName.forVariables(procedure);
\r