Loading src/main/java/tfm/graphs/Graph.java +1 −2 Original line number Diff line number Diff line Loading @@ -87,8 +87,7 @@ public abstract class Graph extends DefaultDirectedGraph<GraphNode<?>, Arc> { @Override public String toString() { return vertexSet().stream() .sorted(Comparator.comparingInt(GraphNode::getId)) return vertexSet().stream().sorted() .map(GraphNode::toString) .collect(Collectors.joining(System.lineSeparator())); } Loading src/main/java/tfm/graphs/augmented/ACFG.java +5 −0 Original line number Diff line number Diff line Loading @@ -10,6 +10,11 @@ public class ACFG extends CFG { addControlFlowEdge(from, to, new ControlFlowArc.NonExecutable()); } @Override protected void setExitNode(GraphNode<?> exitNode) { super.setExitNode(exitNode); } @Override protected CFGBuilder newCFGBuilder() { return new ACFGBuilder(this); Loading src/main/java/tfm/graphs/augmented/ACFGBuilder.java +2 −1 Original line number Diff line number Diff line Loading @@ -243,6 +243,7 @@ public class ACFGBuilder extends CFGBuilder { methodDeclaration.getBody().get().accept(this, arg); returnList.stream().filter(node -> !hangingNodes.contains(node)).forEach(hangingNodes::add); nonExecHangingNodes.add(graph.getRootNode().get()); connectTo(new EmptyStmt(), "Exit"); GraphNode<EmptyStmt> exitNode = connectTo(new EmptyStmt(), "Exit"); ((ACFG) graph).setExitNode(exitNode); } } src/main/java/tfm/graphs/cfg/CFG.java +20 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import java.util.Set; */ public class CFG extends GraphWithRootNode<MethodDeclaration> { private boolean built = false; protected GraphNode<?> exitNode; public CFG() { super(); Loading Loading @@ -62,9 +63,28 @@ public class CFG extends GraphWithRootNode<MethodDeclaration> { return res; } @Override public boolean removeVertex(GraphNode<?> graphNode) { if (Objects.equals(graphNode, exitNode)) return false; return super.removeVertex(graphNode); } public GraphNode<?> getExitNode() { return exitNode; } protected void setExitNode(GraphNode<?> exitNode) { if (this.exitNode != null) throw new IllegalStateException("Exit node already set!"); this.exitNode = exitNode; } @Override public void build(MethodDeclaration method) { method.accept(newCFGBuilder(), null); if (exitNode == null) throw new IllegalStateException("Exit node missing!"); built = true; } Loading src/main/java/tfm/graphs/cfg/CFGBuilder.java +2 −1 Original line number Diff line number Diff line Loading @@ -275,6 +275,7 @@ public class CFGBuilder extends VoidVisitorAdapter<Void> { hangingNodes.add(graph.getRootNode().get()); methodDeclaration.getBody().get().accept(this, arg); returnList.stream().filter(node -> !hangingNodes.contains(node)).forEach(hangingNodes::add); connectTo(new EmptyStmt(), "Exit"); GraphNode<EmptyStmt> exitNode = connectTo(new EmptyStmt(), "Exit"); graph.setExitNode(exitNode); } } Loading
src/main/java/tfm/graphs/Graph.java +1 −2 Original line number Diff line number Diff line Loading @@ -87,8 +87,7 @@ public abstract class Graph extends DefaultDirectedGraph<GraphNode<?>, Arc> { @Override public String toString() { return vertexSet().stream() .sorted(Comparator.comparingInt(GraphNode::getId)) return vertexSet().stream().sorted() .map(GraphNode::toString) .collect(Collectors.joining(System.lineSeparator())); } Loading
src/main/java/tfm/graphs/augmented/ACFG.java +5 −0 Original line number Diff line number Diff line Loading @@ -10,6 +10,11 @@ public class ACFG extends CFG { addControlFlowEdge(from, to, new ControlFlowArc.NonExecutable()); } @Override protected void setExitNode(GraphNode<?> exitNode) { super.setExitNode(exitNode); } @Override protected CFGBuilder newCFGBuilder() { return new ACFGBuilder(this); Loading
src/main/java/tfm/graphs/augmented/ACFGBuilder.java +2 −1 Original line number Diff line number Diff line Loading @@ -243,6 +243,7 @@ public class ACFGBuilder extends CFGBuilder { methodDeclaration.getBody().get().accept(this, arg); returnList.stream().filter(node -> !hangingNodes.contains(node)).forEach(hangingNodes::add); nonExecHangingNodes.add(graph.getRootNode().get()); connectTo(new EmptyStmt(), "Exit"); GraphNode<EmptyStmt> exitNode = connectTo(new EmptyStmt(), "Exit"); ((ACFG) graph).setExitNode(exitNode); } }
src/main/java/tfm/graphs/cfg/CFG.java +20 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import java.util.Set; */ public class CFG extends GraphWithRootNode<MethodDeclaration> { private boolean built = false; protected GraphNode<?> exitNode; public CFG() { super(); Loading Loading @@ -62,9 +63,28 @@ public class CFG extends GraphWithRootNode<MethodDeclaration> { return res; } @Override public boolean removeVertex(GraphNode<?> graphNode) { if (Objects.equals(graphNode, exitNode)) return false; return super.removeVertex(graphNode); } public GraphNode<?> getExitNode() { return exitNode; } protected void setExitNode(GraphNode<?> exitNode) { if (this.exitNode != null) throw new IllegalStateException("Exit node already set!"); this.exitNode = exitNode; } @Override public void build(MethodDeclaration method) { method.accept(newCFGBuilder(), null); if (exitNode == null) throw new IllegalStateException("Exit node missing!"); built = true; } Loading
src/main/java/tfm/graphs/cfg/CFGBuilder.java +2 −1 Original line number Diff line number Diff line Loading @@ -275,6 +275,7 @@ public class CFGBuilder extends VoidVisitorAdapter<Void> { hangingNodes.add(graph.getRootNode().get()); methodDeclaration.getBody().get().accept(this, arg); returnList.stream().filter(node -> !hangingNodes.contains(node)).forEach(hangingNodes::add); connectTo(new EmptyStmt(), "Exit"); GraphNode<EmptyStmt> exitNode = connectTo(new EmptyStmt(), "Exit"); graph.setExitNode(exitNode); } }