Representation of array length expression, e.g., arr.length.
| 29 | * Representation of array length expression, e.g., arr.length. |
| 30 | */ |
| 31 | public class ArrayLengthExp implements UnaryExp { |
| 32 | |
| 33 | private final Var base; |
| 34 | |
| 35 | public ArrayLengthExp(Var base) { |
| 36 | this.base = base; |
| 37 | assert base.getType() instanceof ArrayType; |
| 38 | } |
| 39 | |
| 40 | public Var getBase() { |
| 41 | return base; |
| 42 | } |
| 43 | |
| 44 | @Override |
| 45 | public Var getOperand() { |
| 46 | return base; |
| 47 | } |
| 48 | |
| 49 | @Override |
| 50 | public PrimitiveType getType() { |
| 51 | return PrimitiveType.INT; |
| 52 | } |
| 53 | |
| 54 | @Override |
| 55 | public <T> T accept(ExpVisitor<T> visitor) { |
| 56 | return visitor.visit(this); |
| 57 | } |
| 58 | |
| 59 | @Override |
| 60 | public String toString() { |
| 61 | return base + ".length"; |
| 62 | } |
| 63 | } |
nothing calls this directly
no outgoing calls
no test coverage detected