|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectforge.dataflow.DataflowAnalysis<D>
public abstract class DataflowAnalysis<D>
A template for a dataflow analysis.
Subclasses need only indicate the direction of the analysis as an argument to the constructor and implement the initial, merge, and transfer functions, though they must be implemented carefully.
An analysis may be forward or backward. A forward analysis proceeds forward from the entry stmt in the CFG, and a backwards analysis proceeds backwards through the CFG from the exit stmt. When implementing a backwards analysis, the transfer function for a branch node must always return branch data whose thenData and elseData are the exact same reference; this can be ensured by using the BranchData constructor that takes a single data argument.
The transfer functions must not modify the input data.. That is, if the data has changed, a new data instance must be returned. The transfer functions may return null (bottom) if the analysis deems the subsequent stmt to be unreachable. For performance reasons, subclasses are encouraged, but not required, to ensure their transfer functions return the input data reference if the data has not changed. This avoids calls to the merge method, which can be costly.
The data before or after a given stmt in the results may be mapped to null, while is used as a bottom value to indicate that the analysis deems the stmt to be unreachable.
Constructor Summary | |
---|---|
protected |
DataflowAnalysis(boolean backward)
Constructs a new dataflow analysis in the specified direction. |
Method Summary | |
---|---|
AnalysisResults<D> |
analyze(ForgeCFG cfg)
Performs the analysis and returns a mapping from each reachable node to the data at the program point immediately preceding the node. |
abstract D |
copy(D data)
Makes a copy of the specified data. |
abstract D |
initial()
Returns the initial data set. |
boolean |
isBackward()
Returns true if this is a backwards analysis. |
abstract boolean |
merge(D from,
D into)
Merges "from" data into the "into" data and return true iff the into data has changed. |
D |
transfer(AssignStmt stmt,
D input)
Transfer function at an assign stmt. |
BranchData<D> |
transfer(BranchStmt stmt,
D input)
Transfer function at a branch node. |
D |
transfer(CallStmt stmt,
D input)
Transfer function at a call stmt. |
D |
transfer(CreateStmt stmt,
D input)
Transfer function at a create stmt. |
D |
transfer(ExitStmt stmt,
D input)
Transfer function at a terminal node. |
D |
transfer(SpecStmt stmt,
D input)
Transfer function at an spec stmt. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected DataflowAnalysis(boolean backward)
Method Detail |
---|
public final boolean isBackward()
public final AnalysisResults<D> analyze(ForgeCFG cfg)
public abstract D initial()
public D transfer(AssignStmt stmt, D input)
public D transfer(CallStmt stmt, D input)
public D transfer(CreateStmt stmt, D input)
public D transfer(SpecStmt stmt, D input)
public BranchData<D> transfer(BranchStmt stmt, D input)
public D transfer(ExitStmt stmt, D input)
public abstract boolean merge(D from, D into)
public abstract D copy(D data)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |