Changed inner classes to be static
This commit is contained in:
parent
498966d76e
commit
f24b00c255
1 changed files with 10 additions and 14 deletions
|
@ -29,7 +29,7 @@ public class CFG {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void beginBlock(Node node, Node condition, boolean addNow) {
|
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)
|
if (condition != null && addNow)
|
||||||
addNode(condition);
|
addNode(condition);
|
||||||
if (blockStack.isEmpty())
|
if (blockStack.isEmpty())
|
||||||
|
@ -48,7 +48,7 @@ public class CFG {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void connect(Node begin, Node end) {
|
public void connect(Node begin, Node end) {
|
||||||
edges.add(new Edge(this, begin, end, nextLabel));
|
edges.add(new Edge(begin, end, nextLabel));
|
||||||
nextLabel = null;
|
nextLabel = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,17 +101,15 @@ public class CFG {
|
||||||
+ s.toString().replace("\"", "\\\"") + "\"";
|
+ s.toString().replace("\"", "\\\"") + "\"";
|
||||||
}
|
}
|
||||||
|
|
||||||
static class Block extends LinkedList<Node> {
|
private static int clusterId = 0;
|
||||||
private static int clusterId = 0;
|
|
||||||
|
|
||||||
|
class Block extends LinkedList<Node> {
|
||||||
private final Node container, condition;
|
private final Node container, condition;
|
||||||
private final CFG cfg;
|
|
||||||
private final List<Block> inners = new LinkedList<>();
|
private final List<Block> inners = new LinkedList<>();
|
||||||
|
|
||||||
Block(Node container, Node condition, CFG cfg) {
|
Block(Node container, Node condition) {
|
||||||
this.container = container;
|
this.container = container;
|
||||||
this.condition = condition;
|
this.condition = condition;
|
||||||
this.cfg = cfg;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void addSubBlock(Block block) {
|
void addSubBlock(Block block) {
|
||||||
|
@ -123,14 +121,14 @@ public class CFG {
|
||||||
res.add(gv.start_subgraph(clusterId++));
|
res.add(gv.start_subgraph(clusterId++));
|
||||||
res.add("label = \"" + getTitle() + "\"");
|
res.add("label = \"" + getTitle() + "\"");
|
||||||
if (condition != null) {
|
if (condition != null) {
|
||||||
res.add("node [ shape = rectangle ]; " + cfg.node2str(condition));
|
res.add("node [ shape = rectangle ]; " + node2str(condition));
|
||||||
res.add("node [ shape = ellipse ]");
|
res.add("node [ shape = ellipse ]");
|
||||||
}
|
}
|
||||||
for (Block b : inners) {
|
for (Block b : inners) {
|
||||||
res.addAll(b.toStringList(gv));
|
res.addAll(b.toStringList(gv));
|
||||||
}
|
}
|
||||||
for (Node n : this) {
|
for (Node n : this) {
|
||||||
res.add(cfg.node2str(n));
|
res.add(node2str(n));
|
||||||
}
|
}
|
||||||
res.add(gv.end_subgraph());
|
res.add(gv.end_subgraph());
|
||||||
return res;
|
return res;
|
||||||
|
@ -173,20 +171,18 @@ public class CFG {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class Edge {
|
class Edge {
|
||||||
private final CFG cfg;
|
|
||||||
private final Node origin, destination;
|
private final Node origin, destination;
|
||||||
private final String label;
|
private final String label;
|
||||||
|
|
||||||
Edge(CFG cfg, Node origin, Node destination, String label) {
|
Edge(Node origin, Node destination, String label) {
|
||||||
this.cfg = cfg;
|
|
||||||
this.origin = origin;
|
this.origin = origin;
|
||||||
this.destination = destination;
|
this.destination = destination;
|
||||||
this.label = label;
|
this.label = label;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
String s = cfg.node2str(origin) + " -> " + cfg.node2str(destination);
|
String s = node2str(origin) + " -> " + node2str(destination);
|
||||||
if (label != null) {
|
if (label != null) {
|
||||||
s += " [ label = \"" + label + "\" ]";
|
s += " [ label = \"" + label + "\" ]";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue