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; }
/** Removes the given object from this Chain. */ @Override @SuppressWarnings("unchecked") public boolean remove(Object obj) { boolean res = false; if (contains(obj)) { Unit successor = getSuccOf((E) obj); if (successor == null) { successor = getPredOf((E) obj); } // Note that redirecting to the last unit in the method // like this is probably incorrect when dealing with a Trap. // I.e., let's say that the final unit in the method used to // be U10, preceded by U9, and that there was a Trap which // returned U10 as getEndUnit(). I.e., before the trap covered U9. // When we redirect the Trap's end unit to U9, the trap will no // longer cover U9. I know this is incorrect, but I'm not sure how // to fix it, so I'm leaving this comment in the hopes that some // future maintainer will see the right course to take. res = innerChain.remove(obj); ((E) obj).redirectJumpsToThisTo(successor); } return res; }
toinsert.add(Baf.v().newStaticGetInst(field.makeRef())); if (field.getType() instanceof IntegerType) { toinsert.add(Baf.v().newIfGeInst((Unit) units.getSuccOf(nonTrap))); } else { SootMethod boolInit = ((RefType) field.getType()).getSootClass().getMethod("boolean booleanValue()"); toinsert.add(Baf.v().newVirtualInvokeInst(boolInit.makeRef())); toinsert.add(Baf.v().newIfGeInst((Unit) units.getSuccOf(nonTrap))); toinsert.add(Baf.v().newIfEqInst((Unit) units.getSuccOf(nonTrap)));
final Unit firstReorderingUnit = units.getSuccOf(first); final Unit nextReorderingUnit = units.getSuccOf(reorderingUnit); units.remove(reorderingUnit); units.add(reorderingUnit); Unit secondReorderedUnit = units.getSuccOf(firstReorderingNotGotoStmt); if (secondReorderedUnit == null || (secondReorderedUnit.equals(units.getLast()) && secondReorderedUnit instanceof IdentityStmt)) { trapEndUnit = reorderedUnitsIterator.next(); trapEndUnit = units.getSuccOf(trapEndUnit);
IfStmt ifs = (IfStmt) s; JGotoStmt jgs = new JGotoStmt((Unit) units.getSuccOf(u)); units.insertAfter(jgs, u);
Unit handler = Baf.v().newThrowInst(); units.add(handler); b.getTraps().add(Baf.v().newTrap(ThrowSet.getRandomThrowable(), sii, (Unit) units.getSuccOf(sii), handler)); done = true; break;
Unit succ = units.getSuccOf(u); Unit pop = Baf.v().newPopInst(RefType.v()); Unit popClone = (Unit) pop.clone();
/** Removes the given object from this Chain. */ @SuppressWarnings("unchecked") public boolean remove(Object obj) { boolean res = false; if(contains(obj)) { Unit successor; if((successor = getSuccOf((E) obj)) == null) successor = getPredOf((E) obj); // Note that redirecting to the last unit in the method // like this is probably incorrect when dealing with a Trap. // I.e., let's say that the final unit in the method used to // be U10, preceded by U9, and that there was a Trap which // returned U10 as getEndUnit(). I.e., before the trap covered U9. // When we redirect the Trap's end unit to U9, the trap will no // longer cover U9. I know this is incorrect, but I'm not sure how // to fix it, so I'm leaving this comment in the hopes that some // future maintainer will see the right course to take. res = innerChain.remove(obj); ((E)obj).redirectJumpsToThisTo(successor); } return res; }
/** Removes the given object from this Chain. */ @SuppressWarnings("unchecked") public boolean remove(Object obj) { boolean res = false; if(contains(obj)) { Unit successor; if((successor = getSuccOf((E) obj)) == null) successor = getPredOf((E) obj); // Note that redirecting to the last unit in the method // like this is probably incorrect when dealing with a Trap. // I.e., let's say that the final unit in the method used to // be U10, preceded by U9, and that there was a Trap which // returned U10 as getEndUnit(). I.e., before the trap covered U9. // When we redirect the Trap's end unit to U9, the trap will no // longer cover U9. I know this is incorrect, but I'm not sure how // to fix it, so I'm leaving this comment in the hopes that some // future maintainer will see the right course to take. res = innerChain.remove(obj); ((E)obj).redirectJumpsToThisTo(successor); } return res; }
private List<Unit> createVirtualCall(Body body, SootMethod callee, Unit originalCall, InstanceInvokeExpr ivk) { List<Unit> units = new LinkedList<Unit>(); Local l = getFreshLocal(body, callee.getDeclaringClass().getType()); // cast the base to the corresponding type. units.add(assignStmtFor(l, Jimple.v().newCastExpr(ivk.getBase(), callee.getDeclaringClass().getType()), originalCall)); if (originalCall instanceof InvokeStmt) { // make the call statement units.add(invokeStmtFor(l, callee.makeRef(), ivk.getArgs(), originalCall)); } else if (originalCall instanceof AssignStmt) { AssignStmt s = (AssignStmt) originalCall; // make the call statement Unit newAssign = assignStmtFor(s.getLeftOp(), Jimple.v().newVirtualInvokeExpr(l, callee.makeRef(), ivk.getArgs()), s); units.add(newAssign); } else if (originalCall instanceof IdentityStmt) { throw new RuntimeException("Not imeplemented " + originalCall); } // jump back to the statement after the original call. Unit succ = body.getUnits().getSuccOf(originalCall); if (succ != null) { units.add(gotoStmtFor(succ, originalCall)); } return units; }
Unit next = units.getSuccOf(arg0);