From af1e41c59234f0988ee9a7f581a5adc90c5b3eb6 Mon Sep 17 00:00:00 2001 From: Carlos Galindo Date: Wed, 27 Mar 2019 00:41:26 +0100 Subject: [PATCH] Visitador: implemented doStmts --- src/main/java/grafos/Visitador.java | 11 +++++++++++ 1 file changed, 11 insertions(+) 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