private void readMethodBodies() throws IOException { int count = in.readVU30(); ABC.MethodBodies bodies = abcFile.methodBodies(count); for (int i = 0; i < count; i++) { int methodInfo = in.readVU30(); int maxStack = in.readVU30(); int maxRegs = in.readVU30(); int scopeDepth = in.readVU30(); int maxScope = in.readVU30(); ABC.MethodBody body = (bodies != null) ? bodies.methodBody(methodInfo, maxStack, maxRegs, scopeDepth, maxScope) : null; int codeLength = in.readVU30(); byte[] code = in.read(codeLength); List<Instruction> instructionList = new ArrayList<Instruction>(); Set<Integer> targetAddresses = new HashSet<Integer>(); // build the instruction list ABC.Instructions instrs = (body != null) ? body.instructions(codeLength) : null; if (instrs != null && !(instrs instanceof ABC.RawBytecode)) { InStream in = new InStream(code); while (in.getBytesRead() < codeLength) { Instruction instr = Instruction.parse(in); targetAddresses.addAll(instr.getTargetAddresses()); instructionList.add(instr); } } // gather the exception handlers int handlerCount = in.readVU30(); List<int[]> handlerList = new ArrayList<int[]>(); for (int j = 0; j < handlerCount; j++) { int start = in.readVU30(); int end = in.readVU30(); int target = in.readVU30(); int typeIndex = in.readVU30(); int nameIndex = in.readVU30(); handlerList.add(new int[] {start, end, target, typeIndex, nameIndex}); targetAddresses.add(start); targetAddresses.add(end); targetAddresses.add(target); } // pass the instructions if (instrs != null) { if (instrs instanceof ABC.RawBytecode) { instrs.bytecode(code); } else { for (Instruction in : instructionList) { // emit an address if the instruction is a target if (targetAddresses.contains(in.getOffset())) { instrs.target(in.getOffset()); } in.write(instrs); } } instrs.done(); } // pass the exception handlers ABC.ExceptionHandlers handlers = (body != null) ? body.exceptionHandlers(handlerCount) : null; if (handlers != null) { for (int[] handler : handlerList) { handlers.exceptionHandler(handler[0], handler[1], handler[2], handler[3], handler[4]); } handlers.done(); } int traitCount = in.readVU30(); ABC.Traits traits = (body != null) ? body.traits(traitCount) : null; readTraits(traitCount, traits); if (body != null) body.done(); } if (bodies != null) bodies.done(); }