private RegisterSpecList getSources(int opcode, int stackPointer) {
    int count = argCount();

    if (count == 0) {
      // We get an easy out if there aren't any sources.
      return RegisterSpecList.EMPTY;
    }

    int localIndex = getLocalIndex();
    RegisterSpecList sources;

    if (localIndex >= 0) {
      // The instruction is operating on a local variable.
      sources = new RegisterSpecList(1);
      sources.set(0, RegisterSpec.make(localIndex, arg(0)));
    } else {
      sources = new RegisterSpecList(count);
      int regAt = stackPointer;
      for (int i = 0; i < count; i++) {
        RegisterSpec spec = RegisterSpec.make(regAt, arg(i));
        sources.set(i, spec);
        regAt += spec.getCategory();
      }

      switch (opcode) {
        case ByteOps.IASTORE:
          {
            /*
             * The Java argument order for array stores is
             * (array, index, value), but the rop argument
             * order is (value, array, index). The following
             * code gets the right arguments in the right
             * places.
             */
            if (count != 3) {
              throw new RuntimeException("shouldn't happen");
            }
            RegisterSpec array = sources.get(0);
            RegisterSpec index = sources.get(1);
            RegisterSpec value = sources.get(2);
            sources.set(0, value);
            sources.set(1, array);
            sources.set(2, index);
            break;
          }
        case ByteOps.PUTFIELD:
          {
            /*
             * Similar to above: The Java argument order for
             * putfield is (object, value), but the rop
             * argument order is (value, object).
             */
            if (count != 2) {
              throw new RuntimeException("shouldn't happen");
            }
            RegisterSpec obj = sources.get(0);
            RegisterSpec value = sources.get(1);
            sources.set(0, value);
            sources.set(1, obj);
            break;
          }
      }
    }

    sources.setImmutable();
    return sources;
  }
Helper for {@link #run}, which gets the list of sources for the. instruction.

@param opcode the opcode being translated
@param stackPointer {@code >= 0;} the stack pointer after the instruction's arguments have been
    popped
@return {@code non-null;} the sources
android/android_framework/dex-maker/src/main/java/com/android/dx/cf/code/RopperMachine.java