Java Code Examples for soot.jimple.NullConstant#v()
The following examples show how to use
soot.jimple.NullConstant#v() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DexNullThrowTransformer.java From JAADAS with GNU General Public License v3.0 | 6 votes |
@Override protected void internalTransform(Body b, String phaseName, Map<String, String> options) { LocalCreation lc = new LocalCreation(b.getLocals(), "ex"); for (Iterator<Unit> unitIt = b.getUnits().snapshotIterator(); unitIt.hasNext(); ) { Unit u = unitIt.next(); // Check for a null exception if (u instanceof ThrowStmt) { ThrowStmt throwStmt = (ThrowStmt) u; if (throwStmt.getOp() == NullConstant.v() || throwStmt.getOp().equals(IntConstant.v(0)) || throwStmt.getOp().equals(LongConstant.v(0))) { createThrowStmt(b, throwStmt, lc); } } } }
Example 2
Source File: NullnessAnalysis.java From JAADAS with GNU General Public License v3.0 | 5 votes |
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()); } }
Example 3
Source File: NullnessAnalysis.java From JAADAS with GNU General Public License v3.0 | 5 votes |
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 { out.put(left, TOP); } }
Example 4
Source File: DexNullArrayRefTransformer.java From JAADAS with GNU General Public License v3.0 | 5 votes |
/** * Checks whether the given local is guaranteed to be always null at the * given statement * @param s The statement at which to check the local * @param base The local to check * @param defs The definition analysis object to use for the check * @return True if the given local is guaranteed to always be null at the * given statement, otherwise false */ private boolean isAlwaysNullBefore(Stmt s, Local base, LocalDefs defs) { List<Unit> baseDefs = defs.getDefsOfAt(base, s); if (baseDefs.isEmpty()) return true; for (Unit u : baseDefs) { if (!(u instanceof DefinitionStmt)) return false; DefinitionStmt defStmt = (DefinitionStmt) u; if (defStmt.getRightOp() != NullConstant.v()) return false; } return true; }
Example 5
Source File: AsmMethodSource.java From JAADAS with GNU General Public License v3.0 | 5 votes |
private void convertConstInsn(InsnNode insn) { int op = insn.getOpcode(); StackFrame frame = getFrame(insn); Operand[] out = frame.out(); Operand opr; if (out == null) { Value v; if (op == ACONST_NULL) v = NullConstant.v(); else if (op >= ICONST_M1 && op <= ICONST_5) v = IntConstant.v(op - ICONST_0); else if (op == LCONST_0 || op == LCONST_1) v = LongConstant.v(op - LCONST_0); else if (op >= FCONST_0 && op <= FCONST_2) v = FloatConstant.v(op - FCONST_0); else if (op == DCONST_0 || op == DCONST_1) v = DoubleConstant.v(op - DCONST_0); else throw new AssertionError("Unknown constant opcode: " + op); opr = new Operand(insn, v); frame.out(opr); } else { opr = out[0]; } if (op == LCONST_0 || op == LCONST_1 || op == DCONST_0 || op == DCONST_1) { pushDual(opr); } else { push(opr); } }
Example 6
Source File: InstrumentationUtils.java From DroidRA with GNU Lesser General Public License v2.1 | 5 votes |
public static Value toDefaultSootTypeValue(Type sootType) { String type = sootType.toString(); if ("boolean".equals(type)) { IntConstant.v(0); } else if ("byte".equals(type)) { return IntConstant.v(0); } else if ("char".equals(type)) { return IntConstant.v(0); } else if ("short".equals(type)) { return IntConstant.v(0); } else if ("int".equals(type)) { return IntConstant.v(0); } else if ("long".equals(type)) { return LongConstant.v(0); } else if ("float".equals(type)) { return FloatConstant.v(0); } else if ("double".equals(type)) { return DoubleConstant.v(0); } return NullConstant.v(); }