private int jopToRopOpcode(int jop, Constant cst) {
    switch (jop) {
      case ByteOps.POP:
      case ByteOps.POP2:
      case ByteOps.DUP:
      case ByteOps.DUP_X1:
      case ByteOps.DUP_X2:
      case ByteOps.DUP2:
      case ByteOps.DUP2_X1:
      case ByteOps.DUP2_X2:
      case ByteOps.SWAP:
      case ByteOps.JSR:
      case ByteOps.RET:
      case ByteOps.MULTIANEWARRAY:
        {
          // These need to be taken care of specially.
          break;
        }
      case ByteOps.NOP:
        {
          return RegOps.NOP;
        }
      case ByteOps.LDC:
      case ByteOps.LDC2_W:
        {
          return RegOps.CONST;
        }
      case ByteOps.ILOAD:
      case ByteOps.ISTORE:
        {
          return RegOps.MOVE;
        }
      case ByteOps.IALOAD:
        {
          return RegOps.AGET;
        }
      case ByteOps.IASTORE:
        {
          return RegOps.APUT;
        }
      case ByteOps.IADD:
      case ByteOps.IINC:
        {
          return RegOps.ADD;
        }
      case ByteOps.ISUB:
        {
          return RegOps.SUB;
        }
      case ByteOps.IMUL:
        {
          return RegOps.MUL;
        }
      case ByteOps.IDIV:
        {
          return RegOps.DIV;
        }
      case ByteOps.IREM:
        {
          return RegOps.REM;
        }
      case ByteOps.INEG:
        {
          return RegOps.NEG;
        }
      case ByteOps.ISHL:
        {
          return RegOps.SHL;
        }
      case ByteOps.ISHR:
        {
          return RegOps.SHR;
        }
      case ByteOps.IUSHR:
        {
          return RegOps.USHR;
        }
      case ByteOps.IAND:
        {
          return RegOps.AND;
        }
      case ByteOps.IOR:
        {
          return RegOps.OR;
        }
      case ByteOps.IXOR:
        {
          return RegOps.XOR;
        }
      case ByteOps.I2L:
      case ByteOps.I2F:
      case ByteOps.I2D:
      case ByteOps.L2I:
      case ByteOps.L2F:
      case ByteOps.L2D:
      case ByteOps.F2I:
      case ByteOps.F2L:
      case ByteOps.F2D:
      case ByteOps.D2I:
      case ByteOps.D2L:
      case ByteOps.D2F:
        {
          return RegOps.CONV;
        }
      case ByteOps.I2B:
        {
          return RegOps.TO_BYTE;
        }
      case ByteOps.I2C:
        {
          return RegOps.TO_CHAR;
        }
      case ByteOps.I2S:
        {
          return RegOps.TO_SHORT;
        }
      case ByteOps.LCMP:
      case ByteOps.FCMPL:
      case ByteOps.DCMPL:
        {
          return RegOps.CMPL;
        }
      case ByteOps.FCMPG:
      case ByteOps.DCMPG:
        {
          return RegOps.CMPG;
        }
      case ByteOps.IFEQ:
      case ByteOps.IF_ICMPEQ:
      case ByteOps.IF_ACMPEQ:
      case ByteOps.IFNULL:
        {
          return RegOps.IF_EQ;
        }
      case ByteOps.IFNE:
      case ByteOps.IF_ICMPNE:
      case ByteOps.IF_ACMPNE:
      case ByteOps.IFNONNULL:
        {
          return RegOps.IF_NE;
        }
      case ByteOps.IFLT:
      case ByteOps.IF_ICMPLT:
        {
          return RegOps.IF_LT;
        }
      case ByteOps.IFGE:
      case ByteOps.IF_ICMPGE:
        {
          return RegOps.IF_GE;
        }
      case ByteOps.IFGT:
      case ByteOps.IF_ICMPGT:
        {
          return RegOps.IF_GT;
        }
      case ByteOps.IFLE:
      case ByteOps.IF_ICMPLE:
        {
          return RegOps.IF_LE;
        }
      case ByteOps.GOTO:
        {
          return RegOps.GOTO;
        }
      case ByteOps.LOOKUPSWITCH:
        {
          return RegOps.SWITCH;
        }
      case ByteOps.IRETURN:
      case ByteOps.RETURN:
        {
          return RegOps.RETURN;
        }
      case ByteOps.GETSTATIC:
        {
          return RegOps.GET_STATIC;
        }
      case ByteOps.PUTSTATIC:
        {
          return RegOps.PUT_STATIC;
        }
      case ByteOps.GETFIELD:
        {
          return RegOps.GET_FIELD;
        }
      case ByteOps.PUTFIELD:
        {
          return RegOps.PUT_FIELD;
        }
      case ByteOps.INVOKEVIRTUAL:
        {
          CstMethodRef ref = (CstMethodRef) cst;
          // The java bytecode specification does not explicitly disallow
          // invokevirtual calls to any instance method, though it
          // specifies that instance methods and private methods "should" be
          // called using "invokespecial" instead of "invokevirtual".
          // Several bytecode tools generate "invokevirtual" instructions for
          // invocation of private methods.
          //
          // The dalvik opcode specification on the other hand allows
          // invoke-virtual to be used only with "normal" virtual methods,
          // i.e, ones that are not private, static, final or constructors.
          // We therefore need to transform invoke-virtual calls to private
          // instance methods to invoke-direct opcodes.
          //
          // Note that it assumes that all methods for a given class are
          // defined in the same dex file.
          //
          // NOTE: This is a slow O(n) loop, and can be replaced with a
          // faster implementation (at the cost of higher memory usage)
          // if it proves to be a hot area of code.
          if (ref.getDefiningClass().equals(method.getDefiningClass())) {
            for (int i = 0; i < methods.size(); ++i) {
              final Method m = methods.get(i);
              if (AccessFlags.isPrivate(m.getAccessFlags()) && ref.getNat().equals(m.getNat())) {
                return RegOps.INVOKE_DIRECT;
              }
            }
          }
          // If the method reference is a signature polymorphic method
          // substitute invoke-polymorphic for invoke-virtual. This only
          // affects MethodHandle.invoke and MethodHandle.invokeExact.
          if (ref.isSignaturePolymorphic()) {
            return RegOps.INVOKE_POLYMORPHIC;
          }
          return RegOps.INVOKE_VIRTUAL;
        }
      case ByteOps.INVOKESPECIAL:
        {
          /*
           * Determine whether the opcode should be
           * INVOKE_DIRECT or INVOKE_SUPER. See vmspec-2 section 6
           * on "invokespecial" as well as section 4.8.2 (7th
           * bullet point) for the gory details.
           */
          /* TODO: Consider checking that invoke-special target
           * method is private, or constructor since otherwise ART
           * verifier will reject it.
           */
          CstMethodRef ref = (CstMethodRef) cst;
          if (ref.isInstanceInit() || (ref.getDefiningClass().equals(method.getDefiningClass()))) {
            return RegOps.INVOKE_DIRECT;
          }
          return RegOps.INVOKE_SUPER;
        }
      case ByteOps.INVOKESTATIC:
        {
          return RegOps.INVOKE_STATIC;
        }
      case ByteOps.INVOKEINTERFACE:
        {
          return RegOps.INVOKE_INTERFACE;
        }
      case ByteOps.INVOKEDYNAMIC:
        {
          return RegOps.INVOKE_CUSTOM;
        }
      case ByteOps.NEW:
        {
          return RegOps.NEW_INSTANCE;
        }
      case ByteOps.NEWARRAY:
      case ByteOps.ANEWARRAY:
        {
          return RegOps.NEW_ARRAY;
        }
      case ByteOps.ARRAYLENGTH:
        {
          return RegOps.ARRAY_LENGTH;
        }
      case ByteOps.ATHROW:
        {
          return RegOps.THROW;
        }
      case ByteOps.CHECKCAST:
        {
          return RegOps.CHECK_CAST;
        }
      case ByteOps.INSTANCEOF:
        {
          return RegOps.INSTANCE_OF;
        }
      case ByteOps.MONITORENTER:
        {
          return RegOps.MONITOR_ENTER;
        }
      case ByteOps.MONITOREXIT:
        {
          return RegOps.MONITOR_EXIT;
        }
    }

    throw new RuntimeException("shouldn't happen");
  }
Gets the register opcode for the given Java opcode.

@param jop {@code jop >= 0;} the Java opcode
@param cst {@code null-ok;} the constant argument, if any
@return {@code >= 0;} the corresponding register opcode
android/android_framework/dex-maker/src/main/java/com/android/dx/cf/code/RopperMachine.java