@Override public void redirectJumpsToThisTo(Unit newLocation) { List<UnitBox> boxesPointing = getBoxesPointingToThis(); UnitBox[] boxes = boxesPointing.toArray(new UnitBox[boxesPointing.size()]); // important to change this to an array to have a static copy for (UnitBox element : boxes) { UnitBox box = element; if (box.getUnit() != this) { throw new RuntimeException("Something weird's happening"); } if (box.isBranchTarget()) { box.setUnit(newLocation); } } } }
/** * takes <code>node</code> and redirects all branches to <code>oldTarget</code> to <code>newTarget</code>. * * @param node * the Unit where we redirect * @param oldTarget * @param newTarget */ private static void redirectBranch(Unit node, Unit oldTarget, Unit newTarget) { for (UnitBox targetBox : node.getUnitBoxes()) { Unit target = targetBox.getUnit(); if (target == oldTarget) { targetBox.setUnit(newTarget); } } }
final public void setTargets(Unit[] targets) { for (int i = 0; i < targets.length; i++) { targetBoxes[i].setUnit(targets[i]); } }
@Override final public Unit getDefaultTarget() { return defaultTargetBox.getUnit(); }
Unit stmt = box.getUnit(); if (box.isBranchTarget()) { labelStmts.add(stmt); } else {
public void toString(UnitPrinter up) { up.literal(Jimple.GOTO); up.literal(" "); targetBox.toString(up); }
if (boxesToTrack != null) { for (UnitBox boxToTrack : boxesToTrack) { if (!boxToTrack.isBranchTarget()) { trackedPhiToBoxes.put(boxToPhiNode.get(boxToTrack), boxToTrack);
List<UnitBox> boxes = point_src.getUnitBoxes(); for (UnitBox box : boxes) { if (box.getUnit() == point_tgt) { box.setUnit(toInsert.iterator().next()); if (box.getUnit() == point_tgt) { box.setUnit(toInsert.iterator().next()); innerChain.insertAfter(toInsert, point_src); box.setUnit(toInsert.iterator().next()); if (succ.getUnitBoxes().get(0).getUnit() == point_tgt) {
@Override final public void setDefaultTarget(Unit defaultTarget) { defaultTargetBox.setUnit(defaultTarget); }
@Override final public Unit getTarget(int index) { return targetBoxes[index].getUnit(); }
if (!pointer.isBranchTarget()) { break; if (remove.equals(targetBox.getUnit())) { if (targetBox.isBranchTarget()) { preds.add(unit); } else {
private void printCaseTarget(UnitPrinter up, int targetIndex) { up.literal(" case "); up.literal(new Integer(targetIndex).toString()); up.literal(": goto "); targetBoxes[targetIndex - lowIndex].toString(up); up.literal(";"); up.newline(); }
/** * Redirects PhiExpr pointers to the given Unit to the new Unit. * * <p> * Normally you should not have to call this function directly, since patching is taken care of Shimple's internal * implementation of PatchingChain. **/ public static void redirectPointers(Unit oldLocation, Unit newLocation) { List<UnitBox> boxesPointing = oldLocation.getBoxesPointingToThis(); // important to change this to an array to have a static copy UnitBox[] boxes = boxesPointing.toArray(new UnitBox[boxesPointing.size()]); for (UnitBox box : boxes) { if (box.getUnit() != oldLocation) { throw new RuntimeException("Something weird's happening"); } if (!box.isBranchTarget()) { box.setUnit(newLocation); } } } }
@Override public void setTarget(Unit target) { targetBox.setUnit(target); }
@Override public Stmt getTarget() { return (Stmt) targetBox.getUnit(); }
if (ub.getUnit() != unit) { throw new RuntimeException("Assertion failed."); if (ub.isBranchTarget()) { continue;
public void toString(UnitPrinter up) { up.literal(getName()); up.literal(" "); targetBox.toString(up); }
public void redirectJumpsToThisTo(Unit newLocation) { List boxesPointing = this.getBoxesPointingToThis(); Object[] boxes = boxesPointing.toArray(); // important to change this to an array to have a static copy for (Object element : boxes) { UnitBox box = (UnitBox) element; if(box.getUnit() != this) throw new RuntimeException("Something weird's happening"); if(box.isBranchTarget()) box.setUnit(newLocation); } } }