]> gerrit.simantics Code Review - simantics/platform.git/blob
9cb37e58ff12c610207aad0a828a7dc2a8fabd60
[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(char accessSeparator, String fieldName) {
13         super(accessSeparator);
14         this.fieldName = fieldName;
15     }
16
17     @Override
18     public Expression asExpression() {
19         return new ELiteral(new StringConstant(fieldName));
20     }
21
22     @Override
23     public boolean isVariableId() {
24         return fieldName.equals("variable");
25     }
26     
27     @Override
28     public void setLocationDeep(long loc) {
29         if(location == Locations.NO_LOCATION)
30             location = loc;
31     }
32     
33     @Override
34     public void accept(FieldAccessorVisitor visitor) {
35         visitor.visit(this);
36     }
37
38     @Override
39     public void forVariables(VariableProcedure procedure) {
40     }
41 }