protected void internalTransform(Body b, String phaseName, Map<String, String> options) { int idx = 0; PatchingChain<Unit> units = b.getUnits(); Iterator<Unit> it = units.iterator(); while (it.hasNext()) { Inst i = (Inst) it.next(); List<Tag> tags = i.getTags(); for (int k = 0; k < tags.size(); k++) { Tag t = (Tag) tags.get(k); if (t instanceof LineNumberTag) { tags.remove(k); break; } } if (i instanceof IdentityInst) { continue; } i.addTag(new LineNumberTag(idx++)); } } }
protected void internalTransform(Body b, String phaseName, Map<String, String> options) { System.out.println("Printing Line Numbers for: " + b.getMethod().getSignature()); PatchingChain<Unit> units = b.getUnits(); // get the method code Iterator<Unit> it = units.iterator(); while (it.hasNext()) { // for each jimple statement or baf instruction Unit u = (Unit) it.next(); if (u.hasTag("LineNumberTag")) { // see if a LineNumberTag exists (it will if you use -keep-line-number) LineNumberTag tag = (LineNumberTag) u.getTag(("LineNumberTag")); System.out.println(u + " has Line Number: " + tag.getLineNumber()); // print out the unit and line number } else { System.out.println(u + " has no Line Number"); } } System.out.println("\n"); } }
private List<Trap> getTrapsForUnit(Object o, Body b) { ArrayList<Trap> list = new ArrayList<Trap>(); Chain<Trap> traps = b.getTraps(); if (traps.size() != 0) { PatchingChain<Unit> units = b.getUnits(); Iterator<Trap> it = traps.iterator(); while (it.hasNext()) { Trap t = it.next(); Iterator<Unit> tit = units.iterator(t.getBeginUnit(), t.getEndUnit()); while (tit.hasNext()) { if (tit.next() == o) { list.add(t); break; } } } } return list; }
Unit last = null; nonTrap = Baf.v().newNopInst(); for (Iterator<Unit> it = units.iterator(); it.hasNext();) { Unit u = (Unit) it.next(); if (u instanceof IdentityInst && ((IdentityInst) u).getLeftOp() instanceof Local) {
= sm.getActiveBody().getTraps().isEmpty() ? null : new HashMap<Unit, Collection<Trap>>(); for (Trap t : sm.getActiveBody().getTraps()) { for (Iterator<Unit> unitIt = units.iterator(t.getBeginUnit(), units.getPredOf(t.getEndUnit())); unitIt.hasNext();) { Unit unit = unitIt.next();
Iterator<Unit> uit = u.iterator(); while (uit.hasNext()) { Unit unit = uit.next();
Iterator<Unit> uit = units.iterator(); while (uit.hasNext()) { Unit unit = (Unit) uit.next();
= units.iterator(secondReorderedUnit, units.getPredOf(caughtExceptionHandler)); Unit trapEndUnit = reorderedUnitsIterator.next(); while (trapEndUnit instanceof IdentityStmt && reorderedUnitsIterator.hasNext()) {
SootMethod thisMethod = b.getMethod(); PatchingChain<Unit> units = b.getUnits(); Iterator<Unit> unitIt = units.iterator(); Unit firstUnit = j.getFirstNonIdentityStmt(); Unit lastUnit = units.getLast();
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 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; }
/** Returns the first non-identity stmt in this body. */ public Stmt getFirstNonIdentityStmt() { Iterator it = getUnits().iterator(); Object o = null; while (it.hasNext()) if (!((o = it.next()) instanceof IdentityStmt)) break; if (o == null) throw new RuntimeException("no non-id statements!"); return (Stmt)o; } }
/** Returns the first non-identity stmt in this body. */ public Stmt getFirstNonIdentityStmt() { Iterator it = getUnits().iterator(); Object o = null; while (it.hasNext()) if (!((o = it.next()) instanceof IdentityStmt)) break; if (o == null) throw new RuntimeException("no non-id statements!"); return (Stmt)o; } }
/** * does the actual mapping. assumes, that the hashtable is already initialized. */ private void map(Body b) { Iterator unitIt = b.getUnits().iterator(); while (unitIt.hasNext()) { Unit currentUnit = (Unit)unitIt.next(); Object o = mapTo(currentUnit); if (o != null) unitToResult.put(currentUnit, o); } }
/** * does the actual mapping. assumes, that the hashtable is already initialized. */ private void map(Body b) { Iterator unitIt = b.getUnits().iterator(); while (unitIt.hasNext()) { Unit currentUnit = (Unit)unitIt.next(); Object o = mapTo(currentUnit); if (o != null) unitToResult.put(currentUnit, o); } }
private IdentityStmt findIdentityStmt(Body b){ Iterator it = b.getUnits().iterator(); while (it.hasNext()){ Stmt s = (Stmt)it.next(); if ((s instanceof IdentityStmt) && (((IdentityStmt)s).getRightOp() instanceof ThisRef)){ return (IdentityStmt)s; } } return null; } }
private IdentityStmt findIdentityStmt(Body b){ Iterator it = b.getUnits().iterator(); while (it.hasNext()){ Stmt s = (Stmt)it.next(); if ((s instanceof IdentityStmt) && (((IdentityStmt)s).getRightOp() instanceof ThisRef)){ return (IdentityStmt)s; } } return null; } }
private InvokeStmt getFirstSpecialInvoke(Body b){ Iterator it = b.getUnits().iterator(); while (it.hasNext()){ Stmt s = (Stmt)it.next(); if (!(s instanceof InvokeStmt)) continue; InvokeExpr invokeExpr = ((InvokeStmt)s).getInvokeExpr(); if (!(invokeExpr instanceof SpecialInvokeExpr)) continue; return (InvokeStmt)s; } // but there will always be either a call to this() or to super() // from the constructor return null; }
/** Return LHS of the first identity stmt assigning from \@this. **/ public Local getThisLocal() { Iterator<Unit> unitsIt = getUnits().iterator(); while (unitsIt.hasNext()) { Unit s = unitsIt.next(); if (s instanceof IdentityStmt && ((IdentityStmt)s).getRightOp() instanceof ThisRef) return (Local)(((IdentityStmt)s).getLeftOp()); } throw new RuntimeException("couldn't find identityref!"+" in "+getMethod()); }
/** Return LHS of the first identity stmt assigning from \@this. **/ public Local getThisLocal() { Iterator<Unit> unitsIt = getUnits().iterator(); while (unitsIt.hasNext()) { Unit s = unitsIt.next(); if (s instanceof IdentityStmt && ((IdentityStmt)s).getRightOp() instanceof ThisRef) return (Local)(((IdentityStmt)s).getLeftOp()); } throw new RuntimeException("couldn't find identityref!"+" in "+getMethod()); }