public static InstructionMethodItem makeInstructionFormatMethodItem( MethodDefinition methodDefinition, CodeItem codeItem, int codeAddress, Instruction instruction) { if (instruction instanceof OffsetInstruction) { return new OffsetInstructionFormatMethodItem( methodDefinition.getLabelCache(), codeItem, codeAddress, instruction); } switch (instruction.getFormat()) { case ArrayData: return new ArrayDataMethodItem( codeItem, codeAddress, (ArrayDataPseudoInstruction) instruction); case PackedSwitchData: return new PackedSwitchMethodItem( methodDefinition, codeItem, codeAddress, (PackedSwitchDataPseudoInstruction) instruction); case SparseSwitchData: return new SparseSwitchMethodItem( methodDefinition, codeItem, codeAddress, (SparseSwitchDataPseudoInstruction) instruction); case UnresolvedOdexInstruction: return new UnresolvedOdexInstructionMethodItem( codeItem, codeAddress, (UnresolvedOdexInstruction) instruction); default: return new InstructionMethodItem(codeItem, codeAddress, instruction); } }
private void updateInvokeType(Instruction inst, MethodIdItem newMethod) { int accessFlags = newMethod.getAccess(); int staticMask = AccessFlags.STATIC.getValue(); int privateMask = AccessFlags.PRIVATE.getValue(); int finalMask = AccessFlags.FINAL.getValue(); int constructorMask = AccessFlags.CONSTRUCTOR.getValue(); int directMask = privateMask | finalMask | constructorMask; if ((accessFlags & staticMask) != 0) { if (inst instanceof Instruction35c) { inst.opcode = Opcode.INVOKE_STATIC; } else if (inst instanceof Instruction3rc) { inst.opcode = Opcode.INVOKE_STATIC_RANGE; } } else if ((accessFlags & directMask) != 0) { if (inst instanceof Instruction35c) { inst.opcode = Opcode.INVOKE_DIRECT; } else if (inst instanceof Instruction3rc) { inst.opcode = Opcode.INVOKE_DIRECT_RANGE; } } else { if (inst instanceof Instruction35c) { inst.opcode = Opcode.INVOKE_VIRTUAL; } else if (inst instanceof Instruction3rc) { inst.opcode = Opcode.INVOKE_VIRTUAL_RANGE; } } }