Interface Analysis<V extends AbstractValue<V>,S extends Store<S>,T extends TransferFunction<V,S>>
-
- Type Parameters:
V
- the abstract value type to be tracked by the analysisS
- the store type used in the analysisT
- the transfer function type that is used to approximated runtime behavior
- All Known Subinterfaces:
BackwardAnalysis<V,S,T>
,ForwardAnalysis<V,S,T>
- All Known Implementing Classes:
AbstractAnalysis
,AccumulationAnalysis
,BackwardAnalysisImpl
,CalledMethodsAnalysis
,CFAbstractAnalysis
,CFAnalysis
,ForwardAnalysisImpl
,InitializationAnalysis
,KeyForAnalysis
,LockAnalysis
,NullnessNoInitAnalysis
,ResourceLeakAnalysis
public interface Analysis<V extends AbstractValue<V>,S extends Store<S>,T extends TransferFunction<V,S>>
This interface defines a dataflow analysis, given a control flow graph and a transfer function. A dataflow analysis has a direction, either forward or backward. The direction of corresponding transfer function is consistent with the analysis, i.e. a forward analysis has a forward transfer function, and a backward analysis has a backward transfer function.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
Analysis.BeforeOrAfter
In calls toAnalysis#runAnalysisFor
, whether to return the store before or after the given node.static class
Analysis.Direction
The direction of an analysis instance.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Analysis.Direction
getDirection()
Get the direction of this analysis.@Nullable S
getExceptionalExitStore()
Returns the exceptional exit store.@Nullable TransferInput<V,S>
getInput(Block b)
Get the transfer input of a givenBlock
b.@Nullable S
getRegularExitStore()
Returns the regular exit store, ornull
, if there is no such store (because the method cannot exit through the regular exit block).AnalysisResult<V,S>
getResult()
The result of running the analysis.@Nullable T
getTransferFunction()
Get the transfer function of this analysis.@Nullable V
getValue(com.sun.source.tree.Tree t)
Return the abstract value forTree
t
, ornull
if no information is available.@Nullable V
getValue(Node n)
boolean
isRunning()
Is the analysis currently running?void
performAnalysis(ControlFlowGraph cfg)
Perform the actual analysis.void
performAnalysisBlock(Block b)
Perform the actual analysis on one block.S
runAnalysisFor(Node node, Analysis.BeforeOrAfter preOrPost, TransferInput<V,S> blockTransferInput, java.util.IdentityHashMap<Node,V> nodeValues, @Nullable java.util.Map<TransferInput<V,S>,java.util.IdentityHashMap<Node,TransferResult<V,S>>> analysisCaches)
Runs the analysis again within the block ofnode
and returns the store at the location ofnode
.
-
-
-
Method Detail
-
getDirection
Analysis.Direction getDirection()
Get the direction of this analysis.- Returns:
- the direction of this analysis
-
isRunning
boolean isRunning()
Is the analysis currently running?- Returns:
- true if the analysis is running currently, else false
-
performAnalysis
void performAnalysis(ControlFlowGraph cfg)
Perform the actual analysis.- Parameters:
cfg
- the control flow graph
-
performAnalysisBlock
void performAnalysisBlock(Block b)
Perform the actual analysis on one block.- Parameters:
b
- the block to analyze
-
runAnalysisFor
S runAnalysisFor(Node node, Analysis.BeforeOrAfter preOrPost, TransferInput<V,S> blockTransferInput, java.util.IdentityHashMap<Node,V> nodeValues, @Nullable java.util.Map<TransferInput<V,S>,java.util.IdentityHashMap<Node,TransferResult<V,S>>> analysisCaches)
Runs the analysis again within the block ofnode
and returns the store at the location ofnode
. Ifbefore
is true, then the store immediately before theNode
node
is returned. Otherwise, the store immediately afternode
is returned. IfanalysisCaches
is not null, this method uses a cache.analysisCaches
is a map of a block of node to the cached analysis result. If the cache fortransferInput
is not inanalysisCaches
, this method creates new cache and stores it inanalysisCaches
. The cache is a map of nodes to the analysis results of the nodes.- Parameters:
node
- the node to analyzepreOrPost
- which store to return: the store immediately beforenode
or the store afternode
blockTransferInput
- the transfer input of the block of this nodenodeValues
- abstract values of nodesanalysisCaches
- caches of analysis results- Returns:
- the store before or after
node
(depends on the value ofbefore
) after running the analysis
-
getResult
AnalysisResult<V,S> getResult()
The result of running the analysis. This is only available once the analysis finished running.- Returns:
- the result of running the analysis
-
getTransferFunction
@Nullable T getTransferFunction()
Get the transfer function of this analysis.- Returns:
- the transfer function of this analysis
-
getInput
@Nullable TransferInput<V,S> getInput(Block b)
Get the transfer input of a givenBlock
b.- Parameters:
b
- a given Block- Returns:
- the transfer input of this Block
-
getValue
@Nullable V getValue(Node n)
Returns the abstract value forNode
n
, ornull
if no information is available. Note that if the analysis has not finished yet, this value might not represent the final value for this node.- Parameters:
n
- n a node- Returns:
- the abstract value for node
n
, ornull
if no information is available
-
getValue
@Nullable V getValue(com.sun.source.tree.Tree t)
Return the abstract value forTree
t
, ornull
if no information is available. Note that if the analysis has not finished yet, this value might not represent the final value for this node.- Parameters:
t
- the given tree- Returns:
- the abstract value for the given tree
-
getRegularExitStore
@Nullable S getRegularExitStore()
Returns the regular exit store, ornull
, if there is no such store (because the method cannot exit through the regular exit block).- Returns:
- the regular exit store, or
null
, if there is no such store (because the method cannot exit through the regular exit block)
-
-