edu.umd.cs.findbugs.ba

Class BasicBlock

public class BasicBlock extends AbstractVertex<Edge,BasicBlock> implements Debug

Simple basic block abstraction for BCEL.

Author: David Hovemeyer

See Also: CFG

Nested Class Summary
classBasicBlock.InstructionIterator
A forward Iterator over the instructions of a basic block.
Constructor Summary
BasicBlock()
Constructor.
Method Summary
voidaddInstruction(InstructionHandle handle)
Add an InstructionHandle to the basic block.
booleancontainsInstruction(InstructionHandle handle)
Return whether or not the basic block contains the given instruction.
booleancontainsInstructionWithOffset(int offset)
Return whether or not the basic block contains the instruction with the given bytecode offset.
CodeExceptionGengetExceptionGen()
Get CodeExceptionGen object; returns null if this basic block is not the entry point of an exception handler.
InstructionHandlegetExceptionThrower()
Get the instruction for which this block is an exception thrower.
InstructionHandlegetFirstInstruction()
Get the first instruction in the basic block.
intgetId()
InstructionHandlegetLastInstruction()
Get the last instruction in the basic block.
InstructionHandlegetPredecessorOf(InstructionHandle handle)
Get the predecessor of given instruction within the basic block.
InstructionHandlegetSuccessorOf(InstructionHandle handle)
Get the successor of given instruction within the basic block.
BasicBlock.InstructionIteratorinstructionIterator()
Get an Iterator over the instructions in the basic block.
Iterator<InstructionHandle>instructionReverseIterator()
Get an Iterator over the instructions in the basic block in reverse order.
booleanisEmpty()
Return true if there are no Instructions in this basic block.
booleanisExceptionHandler()
Is this block an exception handler?
booleanisExceptionThrower()
Return whether or not this block is an exception thrower.
booleanisInJSRSubroutine()
booleanisNullCheck()
Return whether or not this block is a null check.
voidsetExceptionGen(CodeExceptionGen exceptionGen)
Set the CodeExceptionGen object.
voidsetExceptionThrower(InstructionHandle exceptionThrower)
Set the instruction for which this block is the ETB.

Constructor Detail

BasicBlock

public BasicBlock()
Constructor.

Method Detail

addInstruction

public void addInstruction(InstructionHandle handle)
Add an InstructionHandle to the basic block.

Parameters: handle the InstructionHandle

containsInstruction

public boolean containsInstruction(InstructionHandle handle)
Return whether or not the basic block contains the given instruction.

Parameters: handle the instruction

Returns: true if the block contains the instruction, false otherwise

containsInstructionWithOffset

public boolean containsInstructionWithOffset(int offset)
Return whether or not the basic block contains the instruction with the given bytecode offset.

Parameters: offset the bytecode offset

Returns: true if the block contains an instruction with the given offset, false if it does not

getExceptionGen

public CodeExceptionGen getExceptionGen()
Get CodeExceptionGen object; returns null if this basic block is not the entry point of an exception handler.

Returns: the CodeExceptionGen object, or null

getExceptionThrower

public InstructionHandle getExceptionThrower()
Get the instruction for which this block is an exception thrower.

Returns: the instruction, or null if this block is not an exception thrower

getFirstInstruction

public InstructionHandle getFirstInstruction()
Get the first instruction in the basic block.

getId

public int getId()

getLastInstruction

public InstructionHandle getLastInstruction()
Get the last instruction in the basic block.

getPredecessorOf

public InstructionHandle getPredecessorOf(InstructionHandle handle)
Get the predecessor of given instruction within the basic block.

Parameters: handle the instruction

Returns: the instruction's predecessor, or null if the instruction is the first in the basic block

getSuccessorOf

public InstructionHandle getSuccessorOf(InstructionHandle handle)
Get the successor of given instruction within the basic block.

Parameters: handle the instruction

Returns: the instruction's successor, or null if the instruction is the last in the basic block

instructionIterator

public BasicBlock.InstructionIterator instructionIterator()
Get an Iterator over the instructions in the basic block.

instructionReverseIterator

public Iterator<InstructionHandle> instructionReverseIterator()
Get an Iterator over the instructions in the basic block in reverse order. This is useful for backwards dataflow analyses.

isEmpty

public boolean isEmpty()
Return true if there are no Instructions in this basic block.

isExceptionHandler

public boolean isExceptionHandler()
Is this block an exception handler?

isExceptionThrower

public boolean isExceptionThrower()
Return whether or not this block is an exception thrower.

isInJSRSubroutine

public boolean isInJSRSubroutine()

isNullCheck

public boolean isNullCheck()
Return whether or not this block is a null check.

setExceptionGen

public void setExceptionGen(CodeExceptionGen exceptionGen)
Set the CodeExceptionGen object. Marks this basic block as the entry point of an exception handler.

Parameters: exceptionGen the CodeExceptionGen object for the block

setExceptionThrower

public void setExceptionThrower(InstructionHandle exceptionThrower)
Set the instruction for which this block is the ETB.

Parameters: exceptionThrower the instruction

FindBugs™ is licenced under the LGPL. Copyright © 2006 University of Maryland.