MCPcopy Create free account
hub / github.com/LFYSec/MScan / NewMultiArray

Class NewMultiArray

src/main/java/pascal/taie/ir/exp/NewMultiArray.java:34–82  ·  view source on GitHub ↗

Representation of new multi-array expression, e.g., new T[..][..][..].

Source from the content-addressed store, hash-verified

32 * Representation of new multi-array expression, e.g., new T[..][..][..].
33 */
34public class NewMultiArray implements NewExp {
35
36 private final ArrayType type;
37
38 private final List<Var> lengths;
39
40 public NewMultiArray(ArrayType type, List<Var> lengths) {
41 this.type = type;
42 this.lengths = List.copyOf(lengths);
43 }
44
45 @Override
46 public ArrayType getType() {
47 return type;
48 }
49
50 public int getLengthCount() {
51 return lengths.size();
52 }
53
54 public Var getLength(int i) {
55 return lengths.get(i);
56 }
57
58 public List<Var> getLengths() {
59 return lengths;
60 }
61
62 @Override
63 public Set<RValue> getUses() {
64 return new ArraySet<>(lengths);
65 }
66
67 @Override
68 public <T> T accept(ExpVisitor<T> visitor) {
69 return visitor.visit(this);
70 }
71
72 @Override
73 public String toString() {
74 StringBuilder sb = new StringBuilder("newmultiarray ");
75 sb.append(type.baseType());
76 lengths.forEach(length ->
77 sb.append('[').append(length).append(']'));
78 sb.append("[]".repeat(
79 Math.max(0, type.dimensions() - lengths.size())));
80 return sb.toString();
81 }
82}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected