-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVStructTuple.java
More file actions
41 lines (35 loc) · 1.04 KB
/
Copy pathVStructTuple.java
File metadata and controls
41 lines (35 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import java.util.ArrayList;
import java.util.List;
class VStructTuple implements IValue {
String tag;
List<IValue> values;
VStructTuple(String tag, List<IValue> values) {
this.tag = tag;
this.values = values;
}
public String getTag() {
return tag;
}
public List<IValue> getValues() {
return values;
}
@Override
public boolean equals(Object other) {
if (!(other instanceof VStructTuple st)) return false;
if (!this.tag.equals(st.tag)) return false;
return this.values.equals(st.values);
}
@Override
public String toStr() {
StringBuilder sb = new StringBuilder(tag + "(");
List<IValue> filtered = new ArrayList<>();
for (IValue v : values) {
if (!(v instanceof VUnit)) filtered.add(v);
}
for (int i = 0; i < filtered.size(); i++) {
sb.append(filtered.get(i).toStr());
if (i < filtered.size() - 1) sb.append(", ");
}
return sb.append(")").toString();
}
}