Top Description Inners Fields Constructors Methods
org.droidparts.dexmaker.dx.rop.code

public final Class BasicBlock

extends Object
implements LabeledItem
Class Inheritance
All Implemented Interfaces
org.droidparts.dexmaker.dx.util.LabeledItem
Imports
org.droidparts.dexmaker.dx.rop.type.TypeList, org.droidparts.dexmaker.dx.util.Hex, .IntList, .LabeledItem

Basic block of register-based instructions.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
BasicBlock.Visitor

BasicBlock visitor interface

Field Summary

Modifier and TypeField and Description
private final InsnList
insns

non-null; list of instructions in this block

private final int
label

>= 0; target label for this block

private final int
primarySuccessor

>= -1; the primary / standard-flow / "default" successor, or -1 if this block has no successors (that is, it exits the function/method)

private final IntList
successors

non-null; full list of successors that this block may branch to

Constructor Summary

AccessConstructor and Description
public
BasicBlock(int
>= 0; target label for this block
label
,
InsnList
non-null; list of instructions in this block
insns
,
IntList
non-null; full list of successors that this block may branch to
successors
,
int
>= -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)
primarySuccessor
)

Constructs an instance.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true iff this block might throw an exception
canThrow
()

Returns whether this block might throw an exception.

public boolean
equals(Object
the reference object with which to compare.
other
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public TypeList

Returns:

non-null; the exception handler types associated with this block
getExceptionHandlerTypes
()

Returns the exception handler types associated with this block, if any.

public Insn

Returns:

non-null; the first instruction
getFirstInsn
()

Gets the first instruction of this block.

public InsnList

Returns:

non-null; the instruction list
getInsns
()

Gets the list of instructions inside this block.

public int

Returns:

>= 0; the label
getLabel
()

Implements org.droidparts.dexmaker.dx.util.LabeledItem.getLabel.

Gets the target label of this block.
public Insn

Returns:

non-null; the last instruction
getLastInsn
()

Gets the last instruction of this block.

public int

Returns:

>= -1; the primary successor, or -1 if this block has no successors at all
getPrimarySuccessor
()

Gets the primary successor of this block.

public int

Returns:

>= 0; the secondary successor
getSecondarySuccessor
()

Gets the secondary successor of this block.

public IntList

Returns:

non-null; the successors list
getSuccessors
()

Gets the list of successors that this block may branch to.

public boolean

Returns:

true iff this block has any associated exception handlers
hasExceptionHandlers
()

Returns whether this block has any associated exception handlers.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public BasicBlock

Returns:

non-null; an appropriately-constructed instance
withRegisterOffset
(int
the amount to offset register numbers by
delta
)

Returns an instance that is identical to this one, except that the registers in each instruction are offset by the given amount.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

insnsback to summary
private final InsnList insns

non-null; list of instructions in this block

labelback to summary
private final int label

>= 0; target label for this block

primarySuccessorback to summary
private final int primarySuccessor

>= -1; the primary / standard-flow / "default" successor, or -1 if this block has no successors (that is, it exits the function/method)

successorsback to summary
private final IntList successors

non-null; full list of successors that this block may branch to

Constructor Detail

BasicBlockback to summary
public BasicBlock(int label, InsnList insns, IntList successors, int primarySuccessor)

Constructs an instance. The predecessor set is set to null.

Parameters
label:int

>= 0; target label for this block

insns:InsnList

non-null; list of instructions in this block

successors:IntList

non-null; full list of successors that this block may branch to

primarySuccessor:int

>= -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 Detail

canThrowback to summary
public boolean canThrow()

Returns whether this block might throw an exception. This is just a convenient shorthand for getLastInsn().canThrow().

Returns:boolean

true iff this block might throw an exception

equalsback to summary
public boolean equals(Object other)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes. Instances of this class compare by identity. That is, x.equals(y) is only true if x == y.

Parameters
other:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getExceptionHandlerTypesback to summary
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:TypeList

non-null; the exception handler types associated with this block

getFirstInsnback to summary
public Insn getFirstInsn()

Gets the first instruction of this block. This is just a convenient shorthand for getInsns().get(0).

Returns:Insn

non-null; the first instruction

getInsnsback to summary
public InsnList getInsns()

Gets the list of instructions inside this block.

Returns:InsnList

non-null; the instruction list

getLabelback to summary
public int getLabel()

Implements org.droidparts.dexmaker.dx.util.LabeledItem.getLabel.

Gets the target label of this block.

Returns:int

>= 0; the label

getLastInsnback to summary
public Insn getLastInsn()

Gets the last instruction of this block. This is just a convenient shorthand for getInsns().getLast().

Returns:Insn

non-null; the last instruction

getPrimarySuccessorback to summary
public int getPrimarySuccessor()

Gets the primary successor of this block.

Returns:int

>= -1; the primary successor, or -1 if this block has no successors at all

getSecondarySuccessorback to summary
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:int

>= 0; the secondary successor

getSuccessorsback to summary
public IntList getSuccessors()

Gets the list of successors that this block may branch to.

Returns:IntList

non-null; the successors list

hasExceptionHandlersback to summary
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:boolean

true iff this block has any associated exception handlers

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Return the identity hashcode of this instance. This is proper, since instances of this class compare by identity (see equals).
Returns:int

a hash code value for this object

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

withRegisterOffsetback to summary
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:int

the amount to offset register numbers by

Returns:BasicBlock

non-null; an appropriately-constructed instance

org.droidparts.dexmaker.dx.rop.code back to summary

public Interface BasicBlock.Visitor


BasicBlock visitor interface

Method Summary

Modifier and TypeMethod and Description
public void
visitBlock(BasicBlock
block visited
b
)

Visits a basic block

Method Detail

visitBlockback to summary
public void visitBlock(BasicBlock b)

Visits a basic block

Parameters
b:BasicBlock

block visited