Representation of new array expression, e.g., new T[..].
| 30 | * Representation of new array expression, e.g., new T[..]. |
| 31 | */ |
| 32 | public class NewArray implements NewExp { |
| 33 | |
| 34 | private final ArrayType type; |
| 35 | |
| 36 | private final Var length; |
| 37 | |
| 38 | public NewArray(ArrayType type, Var length) { |
| 39 | this.type = type; |
| 40 | this.length = length; |
| 41 | } |
| 42 | |
| 43 | @Override |
| 44 | public ArrayType getType() { |
| 45 | return type; |
| 46 | } |
| 47 | |
| 48 | public Var getLength() { |
| 49 | return length; |
| 50 | } |
| 51 | |
| 52 | @Override |
| 53 | public Set<RValue> getUses() { |
| 54 | return Set.of(length); |
| 55 | } |
| 56 | |
| 57 | @Override |
| 58 | public <T> T accept(ExpVisitor<T> visitor) { |
| 59 | return visitor.visit(this); |
| 60 | } |
| 61 | |
| 62 | @Override |
| 63 | public String toString() { |
| 64 | return String.format("newarray %s[%s]", type.elementType(), length); |
| 65 | } |
| 66 | } |
nothing calls this directly
no outgoing calls
no test coverage detected