public void put(RegisterSpec spec) {
    throwIfImmutable();

    if (spec == null) {
      throw new NullPointerException("spec == null");
    }

    size = -1;

    try {
      int reg = spec.getReg();
      specs[reg] = spec;

      if (reg > 0) {
        int prevReg = reg - 1;
        RegisterSpec prevSpec = specs[prevReg];
        if ((prevSpec != null) && (prevSpec.getCategory() == 2)) {
          specs[prevReg] = null;
        }
      }

      if (spec.getCategory() == 2) {
        specs[reg + 1] = null;
      }
    } catch (ArrayIndexOutOfBoundsException ex) {
      // Translate the exception.
      throw new IllegalArgumentException("spec.getReg() out of range");
    }
  }
Puts the given spec into the set. If there is already an element in the set with the same
register number, it is replaced. Additionally, if the previous element is for a category-2
register, then that previous element is nullified. Finally, if the given spec is for a
category-2 register, then the immediately subsequent element is nullified.

@param spec {@code non-null;} the register spec to put in the instance
android/android_framework/dex-maker/src/main/java/com/android/dx/rop/code/RegisterSpecSet.java