diff --git a/src/main/java/grafos/CFG.java b/src/main/java/grafos/CFG.java index f3d1a5a..add3188 100644 --- a/src/main/java/grafos/CFG.java +++ b/src/main/java/grafos/CFG.java @@ -29,7 +29,7 @@ public class CFG { } public void beginBlock(Node node, Node condition, boolean addNow) { - Block b = new Block(node, condition, this); + Block b = new Block(node, condition); if (condition != null && addNow) addNode(condition); if (blockStack.isEmpty()) @@ -48,7 +48,7 @@ public class CFG { } public void connect(Node begin, Node end) { - edges.add(new Edge(this, begin, end, nextLabel)); + edges.add(new Edge(begin, end, nextLabel)); nextLabel = null; } @@ -101,17 +101,15 @@ public class CFG { + s.toString().replace("\"", "\\\"") + "\""; } - static class Block extends LinkedList { - private static int clusterId = 0; + private static int clusterId = 0; + class Block extends LinkedList { private final Node container, condition; - private final CFG cfg; private final List inners = new LinkedList<>(); - Block(Node container, Node condition, CFG cfg) { + Block(Node container, Node condition) { this.container = container; this.condition = condition; - this.cfg = cfg; } void addSubBlock(Block block) { @@ -123,14 +121,14 @@ public class CFG { res.add(gv.start_subgraph(clusterId++)); res.add("label = \"" + getTitle() + "\""); if (condition != null) { - res.add("node [ shape = rectangle ]; " + cfg.node2str(condition)); + res.add("node [ shape = rectangle ]; " + node2str(condition)); res.add("node [ shape = ellipse ]"); } for (Block b : inners) { res.addAll(b.toStringList(gv)); } for (Node n : this) { - res.add(cfg.node2str(n)); + res.add(node2str(n)); } res.add(gv.end_subgraph()); return res; @@ -173,20 +171,18 @@ public class CFG { } } - static class Edge { - private final CFG cfg; + class Edge { private final Node origin, destination; private final String label; - Edge(CFG cfg, Node origin, Node destination, String label) { - this.cfg = cfg; + Edge(Node origin, Node destination, String label) { this.origin = origin; this.destination = destination; this.label = label; } public String toString() { - String s = cfg.node2str(origin) + " -> " + cfg.node2str(destination); + String s = node2str(origin) + " -> " + node2str(destination); if (label != null) { s += " [ label = \"" + label + "\" ]"; }