diff --git a/src/main/java/grafos/Visitador.java b/src/main/java/grafos/Visitador.java index 4ea6b59..d3a5578 100755 --- a/src/main/java/grafos/Visitador.java +++ b/src/main/java/grafos/Visitador.java @@ -2,6 +2,7 @@ package grafos; import com.github.javaparser.ast.Node; import com.github.javaparser.ast.body.MethodDeclaration; +import com.github.javaparser.ast.stmt.DoStmt; import com.github.javaparser.ast.stmt.ExpressionStmt; import com.github.javaparser.ast.stmt.IfStmt; import com.github.javaparser.ast.stmt.WhileStmt; @@ -79,6 +80,16 @@ public class Visitador extends VoidVisitorAdapter { prevNode = Collections.singletonList(whileStart); } + @Override + public void visit(DoStmt n, CFG graph) { + prevNode = new LinkedList<>(prevNode); + prevNode.add(n.getCondition()); + n.getBody().accept(this, graph); + graph.addNode(n.getCondition()); + graph.connect(prevNode, n.getCondition()); + prevNode = Collections.singletonList(n.getCondition()); + } + // Visitador de expresiones // Cada expresión encontrada genera un nodo en el CFG @Override