package org.simantics.scl.compiler.elaboration.expressions.accessor; import org.simantics.scl.compiler.elaboration.contexts.SimplificationContext; import org.simantics.scl.compiler.elaboration.contexts.TranslationContext; import org.simantics.scl.compiler.elaboration.contexts.TypingContext; import org.simantics.scl.compiler.elaboration.expressions.Expression; import org.simantics.scl.compiler.elaboration.expressions.Variable; import org.simantics.scl.compiler.elaboration.expressions.VariableProcedure; import org.simantics.scl.compiler.errors.Locations; import org.simantics.scl.compiler.internal.elaboration.utils.ExpressionDecorator; import org.simantics.scl.compiler.types.Types; import gnu.trove.map.hash.TObjectIntHashMap; import gnu.trove.set.hash.THashSet; import gnu.trove.set.hash.TIntHashSet; public class ExpressionAccessor extends FieldAccessor { public Expression fieldName; public ExpressionAccessor(Expression fieldName) { this.fieldName = fieldName; } @Override public void collectFreeVariables(THashSet vars) { fieldName.collectFreeVariables(vars); } @Override public void collectRefs(TObjectIntHashMap allRefs, TIntHashSet refs) { fieldName.collectRefs(allRefs, refs); } @Override public void collectVars(TObjectIntHashMap allVars, TIntHashSet vars) { fieldName.collectVars(allVars, vars); } @Override public void decorate(ExpressionDecorator decorator) { fieldName = fieldName.decorate(decorator); } @Override public void resolve(TranslationContext context) { fieldName = fieldName.resolve(context); } @Override public void simplify(SimplificationContext context) { fieldName = fieldName.simplify(context); } @Override public void checkType(TypingContext context) { fieldName = fieldName.checkType(context, Types.STRING); } @Override public Expression asExpression() { return fieldName; } @Override public void setLocationDeep(long loc) { if(location == Locations.NO_LOCATION) { location = loc; fieldName.setLocationDeep(loc); } } @Override public void accept(FieldAccessorVisitor visitor) { visitor.visit(this); } @Override public void forVariables(VariableProcedure procedure) { fieldName.forVariables(procedure); } }