]> gerrit.simantics Code Review - simantics/platform.git/blob
0220a9ab859149d6be43ab8c25353f43b2bf34fe
[simantics/platform.git] /
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.elaboration.expressions.VariableProcedure;
7 import org.simantics.scl.compiler.errors.Locations;
8
9 public class IdAccessor extends FieldAccessor {
10     public final String fieldName;
11
12     public IdAccessor(String fieldName) {
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
37     @Override
38     public void forVariables(VariableProcedure procedure) {
39     }
40 }