Search in sources :

Example 1 with JNeExpr

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

the class NullnessAnalysis method handleEqualityOrNonEqualityCheck.

private void handleEqualityOrNonEqualityCheck(AbstractBinopExpr eqExpr, AnalysisInfo in, AnalysisInfo out, AnalysisInfo outBranch) {
    Value left = eqExpr.getOp1();
    Value right = eqExpr.getOp2();
    Value val = null;
    if (left == NullConstant.v()) {
        if (right != NullConstant.v()) {
            val = right;
        }
    } else if (right == NullConstant.v()) {
        if (left != NullConstant.v()) {
            val = left;
        }
    }
    // if we compare a local with null then process further...
    if (val != null && val instanceof Local) {
        if (eqExpr instanceof JEqExpr)
            // a==null
            handleEquality(val, out, outBranch);
        else if (eqExpr instanceof JNeExpr)
            // a!=null
            handleNonEquality(val, out, outBranch);
        else
            throw new IllegalStateException("unexpected condition: " + eqExpr.getClass());
    }
}
Also used : JNeExpr(soot.jimple.internal.JNeExpr) Value(soot.Value) Local(soot.Local) JEqExpr(soot.jimple.internal.JEqExpr)

Example 2 with JNeExpr

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

the class NullnessAnalysis method handleIfStmt.

private void handleIfStmt(JIfStmt ifStmt, AnalysisInfo in, AnalysisInfo out, AnalysisInfo outBranch) {
    Value condition = ifStmt.getCondition();
    if (condition instanceof JInstanceOfExpr) {
        // a instanceof X ; if this succeeds, a is not null
        JInstanceOfExpr expr = (JInstanceOfExpr) condition;
        handleInstanceOfExpression(expr, in, out, outBranch);
    } else if (condition instanceof JEqExpr || condition instanceof JNeExpr) {
        // a==b or a!=b
        AbstractBinopExpr eqExpr = (AbstractBinopExpr) condition;
        handleEqualityOrNonEqualityCheck(eqExpr, in, out, outBranch);
    }
}
Also used : JNeExpr(soot.jimple.internal.JNeExpr) JInstanceOfExpr(soot.jimple.internal.JInstanceOfExpr) AbstractBinopExpr(soot.jimple.internal.AbstractBinopExpr) Value(soot.Value) JEqExpr(soot.jimple.internal.JEqExpr)

Aggregations

Value (soot.Value)2 JEqExpr (soot.jimple.internal.JEqExpr)2 JNeExpr (soot.jimple.internal.JNeExpr)2 Local (soot.Local)1 AbstractBinopExpr (soot.jimple.internal.AbstractBinopExpr)1 JInstanceOfExpr (soot.jimple.internal.JInstanceOfExpr)1