(List<BasicBlock> list, CFG cfg)
| 252 | } |
| 253 | |
| 254 | private Instruction[] prepareIPCs(List<BasicBlock> list, CFG cfg) { |
| 255 | // Set up IPCs |
| 256 | List<Instruction> newInstrs = new ArrayList<Instruction>(); |
| 257 | HashMap<Label, Integer> labelIPCMap = new HashMap<Label, Integer>(); |
| 258 | int ipc = 0; |
| 259 | for (BasicBlock basicBlock: list) { |
| 260 | Label label = basicBlock.getLabel(); |
| 261 | labelIPCMap.put(label, ipc); |
| 262 | // This assumes if multiple equal/same labels exist which are scattered around the scope |
| 263 | // must be the same Java instance or only this one will get a targetPC set. |
| 264 | label.setTargetIPC(ipc); |
| 265 | List<Instruction> bbInstrs = basicBlock.getInstructions(); |
| 266 | int bbInstrsLength = bbInstrs.size(); |
| 267 | for (int i = 0; i < bbInstrsLength; i++) { |
| 268 | Instruction instr = bbInstrs.get(i); |
| 269 | |
| 270 | newInstrs.add(instr); |
| 271 | instr.setIPC(ipc); |
| 272 | ipc++; |
| 273 | } |
| 274 | } |
| 275 | |
| 276 | cfg.getExitBB().getLabel().setTargetIPC(ipc + 1); // Exit BasicBlock IPC |
| 277 | |
| 278 | |
| 279 | setupRescueMap(list, cfg); // Set up the rescue map |
| 280 | |
| 281 | return newInstrs.toArray(new Instruction[newInstrs.size()]); |
| 282 | } |
| 283 | |
| 284 | public void setupRescueMap(List<BasicBlock> list, CFG cfg) { |
| 285 | rescueMap = new HashMap<Integer, Integer>(); |
no test coverage detected