From 63c312589afcf55864a8a90d4ef199c84b10f6ae Mon Sep 17 00:00:00 2001 From: Carlos Galindo Date: Wed, 27 Mar 2019 11:57:18 +0100 Subject: [PATCH] CFG: improved numbering system and removed connect(int, int) --- src/main/java/grafos/CFG.java | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/main/java/grafos/CFG.java b/src/main/java/grafos/CFG.java index 3b301c3..983b9a3 100644 --- a/src/main/java/grafos/CFG.java +++ b/src/main/java/grafos/CFG.java @@ -6,7 +6,7 @@ import com.github.javaparser.ast.stmt.EmptyStmt; import java.util.*; public class CFG { - private final List nodes = new ArrayList(); + private final List nodes = new ArrayList<>(); private final List> edges = new LinkedList<>(); private Node beginNode, endNode; @@ -15,10 +15,6 @@ public class CFG { System.out.println("NODO: " + node2str(stmt)); } - public void connect(int begin, int end) { - connect(nodes.get(begin), nodes.get(end)); - } - public void connect(Node begin, Node end) { edges.add(new HashMap.SimpleEntry<>(begin, end)); } @@ -31,7 +27,6 @@ public class CFG { public Node beginNode() { if (beginNode == null) { beginNode = new EmptyStmt(); - nodes.add(beginNode); } return beginNode; } @@ -39,7 +34,6 @@ public class CFG { public Node endNode() { if (endNode == null) { endNode = new EmptyStmt(); - nodes.add(endNode); } return endNode; } @@ -70,7 +64,7 @@ public class CFG { } if (index == -1) throw new RuntimeException("Internal error, can't find node"); - return "\"(" + index + ", " + s.getRange().get().begin.line + ") " + return "\"(" + (index + 1) + ", " + s.getRange().get().begin.line + ") " + s.toString().replace("\"", "\\\"") + "\""; } }