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

Class RecordAccess

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

Represents a record access expression of the form " rec.f " where rec is the source record and f is the field . @author David J. Pearce

Source from the content-addressed store, hash-verified

4755 *
4756 */
4757 public static class RecordAccess extends AbstractExpr implements LVal, UnaryOperator {
4758 public RecordAccess(Type type, Expr lhs, Identifier rhs) {
4759 super(EXPR_recordaccess, type, lhs, rhs);
4760 }
4761
4762 /**
4763 * Get the source operand for this access. That is <code>e</code> in
4764 * <code>e.f/code>.
4765 */
4766 @Override
4767 public Expr getOperand() {
4768 return (Expr) get(1);
4769 }
4770
4771 /**
4772 * Get the field name for this access. That is <code>f</code> in
4773 * <code>e.f/code>.
4774 */
4775 public Identifier getField() {
4776 return (Identifier) get(2);
4777 }
4778
4779 public void setMove() {
4780 this.opcode = EXPR_recordborrow;
4781 }
4782
4783 public boolean isMove() {
4784 return opcode == EXPR_recordborrow;
4785 }
4786
4787 @Override
4788 public RecordAccess clone(Syntactic.Item[] operands) {
4789 return new RecordAccess((Type) operands[0], (Expr) operands[1], (Identifier) operands[2]);
4790 }
4791
4792 @Override
4793 public String toString() {
4794 return getOperand() + "." + getField();
4795 }
4796
4797 public static final Descriptor DESCRIPTOR_0a = new Descriptor(Operands.THREE, Data.ZERO, "EXPR_recordaccess") {
4798 @Override
4799 public Syntactic.Item construct(int opcode, Syntactic.Item[] operands, byte[] data) {
4800 return new RecordAccess((Type) operands[0], (Expr) operands[1], (Identifier) operands[2]);
4801 }
4802 };
4803
4804 public static final Descriptor DESCRIPTOR_0b = new Descriptor(Operands.THREE, Data.ZERO, "EXPR_recordborrow") {
4805 @Override
4806 public Syntactic.Item construct(int opcode, Syntactic.Item[] operands, byte[] data) {
4807 Expr.RecordAccess r = new RecordAccess((Type) operands[0], (Expr) operands[1],
4808 (Identifier) operands[2]);
4809 r.setMove();
4810 return r;
4811 }
4812 };
4813 }
4814

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected