diff options
Diffstat (limited to 'vaporize/library/CFGSimp.java')
-rw-r--r-- | vaporize/library/CFGSimp.java | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/vaporize/library/CFGSimp.java b/vaporize/library/CFGSimp.java index 372f926..6ab276a 100644 --- a/vaporize/library/CFGSimp.java +++ b/vaporize/library/CFGSimp.java @@ -7,10 +7,26 @@ import java.util.*; public class CFGSimp<P, R> extends VInstr.VisitorPR<P, R, RuntimeException> { - ControlFlowGraph cfg; + private ControlFlowGraph cfg; - public CFGSimp(ControlFlowGraph cfg) { - this.cfg = cfg; + public CFGSimp(VFunction n) { + this.cfg = new ControlFlowGraph(); + CFGNode start = new CFGNode(n.body[0]); + this.cfg.setStart(start); + + // nodes + for (VInstr s : n.body) + this.cfg.addNode(new CFGNode(s)); + + // edges + for (VInstr s : n.body) + s.accept("", this); + + System.out.println(this.cfg.getNodes().toString()); + } + + public ControlFlowGraph getCFG() { + return this.cfg; } public R visit(P p, VMemRead n) throws RuntimeException { @@ -26,6 +42,7 @@ public class CFGSimp<P, R> extends VInstr.VisitorPR<P, R, RuntimeException> { } public R visit(P p, VBranch n) throws RuntimeException { + // two edges return null; } |