Package com.android.dx.rop.code
Class RegisterSpecList
java.lang.Object
com.android.dx.util.MutabilityControl
com.android.dx.util.FixedSizeList
com.android.dx.rop.code.RegisterSpecList
List of
RegisterSpec
instances.-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionget
(int n) Gets the indicated element.int
Gets the minimum required register count implied by this instance.getType
(int n) Gets the indicated element.int
Gets the number of 32-bit words required to hold instances of all the elements of this list.int
indexOfRegister
(int reg) Returns the index of a RegisterSpec in this list that uses the specified register, or -1 if none in this list uses the register.static RegisterSpecList
make
(RegisterSpec spec) Makes a single-element instance.static RegisterSpecList
make
(RegisterSpec spec0, RegisterSpec spec1) Makes a two-element instance.static RegisterSpecList
make
(RegisterSpec spec0, RegisterSpec spec1, RegisterSpec spec2) Makes a three-element instance.static RegisterSpecList
make
(RegisterSpec spec0, RegisterSpec spec1, RegisterSpec spec2, RegisterSpec spec3) Makes a four-element instance.void
set
(int n, RegisterSpec spec) Sets the element at the given index.specForRegister
(int reg) Returns a RegisterSpec in this list that uses the specified register, or null if there is none in this list.Returns a new instance, which contains a subset of the elements specified by the given BitSet.withAddedType
(Type type) Returns a new instance which is identical to this one, except that the given item is appended to the end and it is guaranteed to be immutable.withExpandedRegisters
(int base, boolean duplicateFirst, BitSet compatRegs) Returns an instance that is identical to this one, except that all incompatible register numbers are renumbered sequentially from the given base, with the first number duplicated if indicated.withFirst
(RegisterSpec spec) Returns a new instance, which is the same as this instance, except that it has an additional element prepended to the original.withOffset
(int delta) Returns an instance that is identical to this one, except that all register numbers are offset by the given amount.Returns a new instance, which is the same as this instance, except that its first element is removed.Returns a new instance, which is the same as this instance, except that its last element is removed.Methods inherited from class com.android.dx.util.FixedSizeList
equals, get0, getOrNull0, hashCode, set0, shrinkToFit, size, toHuman, toHuman, toString, toString
Methods inherited from class com.android.dx.util.MutabilityControl
isImmutable, isMutable, setImmutable, throwIfImmutable, throwIfMutable
-
Field Details
-
EMPTY
non-null;
no-element instance
-
-
Constructor Details
-
RegisterSpecList
public RegisterSpecList(int size) Constructs an instance. All indices initially containnull
.- Parameters:
size
- the size of the list
-
-
Method Details
-
make
Makes a single-element instance.- Parameters:
spec
-non-null;
the element- Returns:
non-null;
an appropriately-constructed instance
-
make
Makes a two-element instance.- Parameters:
spec0
-non-null;
the first elementspec1
-non-null;
the second element- Returns:
non-null;
an appropriately-constructed instance
-
make
Makes a three-element instance.- Parameters:
spec0
-non-null;
the first elementspec1
-non-null;
the second elementspec2
-non-null;
the third element- Returns:
non-null;
an appropriately-constructed instance
-
make
public static RegisterSpecList make(RegisterSpec spec0, RegisterSpec spec1, RegisterSpec spec2, RegisterSpec spec3) Makes a four-element instance.- Parameters:
spec0
-non-null;
the first elementspec1
-non-null;
the second elementspec2
-non-null;
the third elementspec3
-non-null;
the fourth element- Returns:
non-null;
an appropriately-constructed instance
-
getType
Gets the indicated element. It is an error to call this with the index for an element which was never set; if you do that, this will throwNullPointerException
. -
getWordCount
public int getWordCount()Gets the number of 32-bit words required to hold instances of all the elements of this list. This is a sum of the widths (categories) of all the elements.- Specified by:
getWordCount
in interfaceTypeList
- Returns:
>= 0;
the required number of words
-
withAddedType
Returns a new instance which is identical to this one, except that the given item is appended to the end and it is guaranteed to be immutable.- Specified by:
withAddedType
in interfaceTypeList
- Parameters:
type
-non-null;
item to append- Returns:
non-null;
an appropriately-constructed instance
-
get
Gets the indicated element. It is an error to call this with the index for an element which was never set; if you do that, this will throwNullPointerException
.- Parameters:
n
->= 0, < size();
which element- Returns:
non-null;
the indicated element
-
specForRegister
Returns a RegisterSpec in this list that uses the specified register, or null if there is none in this list.- Parameters:
reg
- Register to find- Returns:
- RegisterSpec that uses argument or null.
-
indexOfRegister
public int indexOfRegister(int reg) Returns the index of a RegisterSpec in this list that uses the specified register, or -1 if none in this list uses the register.- Parameters:
reg
- Register to find- Returns:
- index of RegisterSpec or -1
-
set
Sets the element at the given index.- Parameters:
n
->= 0, < size();
which elementspec
-non-null;
the value to store
-
getRegistersSize
public int getRegistersSize()Gets the minimum required register count implied by this instance. This is equal to the highest register number referred to plus the widest width (largest category) of the type used in that register.- Returns:
>= 0;
the required registers size
-
withFirst
Returns a new instance, which is the same as this instance, except that it has an additional element prepended to the original. Mutability of the result is inherited from the original.- Parameters:
spec
-non-null;
the new first spec (to prepend)- Returns:
non-null;
an appropriately-constructed instance
-
withoutFirst
Returns a new instance, which is the same as this instance, except that its first element is removed. Mutability of the result is inherited from the original.- Returns:
non-null;
an appropriately-constructed instance
-
withoutLast
Returns a new instance, which is the same as this instance, except that its last element is removed. Mutability of the result is inherited from the original.- Returns:
non-null;
an appropriately-constructed instance
-
subset
Returns a new instance, which contains a subset of the elements specified by the given BitSet. Indexes in the BitSet with a zero are included, while indexes with a one are excluded. Mutability of the result is inherited from the original.- Parameters:
exclusionSet
-non-null;
set of registers to exclude- Returns:
non-null;
an appropriately-constructed instance
-
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
-
withExpandedRegisters
Returns an instance that is identical to this one, except that all incompatible register numbers are renumbered sequentially from the given base, with the first number duplicated if indicated. If a null BitSet is given, it indicates all registers are incompatible.- Parameters:
base
- the base register numberduplicateFirst
- whether to duplicate the first numbercompatRegs
-null-ok;
either anon-null
set of compatible registers, ornull
to indicate all registers are incompatible- Returns:
non-null;
an appropriately-constructed instance
-