edu.umd.cs.findbugs.ba
Class BlockTypeAnalysis

java.lang.Object
  extended by edu.umd.cs.findbugs.ba.BlockTypeAnalysis
All Implemented Interfaces:
DataflowAnalysis<BlockType>

public class BlockTypeAnalysis
extends java.lang.Object
implements DataflowAnalysis<BlockType>

Dataflow analysis to determine the nesting of catch and finally blocks within a method.

Author:
David Hovemeyer
See Also:
BlockType

Field Summary
private  DepthFirstSearch dfs
           
private  java.util.Map<BasicBlock,BlockType> resultFactMap
           
private  java.util.Map<BasicBlock,BlockType> startFactMap
           
 
Constructor Summary
BlockTypeAnalysis(DepthFirstSearch dfs)
          Constructor.
 
Method Summary
 void copy(BlockType source, BlockType dest)
          Copy dataflow facts.
 BlockType createFact()
          Create empty (uninitialized) dataflow facts for one program point.
 BlockOrder getBlockOrder(CFG cfg)
          Return the BlockOrder specifying the order in which BasicBlocks should be visited in the main dataflow loop.
 BlockType getResultFact(BasicBlock block)
          Get the result fact for given basic block.
 BlockType getStartFact(BasicBlock block)
          Get the start fact for given basic block.
 void initEntryFact(BlockType result)
          Initialize the "entry" fact for the graph.
 void initResultFact(BlockType result)
          Initialize result fact for block.
 boolean isForwards()
          Returns true if the analysis is forwards, false if backwards.
private  BlockType lookupOrCreateFact(java.util.Map<BasicBlock,BlockType> map, BasicBlock block)
           
static void main(java.lang.String[] argv)
           
 void makeFactTop(BlockType fact)
          Make given fact the top value.
 void meetInto(BlockType fact, Edge edge, BlockType result)
          Meet a dataflow fact associated with an incoming edge into another fact.
 boolean same(BlockType fact1, BlockType fact2)
          Are given dataflow facts the same?
 void transfer(BasicBlock basicBlock, org.apache.bcel.generic.InstructionHandle end, BlockType start, BlockType result)
          Transfer function for the analysis.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dfs

private DepthFirstSearch dfs

startFactMap

private java.util.Map<BasicBlock,BlockType> startFactMap

resultFactMap

private java.util.Map<BasicBlock,BlockType> resultFactMap
Constructor Detail

BlockTypeAnalysis

public BlockTypeAnalysis(DepthFirstSearch dfs)
Constructor.

Parameters:
dfs - a DepthFirstSearch for the method to be analyzed
Method Detail

createFact

public BlockType createFact()
Description copied from interface: DataflowAnalysis
Create empty (uninitialized) dataflow facts for one program point. A valid value will be copied into it before it is used.

Specified by:
createFact in interface DataflowAnalysis<BlockType>

getStartFact

public BlockType getStartFact(BasicBlock block)
Description copied from interface: DataflowAnalysis
Get the start fact for given basic block.

Specified by:
getStartFact in interface DataflowAnalysis<BlockType>
Parameters:
block - the basic block

getResultFact

public BlockType getResultFact(BasicBlock block)
Description copied from interface: DataflowAnalysis
Get the result fact for given basic block.

Specified by:
getResultFact in interface DataflowAnalysis<BlockType>
Parameters:
block - the basic block

copy

public void copy(BlockType source,
                 BlockType dest)
Description copied from interface: DataflowAnalysis
Copy dataflow facts.

Specified by:
copy in interface DataflowAnalysis<BlockType>

initEntryFact

public void initEntryFact(BlockType result)
                   throws DataflowAnalysisException
Description copied from interface: DataflowAnalysis
Initialize the "entry" fact for the graph.

Specified by:
initEntryFact in interface DataflowAnalysis<BlockType>
Throws:
DataflowAnalysisException

initResultFact

public void initResultFact(BlockType result)
Description copied from interface: DataflowAnalysis
Initialize result fact for block. The start facts for a block are initialized as the meet of the "logical" predecessor's result facts. Note that a "logical predecessor" is actually a CFG successor if the analysis is backwards.

Specified by:
initResultFact in interface DataflowAnalysis<BlockType>

makeFactTop

public void makeFactTop(BlockType fact)
Description copied from interface: DataflowAnalysis
Make given fact the top value.

Specified by:
makeFactTop in interface DataflowAnalysis<BlockType>

isForwards

public boolean isForwards()
Description copied from interface: DataflowAnalysis
Returns true if the analysis is forwards, false if backwards.

Specified by:
isForwards in interface DataflowAnalysis<BlockType>

getBlockOrder

public BlockOrder getBlockOrder(CFG cfg)
Description copied from interface: DataflowAnalysis
Return the BlockOrder specifying the order in which BasicBlocks should be visited in the main dataflow loop.

Specified by:
getBlockOrder in interface DataflowAnalysis<BlockType>
Parameters:
cfg - the CFG upon which we're performing dataflow analysis

same

public boolean same(BlockType fact1,
                    BlockType fact2)
Description copied from interface: DataflowAnalysis
Are given dataflow facts the same?

Specified by:
same in interface DataflowAnalysis<BlockType>

transfer

public void transfer(BasicBlock basicBlock,
                     org.apache.bcel.generic.InstructionHandle end,
                     BlockType start,
                     BlockType result)
              throws DataflowAnalysisException
Description copied from interface: DataflowAnalysis
Transfer function for the analysis. Taking dataflow facts at start (which might be either the entry or exit of the block, depending on whether the analysis is forwards or backwards), modify result to be the facts at the other end of the block.

Specified by:
transfer in interface DataflowAnalysis<BlockType>
Parameters:
basicBlock - the basic block
end - if nonnull, stop before considering this instruction; otherwise, consider all of the instructions in the basic block
start - dataflow facts at beginning of block (if forward analysis) or end of block (if backwards analysis)
result - resulting dataflow facts at other end of block
Throws:
DataflowAnalysisException

meetInto

public void meetInto(BlockType fact,
                     Edge edge,
                     BlockType result)
              throws DataflowAnalysisException
Description copied from interface: DataflowAnalysis
Meet a dataflow fact associated with an incoming edge into another fact. This is used to determine the start fact for a basic block.

Specified by:
meetInto in interface DataflowAnalysis<BlockType>
Parameters:
fact - the predecessor fact (incoming edge)
edge - the edge from the predecessor
result - the result fact
Throws:
DataflowAnalysisException

lookupOrCreateFact

private BlockType lookupOrCreateFact(java.util.Map<BasicBlock,BlockType> map,
                                     BasicBlock block)

main

public static void main(java.lang.String[] argv)
                 throws java.lang.Exception
Throws:
java.lang.Exception