Fixed labels positioning, added flexibility

This commit is contained in:
Carlos Galindo 2019-04-04 00:13:52 +02:00
parent e77fe8f772
commit 5ea988992a
Signed by untrusted user who does not match committer: kauron
GPG Key ID: 83E68706DEE119A3
1 changed files with 5 additions and 6 deletions

View File

@ -12,9 +12,8 @@ public class CFG {
private final Stack<Block> blockStack = new Stack<>();
private final List<Edge> edges = new LinkedList<>();
private final Node beginNode = new EmptyStmt(), endNode = new EmptyStmt();
private final List<Node> nodeList = new LinkedList<>();
private String nextLabel;
private final LinkedList<Node> nodeList = new LinkedList<>();
private final Map<Node, String> labelMap = new HashMap<>();
private void registerNode(Node stmt) {
nodes.add(stmt);
@ -100,12 +99,12 @@ public class CFG {
}
public void setNextLabel(boolean b) {
nextLabel = String.valueOf(b);
labelMap.put(nodeList.getLast(), String.valueOf(b));
}
private void connect(Node begin, Node end) {
edges.add(new Edge(begin, end, nextLabel));
nextLabel = null;
edges.add(new Edge(begin, end, labelMap.get(begin)));
labelMap.remove(begin);
}
public Node getEndNode() {