summaryrefslogtreecommitdiff
path: root/vaporize/library/ControlFlowGraph.java
diff options
context:
space:
mode:
authorbd-912 <bdunahu@colostate.edu>2024-04-20 01:03:23 -0600
committerbd-912 <bdunahu@colostate.edu>2024-04-20 01:03:23 -0600
commitb7705e83c2026ff3983fc0b83f9b083d3e8be4c5 (patch)
tree9795143d8c2c9cb9fa7bac25a339533eb704cc32 /vaporize/library/ControlFlowGraph.java
parent63551aff281f1d289605fe2c9975a15124dbe643 (diff)
CFG fix create edges only if nodes != (found by graphviz)
Diffstat (limited to 'vaporize/library/ControlFlowGraph.java')
-rw-r--r--vaporize/library/ControlFlowGraph.java24
1 files changed, 16 insertions, 8 deletions
diff --git a/vaporize/library/ControlFlowGraph.java b/vaporize/library/ControlFlowGraph.java
index 364cec1..b4c995c 100644
--- a/vaporize/library/ControlFlowGraph.java
+++ b/vaporize/library/ControlFlowGraph.java
@@ -38,16 +38,24 @@ public class ControlFlowGraph {
}
protected String addEdge(CFGNode source, CFGNode dest) {
- String ret = String.format("%d -> %d",
- source.getInstruction().sourcePos.line,
- dest.getInstruction().sourcePos.line);
- MinimalLogger.info(String.format("Edge %s",
- ret));
+ /**
+ * Iff the CFGNodes are different, construct an edge between them.
+ * Returns a string capable of being manipulated by graphviz.
+ */
+ String ret = "";
+ if (!source.equals(dest)) {
+ ret = String.format("%d -> %d",
+ source.getInstruction().sourcePos.line,
+ dest.getInstruction().sourcePos.line);
+ MinimalLogger.info(String.format("Edge %s",
+ ret));
- source.addDest(dest);
- dest.addSource(source);
+ source.addDest(dest);
+ dest.addSource(source);
+ ret += ";";
+ }
- return ret +";";
+ return ret;
}
protected void setStart(CFGNode start) {