Visitador: implemented doStmts

This commit is contained in:
Carlos Galindo 2019-03-27 00:41:26 +01:00
parent dc51f39176
commit af1e41c592
Signed by untrusted user who does not match committer: kauron
GPG key ID: 83E68706DEE119A3

View file

@ -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<CFG> {
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