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

Class ArrayAccess

src/main/java/pascal/taie/ir/exp/ArrayAccess.java:33–76  ·  view source on GitHub ↗

Representation of array access expression, e.g., a[i].

Source from the content-addressed store, hash-verified

31 * Representation of array access expression, e.g., a[i].
32 */
33public class ArrayAccess implements LValue, RValue {
34
35 private final Var base;
36
37 private final Var index;
38
39 public ArrayAccess(Var base, Var index) {
40 this.base = base;
41 this.index = index;
42 assert base.getType() instanceof ArrayType;
43 }
44
45 public Var getBase() {
46 return base;
47 }
48
49 public Var getIndex() {
50 return index;
51 }
52
53 @Override
54 public Type getType() {
55 if (base.getType() instanceof ArrayType) {
56 return ((ArrayType) base.getType()).elementType();
57 } else {
58 throw new RuntimeException("Invalid base type: " + base.getType());
59 }
60 }
61
62 @Override
63 public Set<RValue> getUses() {
64 return Set.of(base, index);
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 return String.format("%s[%s]", base, index);
75 }
76}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected