summaryrefslogtreecommitdiff
path: root/vaporize/library/CFGNode.java
diff options
context:
space:
mode:
authorbd-912 <bdunahu@colostate.edu>2024-04-20 13:23:01 -0600
committerbd-912 <bdunahu@colostate.edu>2024-04-20 13:23:01 -0600
commitb320d02e1dbfa255ac0c919e37f89aa0108edaa5 (patch)
tree2c9660327a0b944cf2779ae45b9c1de825d9a9c5 /vaporize/library/CFGNode.java
parentc5ec4e0c84e5199d5a5ad418a0480749fcf17bab (diff)
Implement partial reachable tracking in CFG
Diffstat (limited to 'vaporize/library/CFGNode.java')
-rw-r--r--vaporize/library/CFGNode.java24
1 files changed, 20 insertions, 4 deletions
diff --git a/vaporize/library/CFGNode.java b/vaporize/library/CFGNode.java
index b79ee6b..9d627a0 100644
--- a/vaporize/library/CFGNode.java
+++ b/vaporize/library/CFGNode.java
@@ -4,18 +4,22 @@ import misc.*;
import cs132.vapor.ast.*;
import java.util.ArrayList;
+import java.util.HashSet;
class CFGNode {
private Node instruction;
private ArrayList<CFGNode> sources;
private ArrayList<CFGNode> dests;
+ private HashSet<String> reaching;
+ private ArrayList<String> liveness;
private int line;
protected CFGNode(Node instruction) {
this.instruction = instruction;
this.sources = new ArrayList<>();
this.dests = new ArrayList<>();
+ this.reaching = new HashSet<>();
this.line = this.instruction.sourcePos.line;
}
@@ -23,10 +27,6 @@ class CFGNode {
return this.instruction.toString();
}
- public int hashCode() {
- return this.line;
- }
-
/**
* For if we only have a line
* number. (VBranch issues)
@@ -52,6 +52,13 @@ class CFGNode {
this.dests.add(node);
}
+ protected void addReaching(String add) {
+ MinimalLogger.info(String.format("Def %s at %s",
+ add,
+ this.line));
+ this.reaching.add(add);
+ }
+
protected Node getInstruction() {
return this.instruction;
}
@@ -64,4 +71,13 @@ class CFGNode {
return this.dests;
}
+ protected HashSet<String> getReaching() {
+ return this.reaching;
+ }
+
+ protected int getLine() {
+ return this.line;
+ }
+
+
}