public void redirectBranches(final InstructionHandle old_target, final InstructionHandle new_target) {
for (InstructionHandle ih = start; ih != null; ih = ih.getNext()) {
final Instruction i = ih.getInstruction();
if (i instanceof BranchInstruction) {
final BranchInstruction b = (BranchInstruction) i;
final InstructionHandle target = b.getTarget();
if (target == old_target) {
b.setTarget(new_target);
}
if (b instanceof Select) { // Either LOOKUPSWITCH or TABLESWITCH
final InstructionHandle[] targets = ((Select) b).getTargets();
for (int j = 0; j < targets.length; j++) {
if (targets[j] == old_target) {
((Select) b).setTarget(j, new_target);
}
}
}
}
}
}
|