MCPcopy Create free account
hub / github.com/Whiley/WhileyCompiler / ArrayAccess

Class ArrayAccess

src/main/java/wyil/lang/WyilFile.java:4461–4517  ·  view source on GitHub ↗

Represents an array access expression of the form " arr[e] " where arr is the source array and e the subscript expression . This returns the value held in the element determined by e . @author David J. Pearce

Source from the content-addressed store, hash-verified

4459 *
4460 */
4461 public static class ArrayAccess extends AbstractExpr implements LVal, BinaryOperator {
4462 public ArrayAccess(Type type, Expr src, Expr index) {
4463 super(EXPR_arrayaccess, type, src, index);
4464 }
4465
4466 /**
4467 * Get the source array operand for this access. That is <code>xs</code> in
4468 * <code>xs[i]</code>.
4469 */
4470 @Override
4471 public Expr getFirstOperand() {
4472 return (Expr) get(1);
4473 }
4474
4475 /**
4476 * Get the index operand for this access. That is <code>i</code> in
4477 * <code>xs[i]</code>.
4478 */
4479 @Override
4480 public Expr getSecondOperand() {
4481 return (Expr) get(2);
4482 }
4483
4484 public void setMove() {
4485 this.opcode = EXPR_arrayborrow;
4486 }
4487
4488 public boolean isMove() {
4489 return opcode == EXPR_arrayborrow;
4490 }
4491
4492 @Override
4493 public ArrayAccess clone(Syntactic.Item[] operands) {
4494 return new ArrayAccess((Type) operands[0], (Expr) operands[1], (Expr) operands[2]);
4495 }
4496
4497 @Override
4498 public String toString() {
4499 return getFirstOperand() + "[" + getSecondOperand() + "]";
4500 }
4501
4502 public static final Descriptor DESCRIPTOR_0a = new Descriptor(Operands.THREE, Data.ZERO, "EXPR_arrayaccess") {
4503 @Override
4504 public Syntactic.Item construct(int opcode, Syntactic.Item[] operands, byte[] data) {
4505 return new ArrayAccess((Type) operands[0], (Expr) operands[1], (Expr) operands[2]);
4506 }
4507 };
4508
4509 public static final Descriptor DESCRIPTOR_0b = new Descriptor(Operands.THREE, Data.ZERO, "EXPR_arrayborrow") {
4510 @Override
4511 public Syntactic.Item construct(int opcode, Syntactic.Item[] operands, byte[] data) {
4512 Expr.ArrayAccess r = new ArrayAccess((Type) operands[0], (Expr) operands[1], (Expr) operands[2]);
4513 r.setMove();
4514 return r;
4515 }
4516 };
4517 }
4518

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected