Changed inner classes to be static

This commit is contained in:
Carlos Galindo 2019-04-03 18:02:26 +02:00
parent 498966d76e
commit f24b00c255
Signed by untrusted user who does not match committer: kauron
GPG Key ID: 83E68706DEE119A3
1 changed files with 10 additions and 14 deletions

View File

@ -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<Node> {
private static int clusterId = 0;
private static int clusterId = 0;
class Block extends LinkedList<Node> {
private final Node container, condition;
private final CFG cfg;
private final List<Block> 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 + "\" ]";
}