]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/accessor/IdAccessor.java
(refs #7375) Replaced forVariables by a visitor
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / elaboration / expressions / accessor / IdAccessor.java
1 package org.simantics.scl.compiler.elaboration.expressions.accessor;
2
3 import org.simantics.scl.compiler.constants.StringConstant;
4 import org.simantics.scl.compiler.elaboration.expressions.ELiteral;
5 import org.simantics.scl.compiler.elaboration.expressions.Expression;
6 import org.simantics.scl.compiler.errors.Locations;
7
8 public class IdAccessor extends FieldAccessor {
9     public final String fieldName;
10
11     public IdAccessor(char accessSeparator, String fieldName) {
12         super(accessSeparator);
13         this.fieldName = fieldName;
14     }
15
16     @Override
17     public Expression asExpression() {
18         return new ELiteral(new StringConstant(fieldName));
19     }
20
21     @Override
22     public boolean isVariableId() {
23         return fieldName.equals("variable");
24     }
25     
26     @Override
27     public void setLocationDeep(long loc) {
28         if(location == Locations.NO_LOCATION)
29             location = loc;
30     }
31     
32     @Override
33     public void accept(FieldAccessorVisitor visitor) {
34         visitor.visit(this);
35     }
36 }