private Instruction[] prepareIPCs(List<BasicBlock> list, CFG cfg) { // Set up IPCs List<Instruction> newInstrs = new ArrayList<Instruction>(); HashMap<Label, Integer> labelIPCMap = new HashMap<Label, Integer>(); int ipc = 0; for (BasicBlock basicBlock : list) { Label label = basicBlock.getLabel(); labelIPCMap.put(label, ipc); // This assumes if multiple equal/same labels exist which are scattered around the scope // must be the same Java instance or only this one will get a targetPC set. label.setTargetIPC(ipc); List<Instruction> bbInstrs = basicBlock.getInstructions(); int bbInstrsLength = bbInstrs.size(); for (int i = 0; i < bbInstrsLength; i++) { Instruction instr = bbInstrs.get(i); newInstrs.add(instr); instr.setIPC(ipc); ipc++; } } cfg.getExitBB().getLabel().setTargetIPC(ipc + 1); // Exit BasicBlock IPC setupRescueMap(list, cfg); // Set up the rescue map return newInstrs.toArray(new Instruction[newInstrs.size()]); }