diff options
Diffstat (limited to 'vaporize/library/ControlFlowGraph.java')
-rw-r--r-- | vaporize/library/ControlFlowGraph.java | 69 |
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); } } |