@Override public DecodedInstruction withProtoIndex(int newIndex, int newProtoIndex) { return new InvokePolymorphicDecodedInstruction( getFormat(), getOpcode(), newIndex, getIndexType(), newProtoIndex, registers); }
@Override public void encode(DecodedInstruction insn, CodeOutput out) { InvokePolymorphicDecodedInstruction polyInsn = (InvokePolymorphicDecodedInstruction) insn; out.write(codeUnit(polyInsn.getOpcode(), makeByte(polyInsn.getG(), polyInsn.getRegisterCount())), polyInsn.getIndexUnit(), codeUnit(polyInsn.getC(), polyInsn.getD(), polyInsn.getE(), polyInsn.getF()), polyInsn.getProtoIndex()); } },
@Override public DecodedInstruction decode(int opcodeUnit, CodeInput in) throws EOFException { int opcode = byte0(opcodeUnit); if (opcode != Opcodes.INVOKE_POLYMORPHIC) { // 45cc isn't currently used for anything other than invoke-polymorphic. // If that changes, add a more general DecodedInstruction for this format. throw new UnsupportedOperationException(String.valueOf(opcode)); } int g = nibble2(opcodeUnit); int registerCount = nibble3(opcodeUnit); int methodIndex = in.read(); int cdef = in.read(); int c = nibble0(cdef); int d = nibble1(cdef); int e = nibble2(cdef); int f = nibble3(cdef); int protoIndex = in.read(); IndexType indexType = OpcodeInfo.getIndexType(opcode); if (registerCount < 1 || registerCount > 5) { throw new DexException("bogus registerCount: " + Hex.uNibble(registerCount)); } int[] registers = {c, d, e, f, g}; registers = Arrays.copyOfRange(registers, 0, registerCount); return new InvokePolymorphicDecodedInstruction( this, opcode, methodIndex, indexType, protoIndex, registers); }