public void caseIfStmt(IfStmt s) { IfStmt newStmt = (IfStmt) (oldToNew.get(s)); newStmt.setTarget(oldToNew.get(newStmt.getTarget())); }
private void transformBody(Body b, Stmt next) { // change target of stmts 0 and 1 to target of stmt 5 // remove stmts 2, 3, 4, 5 Stmt newTarget = null; Stmt oldTarget = null; if (sameGoto) { newTarget = ((IfStmt) stmtSeq[5]).getTarget(); } else { newTarget = next; oldTarget = ((IfStmt) stmtSeq[5]).getTarget(); } ((IfStmt) stmtSeq[0]).setTarget(newTarget); ((IfStmt) stmtSeq[1]).setTarget(newTarget); for (int i = 2; i <= 5; i++) { b.getUnits().remove(stmtSeq[i]); } if (!sameGoto) { b.getUnits().insertAfter(Jimple.v().newGotoStmt(oldTarget), stmtSeq[1]); } }
@Override protected void internalTransform(Body b, String phaseName, Map<String, String> options) { for (Iterator<Unit> unitIt = b.getUnits().snapshotIterator(); unitIt.hasNext();) { Unit u = unitIt.next(); if (u instanceof GotoStmt) { GotoStmt stmt = (GotoStmt) u; while (stmt.getTarget() instanceof GotoStmt) { GotoStmt nextTarget = (GotoStmt) stmt.getTarget(); stmt.setTarget(nextTarget.getTarget()); } } else if (u instanceof IfStmt) { IfStmt stmt = (IfStmt) u; while (stmt.getTarget() instanceof GotoStmt) { GotoStmt nextTarget = (GotoStmt) stmt.getTarget(); stmt.setTarget(nextTarget.getTarget()); } } } }
} else if (loopTail instanceof IfStmt) { if (((IfStmt) loopTail).getTarget() == condition.getHead()) { ((IfStmt) loopTail).setTarget(copiedHead); } else { insertGotoAfter(loopTail, copiedHead);
newTarget = stmt; ((IfStmt) stmt).setTarget(newTarget); updateCounters(2, true); } else if (target instanceof IfStmt) {
Unit newTarget = (Unit) t.clone(); body.getUnits().addLast(newTarget); ifstmt.setTarget(newTarget);
ifstmt.setTarget(u);
units.insertBefore(Jimple.v().newAssignStmt(Jimple.v().newStaticFieldRef(classCacher.makeRef()), l), target); ifStmt.setTarget(target); return l;
((IfStmt) insertee).setTarget(s);
ifs.setTarget(newDst);
ifs.setTarget((Unit) jumper);
((IfStmt) insertee).setTarget(toInline);
u.setTarget(addt);
else if (loopTail instanceof IfStmt) { if (((IfStmt)loopTail).getTarget() == condition.getHead()) ((IfStmt)loopTail).setTarget(copiedHead); else insertGotoAfter(loopTail, copiedHead);
else if (loopTail instanceof IfStmt) { if (((IfStmt)loopTail).getTarget() == condition.getHead()) ((IfStmt)loopTail).setTarget(copiedHead); else insertGotoAfter(loopTail, copiedHead);
if (newTarget == null) newTarget = stmt; ((IfStmt)stmt).setTarget(newTarget); updateCounters(2, true);
if (newTarget == null) newTarget = stmt; ((IfStmt)stmt).setTarget(newTarget); updateCounters(2, true);