Search in sources :

Example 1 with JIfStmt

use of soot.jimple.internal.JIfStmt in project soot by Sable.

the class NullnessAnalysis method flowThrough.

/**
 * {@inheritDoc}
 */
@Override
protected void flowThrough(AnalysisInfo in, Unit u, List<AnalysisInfo> fallOut, List<AnalysisInfo> branchOuts) {
    AnalysisInfo out = new AnalysisInfo(in);
    AnalysisInfo outBranch = new AnalysisInfo(in);
    Stmt s = (Stmt) u;
    // or for an instanceof expression
    if (s instanceof JIfStmt) {
        JIfStmt ifStmt = (JIfStmt) s;
        handleIfStmt(ifStmt, in, out, outBranch);
    } else // in case of a monitor statement, we know that if it succeeds, we have a non-null value
    if (s instanceof MonitorStmt) {
        MonitorStmt monitorStmt = (MonitorStmt) s;
        out.put(monitorStmt.getOp(), NON_NULL);
    }
    // if we have an array ref, set the base to non-null
    if (s.containsArrayRef()) {
        ArrayRef arrayRef = s.getArrayRef();
        handleArrayRef(arrayRef, out);
    }
    // for field refs, set the receiver object to non-null, if there is one
    if (s.containsFieldRef()) {
        FieldRef fieldRef = s.getFieldRef();
        handleFieldRef(fieldRef, out);
    }
    // for invoke expr, set the receiver object to non-null, if there is one
    if (s.containsInvokeExpr()) {
        InvokeExpr invokeExpr = s.getInvokeExpr();
        handleInvokeExpr(invokeExpr, out);
    }
    // x=y,                  copy the info for y (for locals x,y)
    if (s instanceof DefinitionStmt) {
        DefinitionStmt defStmt = (DefinitionStmt) s;
        if (defStmt.getLeftOp().getType() instanceof RefLikeType) {
            handleRefTypeAssignment(defStmt, out);
        }
    }
    // now copy the computed info to all successors
    for (Iterator<AnalysisInfo> it = fallOut.iterator(); it.hasNext(); ) {
        copy(out, it.next());
    }
    for (Iterator<AnalysisInfo> it = branchOuts.iterator(); it.hasNext(); ) {
        copy(outBranch, it.next());
    }
}
Also used : ArrayRef(soot.jimple.ArrayRef) RefLikeType(soot.RefLikeType) FieldRef(soot.jimple.FieldRef) InstanceFieldRef(soot.jimple.InstanceFieldRef) InstanceInvokeExpr(soot.jimple.InstanceInvokeExpr) InvokeExpr(soot.jimple.InvokeExpr) JIfStmt(soot.jimple.internal.JIfStmt) MonitorStmt(soot.jimple.MonitorStmt) DefinitionStmt(soot.jimple.DefinitionStmt) MonitorStmt(soot.jimple.MonitorStmt) Stmt(soot.jimple.Stmt) JIfStmt(soot.jimple.internal.JIfStmt) DefinitionStmt(soot.jimple.DefinitionStmt)

Aggregations

RefLikeType (soot.RefLikeType)1 ArrayRef (soot.jimple.ArrayRef)1 DefinitionStmt (soot.jimple.DefinitionStmt)1 FieldRef (soot.jimple.FieldRef)1 InstanceFieldRef (soot.jimple.InstanceFieldRef)1 InstanceInvokeExpr (soot.jimple.InstanceInvokeExpr)1 InvokeExpr (soot.jimple.InvokeExpr)1 MonitorStmt (soot.jimple.MonitorStmt)1 Stmt (soot.jimple.Stmt)1 JIfStmt (soot.jimple.internal.JIfStmt)1