Package com.android.dx.rop.code
Class BasicBlock
java.lang.Object
com.android.dx.rop.code.BasicBlock
- All Implemented Interfaces:
LabeledItem
Basic block of register-based instructions.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
BasicBlock visitor interface -
Constructor Summary
ConstructorDescriptionBasicBlock
(int label, InsnList insns, IntList successors, int primarySuccessor) Constructs an instance. -
Method Summary
Modifier and TypeMethodDescriptionboolean
canThrow()
Returns whether this block might throw an exception.boolean
Instances of this class compare by identity.Returns the exception handler types associated with this block, if any.Gets the first instruction of this block.getInsns()
Gets the list of instructions inside this block.int
getLabel()
Gets the target label of this block.Gets the last instruction of this block.int
Gets the primary successor of this block.int
Gets the secondary successor of this block.Gets the list of successors that this block may branch to.boolean
Returns whether this block has any associated exception handlers.int
hashCode()
Return the identity hashcode of this instance.toString()
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.
-
Constructor Details
-
BasicBlock
Constructs an instance. The predecessor set is set tonull
.- Parameters:
label
->= 0;
target label for this blockinsns
-non-null;
list of instructions in this blocksuccessors
-non-null;
full list of successors that this block may branch toprimarySuccessor
->= -1;
the primary / standard-flow / "default" successor, or-1
if this block has no successors (that is, it exits the function/method or is an unconditional throw)
-
-
Method Details
-
equals
Instances of this class compare by identity. That is,x.equals(y)
is only true ifx == y
. -
hashCode
public int hashCode()Return the identity hashcode of this instance. This is proper, since instances of this class compare by identity (seeequals(java.lang.Object)
). -
getLabel
public int getLabel()Gets the target label of this block.- Specified by:
getLabel
in interfaceLabeledItem
- Returns:
>= 0;
the label
-
getInsns
Gets the list of instructions inside this block.- Returns:
non-null;
the instruction list
-
getSuccessors
Gets the list of successors that this block may branch to.- Returns:
non-null;
the successors list
-
getPrimarySuccessor
public int getPrimarySuccessor()Gets the primary successor of this block.- Returns:
>= -1;
the primary successor, or-1
if this block has no successors at all
-
getSecondarySuccessor
public int getSecondarySuccessor()Gets the secondary successor of this block. It is only valid to call this method on blocks that have exactly two successors.- Returns:
>= 0;
the secondary successor
-
getFirstInsn
Gets the first instruction of this block. This is just a convenient shorthand forgetInsns().get(0)
.- Returns:
non-null;
the first instruction
-
getLastInsn
Gets the last instruction of this block. This is just a convenient shorthand forgetInsns().getLast()
.- Returns:
non-null;
the last instruction
-
canThrow
public boolean canThrow()Returns whether this block might throw an exception. This is just a convenient shorthand forgetLastInsn().canThrow()
.- Returns:
true
iff this block might throw an exception
-
hasExceptionHandlers
public boolean hasExceptionHandlers()Returns whether this block has any associated exception handlers. This is just a shorthand for inspecting the last instruction in the block to see if it could throw, and if so, whether it in fact has any associated handlers.- Returns:
true
iff this block has any associated exception handlers
-
getExceptionHandlerTypes
Returns the exception handler types associated with this block, if any. This is just a shorthand for inspecting the last instruction in the block to see if it could throw, and if so, grabbing the catch list out of it. If not, this returns an empty list (notnull
).- Returns:
non-null;
the exception handler types associated with this block
-
withRegisterOffset
Returns an instance that is identical to this one, except that the registers in each instruction are offset by the given amount.- Parameters:
delta
- the amount to offset register numbers by- Returns:
non-null;
an appropriately-constructed instance
-
toString
-