]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/accessor/StringAccessor.java
(refs #7375) Replaced forVariables by a visitor
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / elaboration / expressions / accessor / StringAccessor.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 StringAccessor extends FieldAccessor {
9     public final String fieldName;
10
11     public StringAccessor(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 void setLocationDeep(long loc) {
23         if(location == Locations.NO_LOCATION)
24             location = loc;
25     }
26
27     @Override
28     public void accept(FieldAccessorVisitor visitor) {
29         visitor.visit(this);
30     }
31 }