edu.umd.cs.findbugs.ba
Class Dataflow<Fact,AnalysisType extends DataflowAnalysis<Fact>>

java.lang.Object
  extended by edu.umd.cs.findbugs.ba.Dataflow<Fact,AnalysisType>
Direct Known Subclasses:
IsNullValueDataflow, LiveLocalStoreDataflow, LockCountDataflow, LockDataflow, ReturnPathDataflow, TypeDataflow, ValueNumberDataflow

public class Dataflow<Fact,AnalysisType extends DataflowAnalysis<Fact>>
extends java.lang.Object

Perform dataflow analysis on a method using a control flow graph. Both forward and backward analyses can be performed.

The analysis's transfer function is applied to transform the meet of the results of the block's logical predecessors (the block's start facts) into the block's result facts.

Author:
David Hovemeyer
See Also:
CFG, DataflowAnalysis

Field Summary
private  AnalysisType analysis
           
private  BlockOrder blockOrder
           
private  CFG cfg
           
private static boolean DEBUG
           
private  boolean isForwards
           
private static int MAX_ITERS
           
private  int numIterations
           
 
Constructor Summary
Dataflow(CFG cfg, AnalysisType analysis)
          Constructor.
 
Method Summary
private static void debug(BasicBlock bb, BasicBlock pred, java.lang.String msg)
           
private static void debug(BasicBlock bb, java.lang.String msg)
           
 void execute()
          Run the algorithm.
 AnalysisType getAnalysis()
          Get the analysis object.
 CFG getCFG()
          Get the CFG object.
 int getNumIterations()
          Return the number of iterations of the main execution loop.
 Fact getResultFact(BasicBlock block)
          Get dataflow facts for end of given block.
 Fact getStartFact(BasicBlock block)
          Get dataflow facts for start of given block.
private  BasicBlock logicalEntryBlock()
          Get the "logical" entry block of the CFG.
private  java.util.Iterator<Edge> logicalPredecessorEdgeIterator(BasicBlock block)
          Return an Iterator over edges that connect given block to its logical predecessors.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cfg

private CFG cfg

analysis

private AnalysisType extends DataflowAnalysis<Fact> analysis

blockOrder

private BlockOrder blockOrder

isForwards

private boolean isForwards

numIterations

private int numIterations

DEBUG

private static final boolean DEBUG

MAX_ITERS

private static final int MAX_ITERS
Constructor Detail

Dataflow

public Dataflow(CFG cfg,
                AnalysisType analysis)
Constructor.

Parameters:
cfg - the control flow graph
analysis - the DataflowAnalysis to be run
Method Detail

execute

public void execute()
             throws DataflowAnalysisException
Run the algorithm. Afterwards, caller can use the getStartFact() and getResultFact() methods to to get dataflow facts at start and result points of each block.

Throws:
DataflowAnalysisException

debug

private static void debug(BasicBlock bb,
                          java.lang.String msg)

debug

private static void debug(BasicBlock bb,
                          BasicBlock pred,
                          java.lang.String msg)

getNumIterations

public int getNumIterations()
Return the number of iterations of the main execution loop.


getStartFact

public Fact getStartFact(BasicBlock block)
Get dataflow facts for start of given block.


getResultFact

public Fact getResultFact(BasicBlock block)
Get dataflow facts for end of given block.


getAnalysis

public AnalysisType getAnalysis()
Get the analysis object.


getCFG

public CFG getCFG()
Get the CFG object.


logicalPredecessorEdgeIterator

private java.util.Iterator<Edge> logicalPredecessorEdgeIterator(BasicBlock block)
Return an Iterator over edges that connect given block to its logical predecessors. For forward analyses, this is the incoming edges. For backward analyses, this is the outgoing edges.


logicalEntryBlock

private BasicBlock logicalEntryBlock()
Get the "logical" entry block of the CFG. For forward analyses, this is the entry block. For backward analyses, this is the exit block.