Search in sources :

Example 1 with JCastExpr

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

the class NullnessAssumptionAnalysis method handleRefTypeAssignment.

private void handleRefTypeAssignment(DefinitionStmt assignStmt, AnalysisInfo rhsInfo, AnalysisInfo out) {
    Value left = assignStmt.getLeftOp();
    Value right = assignStmt.getRightOp();
    // unbox casted value
    if (right instanceof JCastExpr) {
        JCastExpr castExpr = (JCastExpr) right;
        right = castExpr.getOp();
    }
    // An assignment invalidates any assumptions of null/non-null for lhs
    // We COULD be more accurate by assigning those assumptions to the rhs prior to this statement
    rhsInfo.put(right, BOTTOM);
    // assign from rhs to lhs
    out.put(left, rhsInfo.get(right));
}
Also used : Value(soot.Value) JCastExpr(soot.jimple.internal.JCastExpr)

Example 2 with JCastExpr

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

the class NullnessAnalysis method handleRefTypeAssignment.

private void handleRefTypeAssignment(DefinitionStmt assignStmt, AnalysisInfo out) {
    Value left = assignStmt.getLeftOp();
    Value right = assignStmt.getRightOp();
    // unbox casted value
    if (right instanceof JCastExpr) {
        JCastExpr castExpr = (JCastExpr) right;
        right = castExpr.getOp();
    }
    // if we have a definition (assignment) statement to a ref-like type, handle it,
    if (isAlwaysNonNull(right) || right instanceof NewExpr || right instanceof NewArrayExpr || right instanceof NewMultiArrayExpr || right instanceof ThisRef || right instanceof StringConstant || right instanceof ClassConstant || right instanceof CaughtExceptionRef) {
        // if we assign new... or @this, the result is non-null
        out.put(left, NON_NULL);
    } else if (right == NullConstant.v()) {
        // if we assign null, well, it's null
        out.put(left, NULL);
    } else if (left instanceof Local && right instanceof Local) {
        out.put(left, out.get(right));
    } else if (left instanceof Local && right instanceof PhiExpr) {
        handlePhiExpr(out, left, (PhiExpr) right);
    } else {
        out.put(left, TOP);
    }
}
Also used : CaughtExceptionRef(soot.jimple.CaughtExceptionRef) NewArrayExpr(soot.jimple.NewArrayExpr) ThisRef(soot.jimple.ThisRef) PhiExpr(soot.shimple.PhiExpr) NewMultiArrayExpr(soot.jimple.NewMultiArrayExpr) Value(soot.Value) NewExpr(soot.jimple.NewExpr) Local(soot.Local) JCastExpr(soot.jimple.internal.JCastExpr) StringConstant(soot.jimple.StringConstant) ClassConstant(soot.jimple.ClassConstant)

Aggregations

Value (soot.Value)2 JCastExpr (soot.jimple.internal.JCastExpr)2 Local (soot.Local)1 CaughtExceptionRef (soot.jimple.CaughtExceptionRef)1 ClassConstant (soot.jimple.ClassConstant)1 NewArrayExpr (soot.jimple.NewArrayExpr)1 NewExpr (soot.jimple.NewExpr)1 NewMultiArrayExpr (soot.jimple.NewMultiArrayExpr)1 StringConstant (soot.jimple.StringConstant)1 ThisRef (soot.jimple.ThisRef)1 PhiExpr (soot.shimple.PhiExpr)1