Package com.android.dx.rop.code
Class RegisterSpecSet
java.lang.Object
com.android.dx.util.MutabilityControl
com.android.dx.rop.code.RegisterSpecSet
Set of
RegisterSpec
instances, where a given register number
may appear only once in the set.-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns the spec in this set that's currently associated with a given local (type, name, and signature), ornull
if there is none.get
(int reg) Gets the element with the given register number, if any.get
(RegisterSpec spec) Gets the element with the same register number as the given spec, if any.int
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.int
hashCode()
void
intersect
(RegisterSpecSet other, boolean localPrimary) Intersects this instance with the given one, modifying this instance.localItemToSpec
(LocalItem local) Returns the spec in this set that's currently associated with a given local (name and signature), ornull
if there is none.Makes and return a mutable copy of this instance.void
put
(RegisterSpec spec) Puts the given spec into the set.void
putAll
(RegisterSpecSet set) Put the entire contents of the given set into this one.void
remove
(RegisterSpec toRemove) Removes a spec from the set.int
size()
Gets the current size of this instance.toString()
withOffset
(int delta) Returns an instance that is identical to this one, except that all register numbers are offset by the given amount.Methods inherited from class com.android.dx.util.MutabilityControl
isImmutable, isMutable, setImmutable, throwIfImmutable, throwIfMutable
-
Field Details
-
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
-
hashCode
public int hashCode() -
toString
-
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
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 ornull
if there is none
-
get
Gets the element with the same register number as the given spec, if any. This is just a convenient shorthand forget(spec.getReg())
.- Parameters:
spec
-non-null;
spec with the desired register number- Returns:
null-ok;
the element with the matching register number ornull
if there is none
-
findMatchingLocal
Returns the spec in this set that's currently associated with a given local (type, name, and signature), ornull
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
Returns the spec in this set that's currently associated with a given local (name and signature), ornull
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
Removes a spec from the set. Only the register number of the parameter is significant.- Parameters:
toRemove
-non-null;
register to remove.
-
put
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
Put the entire contents of the given set into this one.- Parameters:
set
-non-null;
the set to put into this instance
-
intersect
Intersects this instance with the given one, modifying this instance. The intersection consists of the pairwiseRegisterSpec.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 withlocalPrimary
- whether local variables are primary to the intersection; iftrue
, then the only non-null result elements occur when registers being intersected have equal names (or both havenull
names)
-
withOffset
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
Makes and return a mutable copy of this instance.- Returns:
non-null;
the mutable copy
-