public final void changeOneSource(int index, RegisterSpec newSpec) {
    RegisterSpecList origSources = insn.getSources();
    int sz = origSources.size();
    RegisterSpecList newSources = new RegisterSpecList(sz);

    for (int i = 0; i < sz; i++) {
      newSources.set(i, i == index ? newSpec : origSources.get(i));
    }

    newSources.setImmutable();

    RegisterSpec origSpec = origSources.get(index);
    if (origSpec.getReg() != newSpec.getReg()) {
      /*
       * If the register remains unchanged, we're only changing
       * the type or local var name so don't update use list
       */
      getBlock().getParent().onSourceChanged(this, origSpec, newSpec);
    }

    insn = insn.withNewRegisters(getResult(), newSources);
  }
Changes one of the insn's sources. New source should be of same type and category.

@param index {@code >=0;} index of source to change
@param newSpec spec for new source
android/android_framework/dex-maker/src/main/java/com/android/dx/ssa/NormalSsaInsn.java