Represents the use of some variable within an expression. For example, in x + 1 the expression x is a variable access expression. Every variable access is associated with a variable declaration that unique identifies which variable is being accessed. @author David J
| 3128 | * |
| 3129 | */ |
| 3130 | public static class VariableAccess extends AbstractExpr implements LVal { |
| 3131 | public VariableAccess(Type type, Decl.Variable decl) { |
| 3132 | super(EXPR_variablecopy, type, decl); |
| 3133 | } |
| 3134 | |
| 3135 | public Decl.Variable getVariableDeclaration() { |
| 3136 | return (Decl.Variable) get(1); |
| 3137 | } |
| 3138 | |
| 3139 | /** |
| 3140 | * Mark this variable access as a move or borrow |
| 3141 | */ |
| 3142 | public void setMove() { |
| 3143 | this.opcode = EXPR_variablemove; |
| 3144 | } |
| 3145 | |
| 3146 | public boolean isMove() { |
| 3147 | return this.opcode == EXPR_variablemove; |
| 3148 | } |
| 3149 | |
| 3150 | @Override |
| 3151 | public VariableAccess clone(Syntactic.Item[] operands) { |
| 3152 | return new VariableAccess((Type) operands[0], (Decl.Variable) operands[1]); |
| 3153 | } |
| 3154 | |
| 3155 | @Override |
| 3156 | public String toString() { |
| 3157 | return getVariableDeclaration().getName().toString(); |
| 3158 | } |
| 3159 | |
| 3160 | public static final Descriptor DESCRIPTOR_0a = new Descriptor(Operands.TWO, Data.ZERO, "EXPR_variablecopy") { |
| 3161 | @Override |
| 3162 | public Syntactic.Item construct(int opcode, Syntactic.Item[] operands, byte[] data) { |
| 3163 | return new VariableAccess((Type) operands[0], (Decl.Variable) operands[1]); |
| 3164 | } |
| 3165 | }; |
| 3166 | |
| 3167 | public static final Descriptor DESCRIPTOR_0b = new Descriptor(Operands.TWO, Data.ZERO, "EXPR_variablemove") { |
| 3168 | @Override |
| 3169 | public Syntactic.Item construct(int opcode, Syntactic.Item[] operands, byte[] data) { |
| 3170 | Expr.VariableAccess v = new VariableAccess((Type) operands[0], (Decl.Variable) operands[1]); |
| 3171 | v.setMove(); |
| 3172 | return v; |
| 3173 | } |
| 3174 | }; |
| 3175 | } |
| 3176 | |
| 3177 | // ========================================================================= |
| 3178 | // Logical Expressions |
nothing calls this directly
no outgoing calls
no test coverage detected