public class CFG extends AbstractGraph<Edge,BasicBlock> implements Debug
BasicBlock
,
Edge
Modifier and Type | Field and Description |
---|---|
static int |
BUSY
Flag set if CFG is busy (in the process of being refined.
|
static int |
FOUND_INEXACT_UNCONDITIONAL_THROWERS |
static int |
PRUNED_FAILED_ASSERTION_EDGES
Flag set if CFG edges corresponding to failed assertions have been
removed.
|
static int |
PRUNED_INFEASIBLE_EXCEPTIONS
Flag set if infeasible exception edges have been pruned from the CFG.
|
static int |
PRUNED_UNCONDITIONAL_THROWERS
Flag set if normal return edges from calls to methods which
unconditionally throw an exception have been removed.
|
static int |
REFINED
Flag set if CFG has been "refined"; i.e., to the extent possible, all
infeasible edges have been removed.
|
VERIFY_INTEGRITY
Constructor and Description |
---|
CFG()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
BasicBlock |
allocate()
Allocate a new BasicBlock.
|
protected Edge |
allocateEdge(BasicBlock source,
BasicBlock target) |
java.util.Iterator<BasicBlock> |
blockIterator()
Get an Iterator over the nodes (BasicBlocks) of the control flow graph.
|
java.lang.Iterable<BasicBlock> |
blocks() |
void |
checkIntegrity() |
void |
clearFlag(int flags) |
Edge |
createEdge(BasicBlock source,
BasicBlock dest,
int type)
Add a unique edge to the graph.
|
java.util.Collection<BasicBlock> |
getBlocks(java.util.BitSet labelSet)
Get Collection of basic blocks whose IDs are specified by given BitSet.
|
java.util.Collection<BasicBlock> |
getBlocksContainingInstructionWithOffset(int offset)
Get a Collection of basic blocks which contain the bytecode instruction
with given offset.
|
BasicBlock |
getEntry()
Get the entry node.
|
Location |
getExceptionThrowerLocation(Edge exceptionEdge)
Get the Location where exception(s) thrown on given exception edge are
thrown.
|
BasicBlock |
getExit()
Get the exit node.
|
int |
getFlags() |
Edge |
getIncomingEdgeWithType(BasicBlock basicBlock,
int edgeType)
Get the first incoming edge in basic block with given type.
|
Location |
getLocationAtEntry()
Get the Location representing the entry to the CFG.
|
java.util.Collection<Location> |
getLocationsContainingInstructionWithOffset(int offset)
Get a Collection of Locations which specify the instruction at given
bytecode offset.
|
int |
getMaxEdgeId()
Get the number of edge labels allocated.
|
org.apache.bcel.generic.MethodGen |
getMethodGen() |
java.lang.String |
getMethodName() |
java.lang.String |
getMethodSig() |
int |
getNumBasicBlocks()
Get number of basic blocks.
|
int |
getNumNonExceptionSucessors(BasicBlock block)
Get number of non-exception control successors of given basic block.
|
Edge |
getOutgoingEdgeWithType(BasicBlock basicBlock,
int edgeType)
Get the first outgoing edge in basic block with given type.
|
BasicBlock |
getPredecessorWithEdgeType(BasicBlock target,
int edgeType)
Get the first predecessor reachable from given edge type.
|
Location |
getPreviousLocation(Location loc) |
BasicBlock |
getSuccessorWithEdgeType(BasicBlock source,
int edgeType)
Get the first successor reachable from given edge type.
|
boolean |
isFlagSet(int flag) |
java.util.Iterator<Location> |
locationIterator()
Get an Iterator over the Locations in the control flow graph.
|
java.lang.Iterable<Location> |
locations()
Get an Iterator over the Locations in the control flow graph.
|
BasicBlock |
lookupBlockByLabel(int blockLabel)
Look up a BasicBlock by its unique label.
|
Edge |
lookupEdgeById(int id)
Look up an Edge by its id.
|
java.util.Collection<Location> |
orderedLocations()
Returns a collection of locations, ordered according to the compareTo
ordering over locations.
|
java.util.Iterator<Edge> |
removedEdgeIterator()
Get an Iterator over Edges removed from this CFG.
|
void |
removeEdge(Edge edge)
Remove given edge from the graph.
|
void |
setFlag(int flags) |
void |
setFlags(int flags) |
void |
setMethodGen(org.apache.bcel.generic.MethodGen methodGen) |
void |
setMethodName(java.lang.String methodName) |
addVertex, containsVertex, createEdge, edgeIterator, getNumEdgeLabels, getNumEdges, getNumIncomingEdges, getNumOutgoingEdges, getNumVertexLabels, getNumVertices, incomingEdgeIterator, lookupEdge, outgoingEdgeIterator, predecessorIterator, removeVertex, setNumEdgeLabels, setNumVertexLabels, successorIterator, vertexIterator, vertices
public static final int PRUNED_INFEASIBLE_EXCEPTIONS
public static final int PRUNED_UNCONDITIONAL_THROWERS
public static final int REFINED
public static final int PRUNED_FAILED_ASSERTION_EDGES
public static final int BUSY
public static final int FOUND_INEXACT_UNCONDITIONAL_THROWERS
public CFG()
public void setMethodName(java.lang.String methodName)
methodName
- The methodName to set.public void setMethodGen(org.apache.bcel.generic.MethodGen methodGen)
public org.apache.bcel.generic.MethodGen getMethodGen()
public java.lang.String getMethodName()
public java.lang.String getMethodSig()
public void setFlags(int flags)
public void setFlag(int flags)
public void clearFlag(int flags)
public int getFlags()
public boolean isFlagSet(int flag)
public BasicBlock getEntry()
public BasicBlock getExit()
public Edge createEdge(BasicBlock source, BasicBlock dest, @Edge.Type int type)
source
- the source basic blockdest
- the destination basic blocktype
- the type of edge; see constants in EdgeTypes interfacejava.lang.IllegalStateException
- if there is already an edge in the CFG with the same source
and destination blockpublic Edge lookupEdgeById(int id)
id
- the id of the edge to look uppublic BasicBlock lookupBlockByLabel(int blockLabel)
blockLabel
- the label of a BasicBlockpublic java.util.Iterator<BasicBlock> blockIterator()
public java.lang.Iterable<BasicBlock> blocks()
public java.util.Iterator<Location> locationIterator()
public java.lang.Iterable<Location> locations()
public java.util.Collection<Location> orderedLocations()
public java.util.Collection<BasicBlock> getBlocks(java.util.BitSet labelSet)
labelSet
- BitSet of block labelspublic java.util.Collection<BasicBlock> getBlocksContainingInstructionWithOffset(int offset)
offset
- the bytecode offset of an instructionpublic java.util.Collection<Location> getLocationsContainingInstructionWithOffset(int offset)
offset
- the bytecode offsetpublic BasicBlock getPredecessorWithEdgeType(BasicBlock target, @Edge.Type int edgeType)
target
- the target blockedgeType
- the edge type leading from the predecessorpublic BasicBlock getSuccessorWithEdgeType(BasicBlock source, @Edge.Type int edgeType)
source
- the source blockedgeType
- the edge type leading to the successorpublic Location getExceptionThrowerLocation(Edge exceptionEdge)
exceptionEdge
- the exception Edgepublic java.util.Iterator<Edge> removedEdgeIterator()
public Edge getIncomingEdgeWithType(BasicBlock basicBlock, @Edge.Type int edgeType)
basicBlock
- the basic blockedgeType
- the edge typepublic Edge getOutgoingEdgeWithType(BasicBlock basicBlock, @Edge.Type int edgeType)
basicBlock
- the basic blockedgeType
- the edge typepublic BasicBlock allocate()
public int getNumBasicBlocks()
public int getMaxEdgeId()
public void checkIntegrity()
protected Edge allocateEdge(BasicBlock source, BasicBlock target)
allocateEdge
in class AbstractGraph<Edge,BasicBlock>
public void removeEdge(Edge edge)
Graph
removeEdge
in interface Graph<Edge,BasicBlock>
removeEdge
in class AbstractGraph<Edge,BasicBlock>
public int getNumNonExceptionSucessors(BasicBlock block)
block
- a BasicBlockpublic Location getLocationAtEntry()
FindBugs™ is licenced under the LGPL. Copyright © 2006 University of Maryland.