Class BasicBlock

java.lang.Object
com.android.dx.rop.code.BasicBlock
All Implemented Interfaces:
LabeledItem

public final class BasicBlock extends Object implements LabeledItem
Basic block of register-based instructions.
  • Constructor Details

    • BasicBlock

      public BasicBlock(int label, InsnList insns, IntList successors, int primarySuccessor)
      Constructs an instance. The predecessor set is set to null.
      Parameters:
      label - >= 0; target label for this block
      insns - non-null; list of instructions in this block
      successors - non-null; full list of successors that this block may branch to
      primarySuccessor - >= -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

      public boolean equals(Object other)
      Instances of this class compare by identity. That is, x.equals(y) is only true if x == y.
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Return the identity hashcode of this instance. This is proper, since instances of this class compare by identity (see equals(java.lang.Object)).
      Overrides:
      hashCode in class Object
    • getLabel

      public int getLabel()
      Gets the target label of this block.
      Specified by:
      getLabel in interface LabeledItem
      Returns:
      >= 0; the label
    • getInsns

      public InsnList getInsns()
      Gets the list of instructions inside this block.
      Returns:
      non-null; the instruction list
    • getSuccessors

      public IntList 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

      public Insn getFirstInsn()
      Gets the first instruction of this block. This is just a convenient shorthand for getInsns().get(0).
      Returns:
      non-null; the first instruction
    • getLastInsn

      public Insn getLastInsn()
      Gets the last instruction of this block. This is just a convenient shorthand for getInsns().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 for getLastInsn().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

      public TypeList 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 (not null).
      Returns:
      non-null; the exception handler types associated with this block
    • withRegisterOffset

      public BasicBlock 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.
      Parameters:
      delta - the amount to offset register numbers by
      Returns:
      non-null; an appropriately-constructed instance
    • toString

      public String toString()
      Overrides:
      toString in class Object