summaryrefslogtreecommitdiff
path: root/vaporize/library/CFGNode.java
diff options
context:
space:
mode:
authorbd-912 <bdunahu@colostate.edu>2024-04-17 21:42:42 -0600
committerbd-912 <bdunahu@colostate.edu>2024-04-17 21:42:42 -0600
commit6377548c75f05f0b8599dcfb8d61a56240692334 (patch)
treed763324a175106909188f08b3ccfb7953964afc7 /vaporize/library/CFGNode.java
parentf121f24a80d49e9bacb890d729f0ae64047ed6d8 (diff)
Add all of the tests I forgot to add
Diffstat (limited to 'vaporize/library/CFGNode.java')
-rw-r--r--vaporize/library/CFGNode.java48
1 files changed, 48 insertions, 0 deletions
diff --git a/vaporize/library/CFGNode.java b/vaporize/library/CFGNode.java
new file mode 100644
index 0000000..ca60856
--- /dev/null
+++ b/vaporize/library/CFGNode.java
@@ -0,0 +1,48 @@
+package vaporize.library;
+
+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;
+ }
+
+ 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;
+ }
+
+}