diff --git a/src/main/java/grafos/Visitador.java b/src/main/java/grafos/Visitador.java index 11dea37..4ea6b59 100755 --- a/src/main/java/grafos/Visitador.java +++ b/src/main/java/grafos/Visitador.java @@ -4,6 +4,7 @@ import com.github.javaparser.ast.Node; import com.github.javaparser.ast.body.MethodDeclaration; import com.github.javaparser.ast.stmt.ExpressionStmt; import com.github.javaparser.ast.stmt.IfStmt; +import com.github.javaparser.ast.stmt.WhileStmt; import com.github.javaparser.ast.visitor.VoidVisitorAdapter; import java.util.Collections; @@ -64,6 +65,20 @@ public class Visitador extends VoidVisitorAdapter { prevNode = newPrev; } + @Override + public void visit(WhileStmt n, CFG graph) { + Node whileStart = n.getCondition(); + graph.addNode(whileStart); + graph.connect(prevNode, whileStart); + + // TODO: shortcut conditions (||, &&) + + prevNode = Collections.singletonList(whileStart); + n.getBody().accept(this, graph); + graph.connect(prevNode, whileStart); + prevNode = Collections.singletonList(whileStart); + } + // Visitador de expresiones // Cada expresión encontrada genera un nodo en el CFG @Override