Modified blocks so that the condition is squared and labeled
This commit is contained in:
parent
d7abcb7b55
commit
498966d76e
2 changed files with 30 additions and 16 deletions
|
@ -24,8 +24,14 @@ public class CFG {
|
|||
System.out.println("NODO: " + node2str(stmt));
|
||||
}
|
||||
|
||||
public void beginBlock(Node node) {
|
||||
Block b = new Block(node, this);
|
||||
public void beginBlock(Node node, Node condition) {
|
||||
beginBlock(node, condition, true);
|
||||
}
|
||||
|
||||
public void beginBlock(Node node, Node condition, boolean addNow) {
|
||||
Block b = new Block(node, condition, this);
|
||||
if (condition != null && addNow)
|
||||
addNode(condition);
|
||||
if (blockStack.isEmpty())
|
||||
blocks.addFirst(b);
|
||||
else
|
||||
|
@ -98,12 +104,13 @@ public class CFG {
|
|||
static class Block extends LinkedList<Node> {
|
||||
private static int clusterId = 0;
|
||||
|
||||
private final Node container;
|
||||
private final Node container, condition;
|
||||
private final CFG cfg;
|
||||
private final List<Block> inners = new LinkedList<>();
|
||||
|
||||
Block(Node container, CFG cfg) {
|
||||
Block(Node container, Node condition, CFG cfg) {
|
||||
this.container = container;
|
||||
this.condition = condition;
|
||||
this.cfg = cfg;
|
||||
}
|
||||
|
||||
|
@ -115,6 +122,10 @@ public class CFG {
|
|||
List<String> res = new LinkedList<>();
|
||||
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 = ellipse ]");
|
||||
}
|
||||
for (Block b : inners) {
|
||||
res.addAll(b.toStringList(gv));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue