Skip to content

Commit 83e135a

Browse files
authored
Introduce LongCollection interface for storing instrumentation traces (#229)
1 parent 4014545 commit 83e135a

File tree

1 file changed

+44
-5
lines changed
  • usvm-jvm-instrumentation/src/collectors/java/org/usvm/instrumentation/collector/trace

1 file changed

+44
-5
lines changed

usvm-jvm-instrumentation/src/collectors/java/org/usvm/instrumentation/collector/trace/TraceCollector.java

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//DO NOT EDIT!
44
//USE TRACER
55
public class TraceCollector {
6-
public static LongHashSet trace = new LongHashSet();
6+
public static LongCollection trace = new LongHashSet();
77
public static LongArrayWrapper statics = new LongArrayWrapper();
88

99
public static void jcInstructionCovered(long jcInstructionId) {
@@ -13,12 +13,27 @@ public static void jcStaticFieldAccessed(long jcStaticFieldAccessId) {
1313
statics.add(jcStaticFieldAccessId);
1414
}
1515

16-
public static class LongArrayWrapper {
16+
public interface LongCollection {
17+
void add(long key);
18+
19+
long[] getAllValues();
20+
21+
boolean contains(long key);
22+
23+
int realSize();
24+
25+
boolean isEmpty();
26+
27+
void clear();
28+
}
29+
30+
public static class LongArrayWrapper implements LongCollection {
1731
public long[] arr;
1832
public int size;
1933

20-
LongArrayWrapper() {
34+
public LongArrayWrapper() {
2135
arr = new long[10];
36+
size = 0;
2237
}
2338

2439
public void add(long el) {
@@ -35,6 +50,31 @@ public void removeLast() {
3550
size--;
3651
}
3752

53+
public long[] getAllValues() {
54+
long[] res = new long[size];
55+
for (int i = 0; i < size; i++) {
56+
res[i] = arr[i];
57+
}
58+
return res;
59+
}
60+
61+
public boolean contains(long key) {
62+
for (int i = 0; i < size; i++) {
63+
if (arr[i] == key) {
64+
return true;
65+
}
66+
}
67+
return false;
68+
}
69+
70+
public int realSize() {
71+
return size;
72+
}
73+
74+
public boolean isEmpty() {
75+
return size == 0;
76+
}
77+
3878
public void clear() {
3979
for (int i = 0; i < size; i++) {
4080
arr[i] = 0;
@@ -52,8 +92,7 @@ private void resize() {
5292
}
5393
}
5494

55-
56-
public static class LongHashSet {
95+
public static class LongHashSet implements LongCollection {
5796
private static final int DEFAULT_CAPACITY = 1024;
5897
private static final double DEFAULT_LOAD_FACTOR = 0.75;
5998

0 commit comments

Comments
 (0)