/** * Constructs a GotoStmt(Stmt) grammar chunk. */ public GotoStmt newGotoStmt(Unit target) { return Jimple.v().newGotoStmt(target); }
public soot.jimple.GotoStmt newGotoStmt(Unit target, ASTNode location) { soot.jimple.GotoStmt stmt = Jimple.v().newGotoStmt(target); return stmt; }
public GotoStmt newGotoStmt(GotoStmt s) { return Jimple.v().newGotoStmt(s.getTarget()); }
public void outAGotoStatement(AGotoStatement node) { String targetLabel = (String) mProductions.removeLast(); UnitBox box = Jimple.v().newStmtBox(null); Unit branch = Jimple.v().newGotoStmt(box); addBoxToPatch(targetLabel, box); mProductions.addLast(branch); }
/** * inserts a Jimple<code>Goto</code> to <code> target, directly after * <code>node</code> in the given <code>unitChain</code>.<br> * As we use <code>JGoto</code> the chain must contain Jimple-stmts. * * @param unitChain * the Chain where we will insert the <code>Goto</code>. * @param node * the <code>Goto</code> will be inserted just after this node. * @param target * is the Unit the <code>goto</code> will jump to. * @return the newly inserted <code>Goto</code> */ private static Unit insertGotoAfter(Chain<Unit> unitChain, Unit node, Unit target) { Unit newGoto = Jimple.v().newGotoStmt(target); unitChain.insertAfter(newGoto, node); return newGoto; }
/** * inserts a Jimple<code>Goto</code> to <code> target, directly after * <code>node</code> in the <code>unitChain</code> of the body.<br> * As we use <code>JGoto</code> the chain must contain Jimple-stmts. * * @param node * the <code>Goto</code> will be inserted just after this node. * @param target * is the Unit the <code>goto</code> will jump to. * @return the newly inserted <code>Goto</code> */ private Unit insertGotoAfter(Unit node, Unit target) { Unit newGoto = Jimple.v().newGotoStmt(target); body.getUnits().insertAfter(newGoto, node); return newGoto; }
private GotoStmt gotoStatement() { GotoStmt go = Jimple.v().newGotoStmt(targetInstruction.getUnit()); setUnit(go); addTags(go); return go; }
/** * inserts a Jimple<code>Goto</code> to <code> target, directly before * <code>node</code> in the given <code>unitChain</code>.<br> * As we use <code>JGoto</code> the chain must contain Jimple-stmts. * * @param unitChain * the Chain where we will insert the <code>Goto</code>. * @param node * the <code>Goto</code> will be inserted just before this node. * @param target * is the Unit the <code>goto</code> will jump to. * @return the newly inserted <code>Goto</code> */ /* note, that this method has slightly more overhead than the insertGotoAfter */ private static Unit insertGotoBefore(Chain<Unit> unitChain, Unit node, Unit target) { Unit newGoto = Jimple.v().newGotoStmt(target); unitChain.insertBefore(newGoto, node); newGoto.redirectJumpsToThisTo(node); return newGoto; }
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())); } } } } }
createStmt((polyglot.ast.Stmt) itersIt.next()); soot.jimple.Stmt goto1 = soot.jimple.Jimple.v().newGotoStmt(noop2); body.getUnits().add(goto1); body.getUnits().add(noop1);
/** * While Stmts Creation */ private void createWhile2(polyglot.ast.While whileStmt) { soot.jimple.Stmt brchTgt = soot.jimple.Jimple.v().newNopStmt(); soot.jimple.Stmt beginTgt = soot.jimple.Jimple.v().newNopStmt(); body.getUnits().add(beginTgt); // these are for break and continue endControlNoop.push(soot.jimple.Jimple.v().newNopStmt()); condControlNoop.push(soot.jimple.Jimple.v().newNopStmt()); // handle cond soot.jimple.Stmt continueStmt = condControlNoop.pop(); body.getUnits().add(continueStmt); condControlNoop.push(continueStmt); polyglot.ast.Expr condition = whileStmt.cond(); createBranchingExpr(condition, brchTgt, false); createStmt(whileStmt.body()); soot.jimple.GotoStmt gotoLoop = soot.jimple.Jimple.v().newGotoStmt(beginTgt); body.getUnits().add(gotoLoop); body.getUnits().add((endControlNoop.pop())); body.getUnits().add(brchTgt); condControlNoop.pop(); }
soot.jimple.Stmt tryEndGoto = soot.jimple.Jimple.v().newGotoStmt(endNoop); body.getUnits().add(tryEndGoto); catchStack.pop(); soot.jimple.Stmt catchEndGoto = soot.jimple.Jimple.v().newGotoStmt(endNoop); body.getUnits().add(catchEndGoto);
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]); } }
Stmt newStmt = Jimple.v().newGotoStmt(ifs.getTarget()); units.insertAfter(newStmt, stmt); numTrue++;
@Override protected void internalTransform(Body b, String phaseName, Map<String, String> options) { for (Trap t : b.getTraps()) { // If the first statement already catches the exception, we're fine if (isCaughtExceptionRef(t.getHandlerUnit())) { continue; } // Add the exception reference Local l = new LocalGenerator(b).generateLocal(t.getException().getType()); Stmt caughtStmt = Jimple.v().newIdentityStmt(l, Jimple.v().newCaughtExceptionRef()); b.getUnits().add(caughtStmt); b.getUnits().add(Jimple.v().newGotoStmt(t.getHandlerUnit())); t.setHandlerUnit(caughtStmt); } }
/** * If Stmts Creation - only add line-number tags to if (the other stmts needing tags are created elsewhere */ private void createIf2(polyglot.ast.If ifExpr) { soot.jimple.NopStmt endTgt = soot.jimple.Jimple.v().newNopStmt(); soot.jimple.NopStmt brchTgt = soot.jimple.Jimple.v().newNopStmt(); // handle cond polyglot.ast.Expr condition = ifExpr.cond(); createBranchingExpr(condition, brchTgt, false); // add consequence polyglot.ast.Stmt consequence = ifExpr.consequent(); createStmt(consequence); soot.jimple.Stmt goto1 = soot.jimple.Jimple.v().newGotoStmt(endTgt); body.getUnits().add(goto1); body.getUnits().add(brchTgt); // handle alternative polyglot.ast.Stmt alternative = ifExpr.alternative(); if (alternative != null) { createStmt(alternative); } body.getUnits().add(endTgt); }
GotoStmt gotoStmt = Jimple.v().newGotoStmt(target); units.insertAfter(gotoStmt, predOfTarget);
private soot.Local handleCondBinExpr(soot.jimple.ConditionExpr condExpr) { soot.Local boolLocal = lg.generateLocal(soot.BooleanType.v()); soot.jimple.Stmt noop1 = soot.jimple.Jimple.v().newNopStmt(); soot.Value newVal; newVal = reverseCondition(condExpr); newVal = handleDFLCond((soot.jimple.ConditionExpr) newVal); soot.jimple.Stmt ifStmt = soot.jimple.Jimple.v().newIfStmt(newVal, noop1); body.getUnits().add(ifStmt); body.getUnits().add(soot.jimple.Jimple.v().newAssignStmt(boolLocal, soot.jimple.IntConstant.v(1))); soot.jimple.Stmt noop2 = soot.jimple.Jimple.v().newNopStmt(); soot.jimple.Stmt goto1 = soot.jimple.Jimple.v().newGotoStmt(noop2); body.getUnits().add(goto1); body.getUnits().add(noop1); body.getUnits().add(soot.jimple.Jimple.v().newAssignStmt(boolLocal, soot.jimple.IntConstant.v(0))); body.getUnits().add(noop2); return boolLocal; }
private soot.Local handleCondBinExpr(soot.jimple.ConditionExpr condExpr, boolean reverse) { soot.Local boolLocal = lg.generateLocal(soot.BooleanType.v()); soot.jimple.Stmt noop1 = soot.jimple.Jimple.v().newNopStmt(); soot.Value newVal = condExpr; if (reverse) { newVal = reverseCondition(condExpr); } newVal = handleDFLCond((soot.jimple.ConditionExpr) newVal); soot.jimple.Stmt ifStmt = soot.jimple.Jimple.v().newIfStmt(newVal, noop1); body.getUnits().add(ifStmt); body.getUnits().add(soot.jimple.Jimple.v().newAssignStmt(boolLocal, soot.jimple.IntConstant.v(1))); soot.jimple.Stmt noop2 = soot.jimple.Jimple.v().newNopStmt(); soot.jimple.Stmt goto1 = soot.jimple.Jimple.v().newGotoStmt(noop2); body.getUnits().add(goto1); body.getUnits().add(noop1); body.getUnits().add(soot.jimple.Jimple.v().newAssignStmt(boolLocal, soot.jimple.IntConstant.v(0))); body.getUnits().add(noop2); return boolLocal; }
soot.jimple.Stmt goto1 = soot.jimple.Jimple.v().newGotoStmt(noop2); body.getUnits().add(goto1);