use of soot.dava.toolkits.base.AST.analysis.DepthFirstAdapter in project soot by Sable.
the class IfElseSplitter method bodyTargetsLabel.
/*
* Check that label is non null and the string inside is non null... if yes return false
* Check that the given list (sequeneof ASTNodes have no abrupt edge targeting the label.
*
*/
public boolean bodyTargetsLabel(SETNodeLabel label, List<Object> body) {
// no SETNodeLabel is good
if (label == null)
return false;
// SETNodeLabel but with no string is also good
if (label.toString() == null)
return false;
final String strLabel = label.toString();
// go through the body use traversal to find whether there is an abrupt stmt targeting this
Iterator<Object> it = body.iterator();
targeted = false;
while (it.hasNext()) {
ASTNode temp = (ASTNode) it.next();
temp.apply(new DepthFirstAdapter() {
// set targeted to true if DAbruptStmt targets it
public void inStmt(Stmt s) {
// only interested in abrupt stmts
if (!(s instanceof DAbruptStmt))
return;
DAbruptStmt abrupt = (DAbruptStmt) s;
SETNodeLabel label = abrupt.getLabel();
if (label != null && label.toString() != null && label.toString().equals(strLabel)) {
targeted = true;
}
}
});
if (targeted)
break;
}
return targeted;
}
Aggregations