public static Rop ropFor(int opcode, TypeBearer dest, TypeList sources, Constant cst) {
    switch (opcode) {
      case RegOps.NOP:
        return NOP;
      case RegOps.MOVE:
        return opMove(dest);
      case RegOps.MOVE_PARAM:
        return opMoveParam(dest);
      case RegOps.MOVE_EXCEPTION:
        return opMoveException(dest);
      case RegOps.CONST:
        return opConst(dest);
      case RegOps.GOTO:
        return GOTO;
      case RegOps.IF_EQ:
        return opIfEq(sources);
      case RegOps.IF_NE:
        return opIfNe(sources);
      case RegOps.IF_LT:
        return opIfLt(sources);
      case RegOps.IF_GE:
        return opIfGe(sources);
      case RegOps.IF_LE:
        return opIfLe(sources);
      case RegOps.IF_GT:
        return opIfGt(sources);
      case RegOps.SWITCH:
        return SWITCH;
      case RegOps.ADD:
        return opAdd(sources);
      case RegOps.SUB:
        return opSub(sources);
      case RegOps.MUL:
        return opMul(sources);
      case RegOps.DIV:
        return opDiv(sources);
      case RegOps.REM:
        return opRem(sources);
      case RegOps.NEG:
        return opNeg(dest);
      case RegOps.AND:
        return opAnd(sources);
      case RegOps.OR:
        return opOr(sources);
      case RegOps.XOR:
        return opXor(sources);
      case RegOps.SHL:
        return opShl(sources);
      case RegOps.SHR:
        return opShr(sources);
      case RegOps.USHR:
        return opUshr(sources);
      case RegOps.NOT:
        return opNot(dest);
      case RegOps.CMPL:
        return opCmpl(sources.getType(0));
      case RegOps.CMPG:
        return opCmpg(sources.getType(0));
      case RegOps.CONV:
        return opConv(dest, sources.getType(0));
      case RegOps.TO_BYTE:
        return TO_BYTE;
      case RegOps.TO_CHAR:
        return TO_CHAR;
      case RegOps.TO_SHORT:
        return TO_SHORT;
      case RegOps.RETURN:
        {
          if (sources.size() == 0) {
            return RETURN_VOID;
          }
          return opReturn(sources.getType(0));
        }
      case RegOps.ARRAY_LENGTH:
        return ARRAY_LENGTH;
      case RegOps.THROW:
        return THROW;
      case RegOps.MONITOR_ENTER:
        return MONITOR_ENTER;
      case RegOps.MONITOR_EXIT:
        return MONITOR_EXIT;
      case RegOps.AGET:
        {
          Type source = sources.getType(0);
          Type componentType;
          if (source == Type.KNOWN_NULL) {
            /*
             * Treat a known-null as an array of the expected
             * result type.
             */
            componentType = dest.getType();
          } else {
            componentType = source.getComponentType();
          }
          return opAget(componentType);
        }
      case RegOps.APUT:
        {
          Type source = sources.getType(1);
          Type componentType;
          if (source == Type.KNOWN_NULL) {
            /*
             * Treat a known-null as an array of the type being
             * stored.
             */
            componentType = sources.getType(0);
          } else {
            componentType = source.getComponentType();
          }
          return opAput(componentType);
        }
      case RegOps.NEW_INSTANCE:
        return NEW_INSTANCE;
      case RegOps.NEW_ARRAY:
        return opNewArray(dest.getType());
      case RegOps.CHECK_CAST:
        return CHECK_CAST;
      case RegOps.INSTANCE_OF:
        return INSTANCE_OF;
      case RegOps.GET_FIELD:
        return opGetField(dest);
      case RegOps.GET_STATIC:
        return opGetStatic(dest);
      case RegOps.PUT_FIELD:
        return opPutField(sources.getType(0));
      case RegOps.PUT_STATIC:
        return opPutStatic(sources.getType(0));
      case RegOps.INVOKE_STATIC:
        {
          return opInvokeStatic(((CstMethodRef) cst).getPrototype());
        }
      case RegOps.INVOKE_VIRTUAL:
        {
          CstBaseMethodRef cstMeth = (CstMethodRef) cst;
          Prototype meth = cstMeth.getPrototype();
          CstType definer = cstMeth.getDefiningClass();
          meth = meth.withFirstParameter(definer.getClassType());
          return opInvokeVirtual(meth);
        }
      case RegOps.INVOKE_SUPER:
        {
          CstBaseMethodRef cstMeth = (CstMethodRef) cst;
          Prototype meth = cstMeth.getPrototype();
          CstType definer = cstMeth.getDefiningClass();
          meth = meth.withFirstParameter(definer.getClassType());
          return opInvokeSuper(meth);
        }
      case RegOps.INVOKE_DIRECT:
        {
          CstBaseMethodRef cstMeth = (CstMethodRef) cst;
          Prototype meth = cstMeth.getPrototype();
          CstType definer = cstMeth.getDefiningClass();
          meth = meth.withFirstParameter(definer.getClassType());
          return opInvokeDirect(meth);
        }
      case RegOps.INVOKE_INTERFACE:
        {
          CstBaseMethodRef cstMeth = (CstMethodRef) cst;
          Prototype meth = cstMeth.getPrototype();
          CstType definer = cstMeth.getDefiningClass();
          meth = meth.withFirstParameter(definer.getClassType());
          return opInvokeInterface(meth);
        }
      case RegOps.INVOKE_POLYMORPHIC:
        {
          CstBaseMethodRef cstMeth = (CstMethodRef) cst;
          Prototype proto = cstMeth.getPrototype();
          CstType definer = cstMeth.getDefiningClass();
          Prototype meth = proto.withFirstParameter(definer.getClassType());
          return opInvokePolymorphic(meth);
        }
      case RegOps.INVOKE_CUSTOM:
        {
          CstCallSiteRef cstInvokeDynamicRef = (CstCallSiteRef) cst;
          Prototype proto = cstInvokeDynamicRef.getPrototype();
          return opInvokeCustom(proto);
        }
    }

    throw new RuntimeException("unknown opcode " + RegOps.opName(opcode));
  }
Returns the appropriate rop for the given opcode, destination, and sources. The result is
typically, but not necessarily, a shared instance.

<p><b>Note:</b> This method does not do complete error checking on its arguments, and so it may
return an instance which seemed "right enough" even though in actuality the passed arguments
don't quite match what is returned. TODO: Revisit this issue.

@param opcode the opcode
@param dest {@code non-null;} destination (result) type, or {@link Type#VOID} if none
@param sources {@code non-null;} list of source types
@param cst {@code null-ok;} associated constant, if any
@return {@code non-null;} an appropriate instance
android/android_framework/dex-maker/src/main/java/com/android/dx/rop/code/Rops.java