/** Inserts <code>toInsert</code> in the Chain before <code>point</code>. */ @Override public void insertBefore(Chain<E> toInsert, E point) { Object[] obj = toInsert.toArray(); E previousPoint = point; for (int i = obj.length - 1; i >= 0; i--) { @SuppressWarnings("unchecked") E o = (E) obj[i]; insertBefore(o, previousPoint); previousPoint = o; } }
units.insertBefore(baseAssign, insertBefore); } else { units.insertBeforeNoRedirect(baseAssign, insertBefore);
private void loadBooleanValue(PatchingChain<Unit> units, SootField f, Unit insert) { units.insertBefore(Baf.v().newStaticGetInst(f.makeRef()), insert); if (f.getType() instanceof RefType) { SootMethod boolInit = ((RefType) f.getType()).getSootClass().getMethod("boolean booleanValue()"); units.insertBefore(Baf.v().newVirtualInvokeInst(boolInit.makeRef()), insert); } }
units.insertBefore(first, units.getFirst()); } else { first = (Unit) units.getSuccOf(first); units.insertBefore(newBeginUnit, begUnit); units.insertBefore(Baf.v().newIfNeInst(handlerUnit), begUnit); units.insertBefore(Baf.v().newPopInst(RefType.v()), begUnit); units.insertBefore(Baf.v().newLoadInst(varLocal.getType(), varLocal), begUnit);
public Body add(soot.jimple.Stmt stmt) { if(list != null) { list.add(stmt); list = null; } stmt.addTag(currentSourceRangeTag()); soot.PatchingChain<Unit> chain = (soot.PatchingChain<Unit>)chains.peek(); if(stmt instanceof IdentityStmt && chain.size() != 0) { IdentityStmt idstmt = (IdentityStmt) stmt; if(!(idstmt.getRightOp() instanceof CaughtExceptionRef)) { soot.Unit s = chain.getFirst(); while(s instanceof IdentityStmt) s = chain.getSuccOf((soot.jimple.Stmt)s); if(s != null) { chain.insertBefore(stmt, (soot.jimple.Stmt)s); return this; } } } chain.add(stmt); return this; }
units.insertBefore(Jimple.v().newAssignStmt(b1, Jimple.v().newStaticFieldRef(ops[0].makeRef())), u); } else { RefType rt = (RefType) ops[0].getType(); Local B = Jimple.v().newLocal("addswitchesBOOL1", rt); locals.add(B); units.insertBefore(Jimple.v().newAssignStmt(B, Jimple.v().newStaticFieldRef(ops[0].makeRef())), u); units.insertBefore( Jimple.v().newAssignStmt(b1, Jimple.v().newVirtualInvokeExpr(B, m.makeRef(), Collections.<Value>emptyList())), u); units.insertBefore(Jimple.v().newAssignStmt(b2, Jimple.v().newStaticFieldRef(ops[1].makeRef())), u); } else { RefType rt = (RefType) ops[1].getType(); Local B = Jimple.v().newLocal("addswitchesBOOL2", rt); locals.add(B); units.insertBefore(Jimple.v().newAssignStmt(B, Jimple.v().newStaticFieldRef(ops[1].makeRef())), u); units.insertBefore( Jimple.v().newAssignStmt(b2, Jimple.v().newVirtualInvokeExpr(B, m.makeRef(), Collections.<Value>emptyList())), u); units.insertBefore(ifstmt, u); Unit nxt = (Unit) tit.next(); if (Rand.getInt(5) < 4) { units.insertBefore(Jimple.v().newAssignStmt(l, Jimple.v().newAddExpr(l, IntConstant.v(Rand.getInt(3) + 1))), nxt);
u.insertBefore(pop, unit); processedLabels.add(unit); popsBuilt.put(pop, unit);
units.insertBeforeNoRedirect(newPrep, firstUnit); } else { units.insertBefore(newPrep, tn.entermonitor); units.insertBefore(newPrep, tn.entermonitor); } else { units.insertBeforeNoRedirect(newPrep, tn.beginning); units.insertBeforeNoRedirect(newPrep, firstUnit); } else { units.insertBefore(newPrep, tn.entermonitor); units.insertBefore(newEntermonitor, csr.entermonitor); if (newPrep != null) { Stmt tmp = (Stmt) newPrep.clone(); units.insertBefore(tmp, exitmonitor); // seems units.insertBefore(newExitmonitor, exitmonitor); if (newPrep != null) { Stmt tmp = (Stmt) newPrep.clone(); units.insertBefore(tmp, earlyEnd); units.insertBefore(newExitmonitor, earlyEnd); newEarlyEnds.add(new Pair<Stmt, Stmt>(earlyEnd, newExitmonitor)); units.insertBefore(tmp, exitmonitor);
units.insertBefore(store, first); units.insertBefore(pushUnit, store); units.insertBefore(storet, firstt); units.insertBefore(pushUnit, storet);
Type t = ((Local) locals.get(bl)).getType(); if (t instanceof RefType && ((RefType) t).getSootClass().getName().equals(origClass.getName())) { units.insertBefore(Baf.v().newDup1Inst(RefType.v()), sii); Unit ifinst = Baf.v().newIfNullInst(sii); units.insertBeforeNoRedirect(ifinst, sii); if (Rand.getInt() % 2 == 0) { pop = (Unit) pop.clone(); units.insertBefore(pop, sii); units.insertBefore(Baf.v().newGotoInst(sii), pop); units.add(Baf.v().newJSRInst(pop)); } else { if (c.getName().equals("java.lang.Throwable")) { Unit throwThis = Baf.v().newThrowInst(); units.insertBefore(throwThis, sii); b.getTraps().add(Baf.v().newTrap(origClass, throwThis, sii, sii)); done = true; units.insertBefore(pop, sii); units.insertBeforeNoRedirect(Baf.v().newJSRInst(pop), pop); done = true;
units.insertBefore(clone, u); units.insertBefore(Baf.v().newSwapInst(RefType.v(), clone.getOpType()), u); units.insertBefore(clone, u); Type t2 = clone.getOpType(); Unit dup; dup = Baf.v().newDup1_x2Inst(t2, t, t); units.insertBefore(dup, u); units.insertBefore(Baf.v().newPopInst(t2), u); units.insertBefore(clone, u); units.insertBefore(Baf.v().newSwapInst(IntType.v(), clone.getOpType()), u);
units.insertBefore(tmp, store); store = tmp; units.insertBefore(pinit, store);
u.insertBefore(Baf.v().newPrimitiveCastInst(jloc.getType(), LongType.v()), unit); if (index > 0) { u.insertBefore(Baf.v().newPushInst(IntConstant.v(index)), unit); u.insertBefore(Baf.v().newShlInst(LongType.v()), unit); u.insertBefore(Baf.v().newPushInst(LongConstant.v(~longmask)), unit); u.insertBefore(Baf.v().newAndInst(LongType.v()), unit); u.insertBefore(Baf.v().newLoadInst(LongType.v(), nloc), unit); u.insertBefore(Baf.v().newPushInst(LongConstant.v(longmask)), unit); u.insertBefore(Baf.v().newAndInst(LongType.v()), unit); u.insertBefore(Baf.v().newXorInst(LongType.v()), unit); u.insertBefore(Baf.v().newStoreInst(LongType.v(), nloc), unit); u.remove(unit); u.insertBefore(Baf.v().newLoadInst(LongType.v(), nloc), unit); u.insertBefore(Baf.v().newPushInst(LongConstant.v(longmask)), unit); u.insertBefore(Baf.v().newAndInst(LongType.v()), unit); if (index > 0) { u.insertBefore(Baf.v().newPushInst(IntConstant.v(index)), unit); u.insertBefore(Baf.v().newShrInst(LongType.v()), unit); u.insertBefore(Baf.v().newPrimitiveCastInst(LongType.v(), t), unit); if (!(origType instanceof IntType) && !(origType instanceof BooleanType)) { u.insertBefore(Baf.v().newPrimitiveCastInst(t, origType), unit); u.insertBefore(Baf.v().newPushInst(ii.getConstant()), unit); u.insertBefore(Baf.v().newLoadInst(LongType.v(), nloc), unit); u.insertBefore(Baf.v().newPushInst(LongConstant.v(longmask)), unit); u.insertBefore(Baf.v().newAndInst(LongType.v()), unit);
protected void internalTransform(Body b, String phaseName, Map<String, String> options) { if (b.getMethod().getName().indexOf("<clinit>") >= 0) { return; } int weight = soot.jbco.Main.getWeight(phaseName, b.getMethod().getSignature()); if (weight == 0) { return; } PatchingChain<Unit> units = b.getUnits(); Iterator<Unit> iter = units.snapshotIterator(); while (iter.hasNext()) { Unit u = (Unit) iter.next(); if (u instanceof PushInst) { SootField f = CollectConstants.constantsToFields.get(((PushInst) u).getConstant()); if (f != null && Rand.getInt(10) <= weight) { Unit get = Baf.v().newStaticGetInst(f.makeRef()); units.insertBefore(get, u); BodyBuilder.updateTraps(get, u, b.getTraps()); units.remove(u); updated++; } } } } }
toinserttry.add(Baf.v().newGotoInst(handler)); toinsert.add(Baf.v().newGotoInst(toinserttry.get(0))); units.insertBefore(toinserttry, nop);
Unit pop = Baf.v().newPopInst(RefType.v()); Unit popClone = (Unit) pop.clone(); units.insertBefore(pop, targ); units.insertBefore(gotoTarg, pop); units.insertBefore(methCall, u); } else { Unit throwu = Baf.v().newThrowInst(); units.insertBefore(throwu, u); units.remove(u); units.insertBefore(Baf.v().newPushInst(NullConstant.v()), throwu); Unit ifunit = Baf.v().newIfCmpNeInst(RefType.v(), succ); units.insertBefore(ifunit, throwu); units.insertBefore(Baf.v().newPushInst(NullConstant.v()), throwu); units.insertBefore(methCall, u); units.insertBefore(Baf.v().newPushInst(NullConstant.v()), methCall); if (Rand.getInt(2) == 0) { Unit pop = Baf.v().newPopInst(BooleanType.v()); units.insertBefore(pop, u); Unit gotoTarg = Baf.v().newGotoInst(targ); units.insertBefore(gotoTarg, u); } else { Unit iffalse = Baf.v().newIfEqInst(targ); units.insertBefore(iffalse, u);
units.insertBefore(newU, u); units.insertBefore(newU, u); units.insertBefore(newU, u); units.insertBefore(newU, u);
units.insertBefore(list, units.getFirst());
private Local insertCast(Local oldlocal, Type type, Stmt stmt) { Local newlocal = Jimple.v().newLocal("tmp", type); stmtBody.getLocals().add(newlocal); stmtBody.getUnits().insertBefore(Jimple.v().newAssignStmt(newlocal, Jimple.v().newCastExpr(oldlocal, type)), stmt); return newlocal; }
private Local insertCast(Local oldlocal, Type type, Stmt stmt) { Local newlocal = Jimple.v().newLocal("tmp", type); stmtBody.getLocals().add(newlocal); stmtBody.getUnits().insertBefore(Jimple.v().newAssignStmt(newlocal, Jimple.v().newCastExpr(oldlocal, type)), stmt); return newlocal; } }