Class RegisterSpecSet

java.lang.Object
com.android.dx.util.MutabilityControl
com.android.dx.rop.code.RegisterSpecSet

public final class RegisterSpecSet extends MutabilityControl
Set of RegisterSpec instances, where a given register number may appear only once in the set.
  • Field Details

    • EMPTY

      public static final RegisterSpecSet EMPTY
      non-null; no-element instance
  • Constructor Details

    • RegisterSpecSet

      public RegisterSpecSet(int maxSize)
      Constructs an instance. The instance is initially empty.
      Parameters:
      maxSize - >= 0; the maximum register number (exclusive) that may be represented in this instance
  • Method Details

    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getMaxSize

      public int getMaxSize()
      Gets the maximum number of registers that may be in this instance, which is also the maximum-plus-one of register numbers that may be represented.
      Returns:
      >= 0; the maximum size
    • size

      public int size()
      Gets the current size of this instance.
      Returns:
      >= 0; the size
    • get

      public RegisterSpec get(int reg)
      Gets the element with the given register number, if any.
      Parameters:
      reg - >= 0; the desired register number
      Returns:
      null-ok; the element with the given register number or null if there is none
    • get

      public RegisterSpec get(RegisterSpec spec)
      Gets the element with the same register number as the given spec, if any. This is just a convenient shorthand for get(spec.getReg()).
      Parameters:
      spec - non-null; spec with the desired register number
      Returns:
      null-ok; the element with the matching register number or null if there is none
    • findMatchingLocal

      public RegisterSpec findMatchingLocal(RegisterSpec spec)
      Returns the spec in this set that's currently associated with a given local (type, name, and signature), or null if there is none. This ignores the register number of the given spec but matches on everything else.
      Parameters:
      spec - non-null; local to look for
      Returns:
      null-ok; first register found that matches, if any
    • localItemToSpec

      public RegisterSpec localItemToSpec(LocalItem local)
      Returns the spec in this set that's currently associated with a given local (name and signature), or null if there is none.
      Parameters:
      local - non-null; local item to search for
      Returns:
      null-ok; first register found with matching name and signature
    • remove

      public void remove(RegisterSpec toRemove)
      Removes a spec from the set. Only the register number of the parameter is significant.
      Parameters:
      toRemove - non-null; register to remove.
    • put

      public void put(RegisterSpec spec)
      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.
      Parameters:
      spec - non-null; the register spec to put in the instance
    • putAll

      public void putAll(RegisterSpecSet set)
      Put the entire contents of the given set into this one.
      Parameters:
      set - non-null; the set to put into this instance
    • intersect

      public void intersect(RegisterSpecSet other, boolean localPrimary)
      Intersects this instance with the given one, modifying this instance. The intersection consists of the pairwise RegisterSpec.intersect(com.android.dx.rop.code.RegisterSpec, boolean) of corresponding elements from this instance and the given one where both are non-null.
      Parameters:
      other - non-null; set to intersect with
      localPrimary - whether local variables are primary to the intersection; if true, then the only non-null result elements occur when registers being intersected have equal names (or both have null names)
    • withOffset

      public RegisterSpecSet withOffset(int delta)
      Returns an instance that is identical to this one, except that all register numbers are offset by the given amount. Mutability of the result is inherited from the original.
      Parameters:
      delta - the amount to offset the register numbers by
      Returns:
      non-null; an appropriately-constructed instance
    • mutableCopy

      public RegisterSpecSet mutableCopy()
      Makes and return a mutable copy of this instance.
      Returns:
      non-null; the mutable copy