Fixed labels positioning, added flexibility
This commit is contained in:
parent
e77fe8f772
commit
5ea988992a
1 changed files with 5 additions and 6 deletions
|
@ -12,9 +12,8 @@ public class CFG {
|
||||||
private final Stack<Block> blockStack = new Stack<>();
|
private final Stack<Block> blockStack = new Stack<>();
|
||||||
private final List<Edge> edges = new LinkedList<>();
|
private final List<Edge> edges = new LinkedList<>();
|
||||||
private final Node beginNode = new EmptyStmt(), endNode = new EmptyStmt();
|
private final Node beginNode = new EmptyStmt(), endNode = new EmptyStmt();
|
||||||
private final List<Node> nodeList = new LinkedList<>();
|
private final LinkedList<Node> nodeList = new LinkedList<>();
|
||||||
|
private final Map<Node, String> labelMap = new HashMap<>();
|
||||||
private String nextLabel;
|
|
||||||
|
|
||||||
private void registerNode(Node stmt) {
|
private void registerNode(Node stmt) {
|
||||||
nodes.add(stmt);
|
nodes.add(stmt);
|
||||||
|
@ -100,12 +99,12 @@ public class CFG {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNextLabel(boolean b) {
|
public void setNextLabel(boolean b) {
|
||||||
nextLabel = String.valueOf(b);
|
labelMap.put(nodeList.getLast(), String.valueOf(b));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void connect(Node begin, Node end) {
|
private void connect(Node begin, Node end) {
|
||||||
edges.add(new Edge(begin, end, nextLabel));
|
edges.add(new Edge(begin, end, labelMap.get(begin)));
|
||||||
nextLabel = null;
|
labelMap.remove(begin);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Node getEndNode() {
|
public Node getEndNode() {
|
||||||
|
|
Loading…
Reference in a new issue