Package com.android.dx.rop.code
Class BasicBlockList
java.lang.Object
com.android.dx.util.MutabilityControl
com.android.dx.util.FixedSizeList
com.android.dx.util.LabeledList
com.android.dx.rop.code.BasicBlockList
- All Implemented Interfaces:
ToHuman
List of
BasicBlock
instances.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
catchesEqual
(BasicBlock block1, BasicBlock block2) Compares the catches of two blocks for equality.void
forEachInsn
(Insn.Visitor visitor) Visits each instruction of each block in the list, in order.get
(int n) Gets the element at the given index.int
Gets the total instruction count for this instance, ignoring mark-local instructions which are not actually emitted.int
Gets the total instruction count for this instance.Returns a mutable copy of this list.int
Returns how many registers this method requires.labelToBlock
(int label) Gets the first block in the list with the given label, if any.preferredSuccessorOf
(BasicBlock block) Gets the preferred successor for the given block.void
set
(int n, BasicBlock bb) Sets the basic block at the given index.withRegisterOffset
(int delta) Returns an instance that is identical to this one, except that the registers in each instruction are offset by the given amount.Methods inherited from class com.android.dx.util.LabeledList
getLabelsInOrder, getMaxLabel, indexOfLabel, set, shrinkToFit
Methods inherited from class com.android.dx.util.FixedSizeList
equals, get0, getOrNull0, hashCode, set0, size, toHuman, toHuman, toString, toString
Methods inherited from class com.android.dx.util.MutabilityControl
isImmutable, isMutable, setImmutable, throwIfImmutable, throwIfMutable
-
Constructor Details
-
BasicBlockList
public BasicBlockList(int size) Constructs an instance. All indices initially containnull
, and the first-block label is initially-1
.- Parameters:
size
- the size of the list
-
-
Method Details
-
get
Gets the element at the given index. 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 index- Returns:
non-null;
element at that index
-
set
Sets the basic block at the given index.- Parameters:
n
->= 0, < size();
which indexbb
-null-ok;
the element to set atn
-
getRegCount
public int getRegCount()Returns how many registers this method requires. This is simply the maximum of register-number-plus-category referred to by this instance's instructions (indirectly throughBasicBlock
instances).- Returns:
>= 0;
the register count
-
getInstructionCount
public int getInstructionCount()Gets the total instruction count for this instance. This is the sum of the instruction counts of each block.- Returns:
>= 0;
the total instruction count
-
getEffectiveInstructionCount
public int getEffectiveInstructionCount()Gets the total instruction count for this instance, ignoring mark-local instructions which are not actually emitted.- Returns:
>= 0;
the total instruction count
-
labelToBlock
Gets the first block in the list with the given label, if any.- Parameters:
label
-label >= 0;
the label to look for- Returns:
non-null;
the so-labelled block- Throws:
IllegalArgumentException
- thrown if the label isn't found
-
forEachInsn
Visits each instruction of each block in the list, in order.- Parameters:
visitor
-non-null;
visitor to use
-
withRegisterOffset
Returns an instance that is identical to this one, except that the registers in each instruction are offset by the given amount. Mutability of the result is inherited from the original.- Parameters:
delta
- the amount to offset register numbers by- Returns:
non-null;
an appropriately-constructed instance
-
getMutableCopy
Returns a mutable copy of this list.- Returns:
non-null;
an appropriately-constructed instance
-
preferredSuccessorOf
Gets the preferred successor for the given block. If the block only has one successor, then that is the preferred successor. Otherwise, if the block has a primay successor, then that is the preferred successor. If the block has no successors, then this returnsnull
.- Parameters:
block
-non-null;
the block in question- Returns:
null-ok;
the preferred successor, if any
-
catchesEqual
Compares the catches of two blocks for equality. This includes both the catch types and target labels.- Parameters:
block1
-non-null;
one block to compareblock2
-non-null;
the other block to compare- Returns:
true
if the two blocks' non-primary successors are identical
-