protected void internalTransform(Body b, String phaseName, Map<String, String> options) { for (Unit u : b.getUnits()) { if (u instanceof TargetArgInst && !(u instanceof GotoInst) && !(u instanceof JSRInst)) { count++; } } } }
private Unit getFirstNonIdentityStmt(Body b) { for (Unit u : b.getUnits()) { if (!(u instanceof IdentityStmt)) { return u; } } return null; } }
private static Unit getFirstNotIdentityStmt(Body body) { final Iterator<Unit> unitIterator = body.getUnits().snapshotIterator(); while (unitIterator.hasNext()) { final Unit unit = unitIterator.next(); if (unit instanceof IdentityStmt) { continue; } return unit; } logger.debug("There are no non-identity units in the method body."); return null; }
private IdentityStmt findIdentityStmt(Body b) { for (Unit u : b.getUnits()) { Stmt s = (Stmt) u; if ((s instanceof IdentityStmt) && (((IdentityStmt) s).getRightOp() instanceof ThisRef)) { return (IdentityStmt) s; } } return null; } }
protected boolean isThrowInStmtRange(Body b, Stmt begin, Stmt end, Stmt s) { Iterator it = b.getUnits().iterator(begin, end); while (it.hasNext()) { if (it.next().equals(s)) { return true; } } return false; }
protected Set<Unit> getCallsFromWithinMethod(SootMethod m) { Set<Unit> res = null; for (Unit u : m.getActiveBody().getUnits()) { if (isCallStmt(u)) { if (res == null) { res = new LinkedHashSet<Unit>(); } res.add(u); } } return res == null ? Collections.<Unit>emptySet() : res; }
/** Return unit containing the \@this-assignment **/ public Unit getThisUnit() { for (Unit u : getUnits()) { if (u instanceof IdentityStmt && ((IdentityStmt) u).getRightOp() instanceof ThisRef) { return u; } } throw new RuntimeException("couldn't find this-assignment!" + " in " + getMethod()); }
public void initializeUnitToOwner(SootMethod m) { if (m.hasActiveBody()) { Body b = m.getActiveBody(); PatchingChain<Unit> units = b.getUnits(); for (Unit unit : units) { unitToOwner.put(unit, b); } } }
@Override public boolean isFallThroughSuccessor(Unit u, Unit succ) { assert getSuccsOf(u).contains(succ); if (!u.fallsThrough()) { return false; } Body body = unitToOwner.get(u); return body.getUnits().getSuccOf(u) == succ; }
protected void buildNormal() { Body b = method.retrieveActiveBody(); for (Unit u : b.getUnits()) { nodeFactory.handleStmt((Stmt) u); } }
/** * Add unit to this body. * * @param u * Unit to add. */ public void add(Unit u) { getBody().getUnits().add(u); }
/** Returns a set of units which lie inside the range of any trap. */ public static Set<Unit> getTrappedUnitsOf(Body b) { Set<Unit> trapsSet = new HashSet<Unit>(); Chain<Unit> units = b.getUnits(); for (Trap t : b.getTraps()) { Iterator<Unit> it = units.iterator(t.getBeginUnit(), units.getPredOf(t.getEndUnit())); while (it.hasNext()) { trapsSet.add(it.next()); } } return trapsSet; }
@Override public void retype(Body body) { if (realType == null) { throw new RuntimeException("Real type of this instruction has not been set or was already retyped: " + this); } if (body.getUnits().contains(stmtToRetype)) { Local l = (Local) (stmtToRetype.getLeftOp()); l.setType(realType); realType = null; } }
protected void internalTransform(Body b, String phaseName, Map<String, String> options) { Iterator<Unit> it = b.getUnits().snapshotIterator(); while (it.hasNext()) { Unit u = it.next(); if (u instanceof LookupSwitchStmt) { LookupSwitchStmt sw = (LookupSwitchStmt) u; if (sw.getTargetCount() == 0 && sw.getDefaultTarget() != null) { b.getUnits().swapWith(sw, Jimple.v().newGotoStmt(sw.getDefaultTarget())); } } } } }
/** * Create a <code>BlockGraph</code> representing at the basic block level the control flow specified, at the * <code>Unit</code> level, by a given {@link UnitGraph}. * * @param unitGraph * A representation of the control flow at the level of individual {@link Unit}s. */ protected BlockGraph(UnitGraph unitGraph) { mBody = unitGraph.getBody(); mUnits = mBody.getUnits(); Set<Unit> leaders = computeLeaders(unitGraph); buildBlocks(leaders, unitGraph); }
@Override /** Verifies that the UnitBoxes of this Body all point to a Unit contained within this body. */ public void validate(Body body, List<ValidationException> exception) { for (UnitBox ub : body.getAllUnitBoxes()) { if (!body.getUnits().contains(ub.getUnit())) { throw new RuntimeException( "Unitbox points outside unitChain! to unit : " + ub.getUnit() + " in " + body.getMethod()); } } }
public void deferredJimplify(DexBody body) { IfStmt s = ifStatement(body); body.getBody().getUnits().swapWith(markerUnit, s); // insertAfter(s, markerUnit); setUnit(s); }
@Override public Map<Unit, Set<Local>> initialSeeds() { return DefaultSeeds.make(Collections.singleton(Scene.v().getMainMethod().getActiveBody().getUnits().getFirst()), zeroValue()); } }
public static soot.Local getPrivateAccessFieldInvoke(soot.SootMethodRef toInvoke, ArrayList params, soot.Body body, LocalGenerator lg) { soot.jimple.InvokeExpr invoke = soot.jimple.Jimple.v().newStaticInvokeExpr(toInvoke, params); soot.Local retLocal = lg.generateLocal(toInvoke.returnType()); soot.jimple.AssignStmt stmt = soot.jimple.Jimple.v().newAssignStmt(retLocal, invoke); body.getUnits().add(stmt); return retLocal; }
public void deferredJimplify(DexBody body) { int keyRegister = ((OneRegisterInstruction) instruction).getRegisterA(); int offset = ((OffsetInstruction) instruction).getCodeOffset(); Local key = body.getRegisterLocal(keyRegister); int targetAddress = codeAddress + offset; Instruction targetData = body.instructionAtAddress(targetAddress).instruction; Stmt stmt = switchStatement(body, targetData, key); body.getBody().getUnits().insertAfter(stmt, markerUnit); }