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

View file

@ -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() {