Search in sources :

Example 1 with DepthFirstAdapter

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;
}
Also used : DepthFirstAdapter(soot.dava.toolkits.base.AST.analysis.DepthFirstAdapter) SETNodeLabel(soot.dava.internal.SET.SETNodeLabel) ASTNode(soot.dava.internal.AST.ASTNode) DAbruptStmt(soot.dava.internal.javaRep.DAbruptStmt) ReturnStmt(soot.jimple.ReturnStmt) DAbruptStmt(soot.dava.internal.javaRep.DAbruptStmt) Stmt(soot.jimple.Stmt) ReturnVoidStmt(soot.jimple.ReturnVoidStmt) AugmentedStmt(soot.dava.internal.asg.AugmentedStmt)

Aggregations

ASTNode (soot.dava.internal.AST.ASTNode)1 SETNodeLabel (soot.dava.internal.SET.SETNodeLabel)1 AugmentedStmt (soot.dava.internal.asg.AugmentedStmt)1 DAbruptStmt (soot.dava.internal.javaRep.DAbruptStmt)1 DepthFirstAdapter (soot.dava.toolkits.base.AST.analysis.DepthFirstAdapter)1 ReturnStmt (soot.jimple.ReturnStmt)1 ReturnVoidStmt (soot.jimple.ReturnVoidStmt)1 Stmt (soot.jimple.Stmt)1