summaryrefslogtreecommitdiff
path: root/vaporize/library/CFGSimp.java
diff options
context:
space:
mode:
authorbd-912 <bdunahu@colostate.edu>2024-04-20 01:46:24 -0600
committerbd-912 <bdunahu@colostate.edu>2024-04-20 01:46:24 -0600
commit7abe891766135b36e538b26e7d2433d3bf2a40b2 (patch)
treed718e980cee0f48ca2d24bd3720be69c49c9dc72 /vaporize/library/CFGSimp.java
parentb7705e83c2026ff3983fc0b83f9b083d3e8be4c5 (diff)
Fix many more issues with goto/branch found with GraphViz
Diffstat (limited to 'vaporize/library/CFGSimp.java')
-rw-r--r--vaporize/library/CFGSimp.java20
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(),