summaryrefslogtreecommitdiff
path: root/vaporize/library/CFGSimp.java
diff options
context:
space:
mode:
Diffstat (limited to 'vaporize/library/CFGSimp.java')
-rw-r--r--vaporize/library/CFGSimp.java28
1 files changed, 16 insertions, 12 deletions
diff --git a/vaporize/library/CFGSimp.java b/vaporize/library/CFGSimp.java
index f4d63cf..0cefb5a 100644
--- a/vaporize/library/CFGSimp.java
+++ b/vaporize/library/CFGSimp.java
@@ -9,6 +9,8 @@ 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 VaporProgram vp;
private Kettle kettle;
private ArrayList<ControlFlowGraph> cfgs;
@@ -44,13 +46,13 @@ public class CFGSimp extends VInstr.VisitorPR<ControlFlowGraph, String, RuntimeE
}
- // edges
MinimalLogger.info(String.format("CFGSimp is collecting edges for %s",
this.kettle.parseFuncName(f)));
for (VInstr s : f.body)
s.accept(cfg, this);
- this.createDotGraph(this.kettle.parseFuncName(f));
+ if (this.use_graphviz)
+ this.createDotGraph(this.kettle.parseFuncName(f));
this.cfgs.add(cfg);
}
@@ -71,6 +73,8 @@ public class CFGSimp extends VInstr.VisitorPR<ControlFlowGraph, String, RuntimeE
String type = "svg";
gv.decreaseDpi();
gv.decreaseDpi();
+ gv.decreaseDpi();
+ gv.decreaseDpi();
File out = new File(file_name+"."+ type);
gv.writeGraphToFile( gv.getGraph( gv.getDotSource(), type ), out );
}
@@ -82,7 +86,7 @@ public class CFGSimp extends VInstr.VisitorPR<ControlFlowGraph, String, RuntimeE
n.sourcePos.toString()));
///////////////////////////////////////////////////////////////
CFGNode curr = cfg.getNode(n);
- this.dot_format += cfg.addEdge(this.curr, cfg.getNode(n));
+ this.dot_format += cfg.addEdge(this.curr, curr);
this.curr = curr;
///////////////////////////////////////////////////////////////
MinimalLogger.info(String.format("<-%s (\"%s\":%s)",
@@ -99,7 +103,7 @@ public class CFGSimp extends VInstr.VisitorPR<ControlFlowGraph, String, RuntimeE
n.sourcePos.toString()));
///////////////////////////////////////////////////////////////
CFGNode curr = cfg.getNode(n);
- this.dot_format += cfg.addEdge(this.curr, cfg.getNode(n));
+ this.dot_format += cfg.addEdge(this.curr, curr);
this.curr = curr;
///////////////////////////////////////////////////////////////
MinimalLogger.info(String.format("<-%s (\"%s\":%s)",
@@ -116,7 +120,7 @@ public class CFGSimp extends VInstr.VisitorPR<ControlFlowGraph, String, RuntimeE
n.sourcePos.toString()));
///////////////////////////////////////////////////////////////
CFGNode curr = cfg.getNode(n);
- this.dot_format += cfg.addEdge(this.curr, cfg.getNode(n));
+ this.dot_format += cfg.addEdge(this.curr, curr);
this.curr = curr;
///////////////////////////////////////////////////////////////
MinimalLogger.info(String.format("<-%s (\"%s\":%s)",
@@ -133,7 +137,7 @@ public class CFGSimp extends VInstr.VisitorPR<ControlFlowGraph, String, RuntimeE
n.sourcePos.toString()));
///////////////////////////////////////////////////////////////
CFGNode curr = cfg.getNode(n);
- this.dot_format += cfg.addEdge(this.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()))));
@@ -152,9 +156,9 @@ public class CFGSimp extends VInstr.VisitorPR<ControlFlowGraph, String, RuntimeE
this.kettle.get(n).trim(),
n.sourcePos.toString()));
///////////////////////////////////////////////////////////////
- CFGNode curr = cfg.getNode(n);
- this.dot_format += cfg.addEdge(this.curr, cfg.getNode(new Integer(this.kettle
- .findLabelIndex(n.target.toString()))));
+ CFGNode curr = cfg.getNode(new Integer(this.kettle
+ .findLabelIndex(n.target.toString())));
+ this.dot_format += cfg.addEdge(this.curr, curr);
this.curr = curr;
///////////////////////////////////////////////////////////////
@@ -172,7 +176,7 @@ public class CFGSimp extends VInstr.VisitorPR<ControlFlowGraph, String, RuntimeE
n.sourcePos.toString()));
///////////////////////////////////////////////////////////////
CFGNode curr = cfg.getNode(n);
- this.dot_format += cfg.addEdge(this.curr, cfg.getNode(n));
+ this.dot_format += cfg.addEdge(this.curr, curr);
this.curr = curr;
///////////////////////////////////////////////////////////////
MinimalLogger.info(String.format("<-%s (\"%s\":%s)",
@@ -189,7 +193,7 @@ public class CFGSimp extends VInstr.VisitorPR<ControlFlowGraph, String, RuntimeE
n.sourcePos.toString()));
///////////////////////////////////////////////////////////////
CFGNode curr = cfg.getNode(n);
- this.dot_format += cfg.addEdge(this.curr, cfg.getNode(n));
+ this.dot_format += cfg.addEdge(this.curr, curr);
this.curr = curr;
///////////////////////////////////////////////////////////////
MinimalLogger.info(String.format("<-%s (\"%s\":%s)",
@@ -206,7 +210,7 @@ public class CFGSimp extends VInstr.VisitorPR<ControlFlowGraph, String, RuntimeE
n.sourcePos.toString()));
///////////////////////////////////////////////////////////////
CFGNode curr = cfg.getNode(n);
- this.dot_format += cfg.addEdge(this.curr, cfg.getNode(n));
+ this.dot_format += cfg.addEdge(this.curr, curr);
this.curr = curr;
///////////////////////////////////////////////////////////////
MinimalLogger.info(String.format("<-%s (\"%s\":%s)",