blob: 0afce608c9f3ca9a4d66553402859ff3cff7f5fb (
plain)
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
package vaporize.library;
import misc.*;
import cs132.vapor.ast.*;
import java.util.ArrayList;
class CFGNode {
private Node instruction;
private ArrayList<CFGNode> sources;
private ArrayList<CFGNode> dests;
private int line;
protected CFGNode(Node instruction) {
this.instruction = instruction;
this.sources = new ArrayList<>();
this.dests = new ArrayList<>();
this.line = this.instruction.sourcePos.line;
}
public String toString() {
return this.instruction.toString();
}
public int hashCode() {
return this.line;
}
/**
* For if we only have a line
* number. (VBranch issues)
*/
// FIXME
public boolean equals(Object other) {
return (other instanceof Node &&
(((Node) other).sourcePos ==
this.instruction.sourcePos)) ||
(other instanceof Integer &&
(((Integer) other)
.equals(this.instruction.sourcePos.line)));
}
protected void addSource(CFGNode node) {
this.sources.add(node);
}
protected void addDest(CFGNode node) {
this.dests.add(node);
}
protected Node getInstruction() {
return this.instruction;
}
protected ArrayList<CFGNode> getSources() {
return this.sources;
}
protected ArrayList<CFGNode> getDests() {
return this.dests;
}
}
|