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(char accessSeparator, Expression fieldName) {
21 super(accessSeparator);
22 this.fieldName = fieldName;
26 public void collectFreeVariables(THashSet<Variable> vars) {
27 fieldName.collectFreeVariables(vars);
31 public void collectRefs(TObjectIntHashMap<Object> allRefs,
33 fieldName.collectRefs(allRefs, refs);
37 public void collectVars(TObjectIntHashMap<Variable> allVars,
39 fieldName.collectVars(allVars, vars);
43 public void decorate(ExpressionDecorator decorator) {
44 fieldName = fieldName.decorate(decorator);
48 public void resolve(TranslationContext context) {
49 fieldName = fieldName.resolve(context);
53 public void simplify(SimplificationContext context) {
54 fieldName = fieldName.simplify(context);
58 public void checkType(TypingContext context) {
59 fieldName = fieldName.checkType(context, Types.STRING);
63 public Expression asExpression() {
68 public void setLocationDeep(long loc) {
69 if(location == Locations.NO_LOCATION) {
71 fieldName.setLocationDeep(loc);
76 public void accept(FieldAccessorVisitor visitor) {
81 public void forVariables(VariableProcedure procedure) {
82 fieldName.forVariables(procedure);