summaryrefslogtreecommitdiff
path: root/vaporize/library/ControlFlowGraph.java
diff options
context:
space:
mode:
authorbd-912 <bdunahu@colostate.edu>2024-04-17 01:33:05 -0600
committerbd-912 <bdunahu@colostate.edu>2024-04-17 01:33:05 -0600
commit62178e370f21ddf80766b8e1075c55e0d3945493 (patch)
tree13fcfc0d7177e578020366e905b71ca48e0857f0 /vaporize/library/ControlFlowGraph.java
parentf08708ee07931db592ffb76c073bd80bcf6cf060 (diff)
CFG Skeleton Files
Diffstat (limited to 'vaporize/library/ControlFlowGraph.java')
-rw-r--r--vaporize/library/ControlFlowGraph.java69
1 files changed, 14 insertions, 55 deletions
diff --git a/vaporize/library/ControlFlowGraph.java b/vaporize/library/ControlFlowGraph.java
index 787ef8f..f181d36 100644
--- a/vaporize/library/ControlFlowGraph.java
+++ b/vaporize/library/ControlFlowGraph.java
@@ -1,68 +1,27 @@
package vaporize.library;
import cs132.vapor.ast.*;
-import st.*;
-import misc.*;
-import java.util.*;
+import java.util.ArrayList;
-public class ControlFlowGraph<P, R> extends VInstr.VisitorPR<P, R, RuntimeException> {
+public class ControlFlowGraph {
+ private ArrayList<Node> nodes;
+ private Node start;
+ private Node end;
- public R visit(P p, VMemRead n) throws RuntimeException {
- PrintFilter.print(String.format("%s (%s)",
- n.getClass().getSimpleName(),
- n.sourcePos.toString()), true);
- return null;
+ public ControlFlowGraph() {
+ this.nodes = new ArrayList<>();
+ this.start = null;
+ this.end = null;
}
- public R visit(P p, VMemWrite n) throws RuntimeException {
- PrintFilter.print(String.format("%s (%s)",
- n.getClass().getSimpleName(),
- n.sourcePos.toString()), true);
- return null;
+ protected void addNode(Node node) {
+ this.nodes.add(node);
}
- public R visit(P p, VAssign n) throws RuntimeException {
- PrintFilter.print(String.format("%s (%s)",
- n.getClass().getSimpleName(),
- n.sourcePos.toString()), true);
- return null;
- }
-
- public R visit(P p, VBranch n) throws RuntimeException {
- PrintFilter.print(String.format("%s (%s)",
- n.getClass().getSimpleName(),
- n.sourcePos.toString()), true);
- return null;
- }
-
- public R visit(P p, VGoto n) throws RuntimeException {
- PrintFilter.print(String.format("%s (%s)",
- n.getClass().getSimpleName(),
- n.sourcePos.toString()), true);
- return null;
- }
-
- public R visit(P p, VCall n) throws RuntimeException {
- PrintFilter.print(String.format("%s (%s)",
- n.getClass().getSimpleName(),
- n.sourcePos.toString()), true);
- return null;
- }
-
- public R visit(P p, VBuiltIn n) throws RuntimeException {
- PrintFilter.print(String.format("%s (%s:%s)",
- n.getClass().getSimpleName(),
- n.op.name,
- n.sourcePos.toString()), true);
- return null;
- }
-
- public R visit(P p, VReturn n) throws RuntimeException {
- PrintFilter.print(String.format("%s (%s)",
- n.getClass().getSimpleName(),
- n.sourcePos.toString()), true);
- return null;
+ protected void addEdge(Node source, Node dest) {
+ source.addDest(dest);
+ dest.addSource(source);
}
}