diff options
Diffstat (limited to 'vaporize/library/CFGSimp.java')
| -rw-r--r-- | vaporize/library/CFGSimp.java | 20 | 
1 files changed, 12 insertions, 8 deletions
diff --git a/vaporize/library/CFGSimp.java b/vaporize/library/CFGSimp.java index 0cefb5a..c261f7c 100644 --- a/vaporize/library/CFGSimp.java +++ b/vaporize/library/CFGSimp.java @@ -9,7 +9,7 @@ import java.util.*;  public class CFGSimp extends VInstr.VisitorPR<ControlFlowGraph, String, RuntimeException> { -    private boolean use_graphviz = true;                // if true, generates svg files of the edges in each function +    private boolean use_graphviz = true;        // if true, generates svg files of the edges in each function      private VaporProgram vp;      private Kettle kettle; @@ -27,7 +27,8 @@ public class CFGSimp extends VInstr.VisitorPR<ControlFlowGraph, String, RuntimeE          for (VFunction f : this.vp.functions) {              ControlFlowGraph cfg = new ControlFlowGraph();              this.dot_format = ""; -            curr = new CFGNode(f.body[0]); +            // first visit may not find edges; cfg.addEdges will handle +            this.curr = new CFGNode(f.body[0]);              cfg.setStart(curr);              MinimalLogger.info(String.format("CFGSimp is collecting nodes for %s", @@ -138,8 +139,8 @@ public class CFGSimp extends VInstr.VisitorPR<ControlFlowGraph, String, RuntimeE          ///////////////////////////////////////////////////////////////          CFGNode curr = cfg.getNode(n);          this.dot_format += cfg.addEdge(this.curr, curr); -        this.dot_format += cfg.addEdge(this.curr, cfg.getNode(new Integer(this.kettle -                                                                          .findLabelIndex(n.target.toString())))); +        this.dot_format += cfg.addEdge(curr, cfg.getNode(new Integer(this.kettle +                                                                     .findLabelIndex(n.target.toString()))));          this.curr = curr;          /////////////////////////////////////////////////////////////// @@ -156,11 +157,14 @@ public class CFGSimp extends VInstr.VisitorPR<ControlFlowGraph, String, RuntimeE                                           this.kettle.get(n).trim(),                                           n.sourcePos.toString()));          /////////////////////////////////////////////////////////////// -        CFGNode curr = cfg.getNode(new Integer(this.kettle -                                               .findLabelIndex(n.target.toString()))); -        this.dot_format += cfg.addEdge(this.curr, curr); +        CFGNode curr = cfg.getNode(n); +        this.dot_format += cfg.addEdge(curr, +                                       cfg.getNode(new Integer(this.kettle +                                                               .findLabelIndex(n.target.toString())))); -        this.curr = curr; +        MinimalLogger.info(String.format("curr is now %s", +                                         this.kettle.get(n).trim())); +        this.curr = cfg.getNextNode(curr);          ///////////////////////////////////////////////////////////////          MinimalLogger.info(String.format("<-%s (\"%s\":%s)",                                           n.getClass().getSimpleName(),  | 
