Visitador: added treatment of whileStmts
This commit is contained in:
parent
8b62733a44
commit
59a768855d
1 changed files with 15 additions and 0 deletions
|
@ -4,6 +4,7 @@ import com.github.javaparser.ast.Node;
|
||||||
import com.github.javaparser.ast.body.MethodDeclaration;
|
import com.github.javaparser.ast.body.MethodDeclaration;
|
||||||
import com.github.javaparser.ast.stmt.ExpressionStmt;
|
import com.github.javaparser.ast.stmt.ExpressionStmt;
|
||||||
import com.github.javaparser.ast.stmt.IfStmt;
|
import com.github.javaparser.ast.stmt.IfStmt;
|
||||||
|
import com.github.javaparser.ast.stmt.WhileStmt;
|
||||||
import com.github.javaparser.ast.visitor.VoidVisitorAdapter;
|
import com.github.javaparser.ast.visitor.VoidVisitorAdapter;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -64,6 +65,20 @@ public class Visitador extends VoidVisitorAdapter<CFG> {
|
||||||
prevNode = newPrev;
|
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
|
// Visitador de expresiones
|
||||||
// Cada expresión encontrada genera un nodo en el CFG
|
// Cada expresión encontrada genera un nodo en el CFG
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue