Class ForwardAnalysisImpl<V extends AbstractValue<V>,S extends Store<S>,T extends ForwardTransferFunction<V,S>>   
java.lang.Object
org.checkerframework.dataflow.analysis.AbstractAnalysis<V,S,T>
  
org.checkerframework.dataflow.analysis.ForwardAnalysisImpl<V,S,T>  
- Type Parameters:
- V- the abstract value type to be tracked by the analysis
- S- the store type used in the analysis
- T- the transfer function type that is used to approximate runtime behavior
- All Implemented Interfaces:
- Analysis<V,,- S, - T> - ForwardAnalysis<V,- S, - T> 
- Direct Known Subclasses:
- CFAbstractAnalysis
public class ForwardAnalysisImpl<V extends AbstractValue<V>,S extends Store<S>,T extends ForwardTransferFunction<V,S>>   
extends AbstractAnalysis<V,S,T>
implements ForwardAnalysis<V,S,T>    
An implementation of a forward analysis to solve a org.checkerframework.dataflow problem given a
 control flow graph and a forward transfer function.
- 
Nested Class SummaryNested classes/interfaces inherited from class org.checkerframework.dataflow.analysis.AbstractAnalysisAbstractAnalysis.WorklistNested classes/interfaces inherited from interface org.checkerframework.dataflow.analysis.AnalysisAnalysis.BeforeOrAfter, Analysis.Direction
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected final @Nullable IdentityHashMap<Block,Integer> Number of times each block has been analyzed since the last time widening was applied.protected final IdentityHashMap<Block,S> Else stores before every basic block (assumed to be 'no information' if not present).protected final intNumber of times a block can be analyzed before widening.protected final IdentityHashMap<ReturnNode,TransferResult<V, S>> The stores after every return statement.protected final IdentityHashMap<Block,S> Then stores before every basic block (assumed to be 'no information' if not present).Fields inherited from class org.checkerframework.dataflow.analysis.AbstractAnalysiscfg, currentInput, currentNode, currentTree, direction, finalLocalValues, inputs, isRunning, nodeValues, transferFunction, worklist
- 
Constructor SummaryConstructorsConstructorDescriptionForwardAnalysisImpl(int maxCountBeforeWidening) Construct an object that can perform a org.checkerframework.dataflow forward analysis over a control flow graph.ForwardAnalysisImpl(T transferFunction) Construct an object that can perform a org.checkerframework.dataflow forward analysis over a control flow graph given a transfer function.
- 
Method SummaryModifier and TypeMethodDescriptionprotected voidaddStoreBefore(Block b, @Nullable Node node, S s, Store.Kind kind, boolean addBlockToWorklist) Add a store before the basic blockbby merging with the existing stores for that location.protected TransferResult<V,S> callTransferFunction(Node node, TransferInput<V, S> input) Call the transfer function for nodenode, and set that node as current node first.Get the transfer input of a givenBlockb.protected @Nullable TransferInput<V,S> Returns the transfer input corresponding to the location right before the basic blockb.List<org.plumelib.util.IPair<ReturnNode,@Nullable TransferResult<V, S>>> Get stores at return statements.getStoreBefore(Block b, Store.Kind kind) Return the store corresponding to the location right before the basic blockb.protected voidInitialize fields of this object based on a given control flow graph.protected voidInitialize the transfer inputs of every basic block before performing the analysis.voidPerform the actual analysis.voidPerform the actual analysis on one block.protected voidpropagateStoresTo(Block succ, @Nullable Node node, TransferInput<V, S> currentInput, Store.FlowRule flowRule, boolean addToWorklistAgain) Propagate the stores incurrentInputto the next block in the direction of analysis, according to theflowRule.runAnalysisFor(Node node, Analysis.BeforeOrAfter preOrPost, TransferInput<V, S> blockTransferInput, IdentityHashMap<Node, V> nodeValues, @Nullable Map<TransferInput<V, S>, IdentityHashMap<Node, TransferResult<V, S>>> analysisCaches) Runs the analysis again within the block ofnodeand returns the store at the location ofnode.Methods inherited from class org.checkerframework.dataflow.analysis.AbstractAnalysisaddToWorklist, getContainingClass, getContainingMethod, getCurrentTree, getDirection, getExceptionalExitStore, getNodesForTree, getNodeValues, getRegularExitStore, getResult, getTransferFunction, getValue, getValue, init, isIgnoredExceptionType, isRunning, readFromStore, setCurrentNode, setCurrentTree, updateNodeValuesMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.checkerframework.dataflow.analysis.AnalysisgetDirection, getExceptionalExitStore, getRegularExitStore, getResult, getTransferFunction, getValue, getValue, isRunning
- 
Field Details- 
blockCountNumber of times each block has been analyzed since the last time widening was applied. Null if maxCountBeforeWidening is -1, which implies widening isn't used for this analysis.
- 
maxCountBeforeWideningprotected final int maxCountBeforeWideningNumber of times a block can be analyzed before widening. -1 implies that widening shouldn't be used.
- 
thenStoresThen stores before every basic block (assumed to be 'no information' if not present).
- 
elseStoresElse stores before every basic block (assumed to be 'no information' if not present).
- 
storesAtReturnStatementsprotected final IdentityHashMap<ReturnNode,TransferResult<V extends AbstractValue<V>, storesAtReturnStatementsS extends Store<S>>> The stores after every return statement.
 
- 
- 
Constructor Details- 
ForwardAnalysisImplpublic ForwardAnalysisImpl(int maxCountBeforeWidening) Construct an object that can perform a org.checkerframework.dataflow forward analysis over a control flow graph. When using this constructor, the transfer function is set later by the subclass, e.g.,org.checkerframework.framework.flow.CFAbstractAnalysis.- Parameters:
- maxCountBeforeWidening- number of times a block can be analyzed before widening
 
- 
ForwardAnalysisImplConstruct an object that can perform a org.checkerframework.dataflow forward analysis over a control flow graph given a transfer function.- Parameters:
- transferFunction- the transfer function
 
 
- 
- 
Method Details- 
performAnalysisDescription copied from interface:AnalysisPerform the actual analysis.- Specified by:
- performAnalysisin interface- Analysis<V extends AbstractValue<V>,- S extends Store<S>, - T extends ForwardTransferFunction<V, - S>> 
- Parameters:
- cfg- the control flow graph
 
- 
performAnalysisBlockDescription copied from interface:AnalysisPerform the actual analysis on one block.- Specified by:
- performAnalysisBlockin interface- Analysis<V extends AbstractValue<V>,- S extends Store<S>, - T extends ForwardTransferFunction<V, - S>> 
- Parameters:
- b- the block to analyze
 
- 
getInputDescription copied from interface:AnalysisGet the transfer input of a givenBlockb.
- 
getReturnStatementStores@RequiresNonNull("cfg") public List<org.plumelib.util.IPair<ReturnNode,@Nullable TransferResult<V, getReturnStatementStores()S>>> Description copied from interface:ForwardAnalysisGet stores at return statements. These stores are transfer results at return node. Thus for a forward analysis, these stores contain the analyzed flow information from entry nodes to return nodes.- Specified by:
- getReturnStatementStoresin interface- ForwardAnalysis<V extends AbstractValue<V>,- S extends Store<S>, - T extends ForwardTransferFunction<V, - S>> 
- Returns:
- the transfer results for each return node in the CFG
 
- 
runAnalysisForpublic S runAnalysisFor(@FindDistinct Node node, Analysis.BeforeOrAfter preOrPost, TransferInput<V, S> blockTransferInput, IdentityHashMap<Node, V> nodeValues, @Nullable Map<TransferInput<V, S>, IdentityHashMap<Node, TransferResult<V, S>>> analysisCaches) Description copied from interface:AnalysisRuns the analysis again within the block ofnodeand returns the store at the location ofnode. Ifbeforeis true, then the store immediately before theNodenodeis returned. Otherwise, the store immediately afternodeis returned. IfanalysisCachesis not null, this method uses a cache.analysisCachesis a map of a block of node to the cached analysis result. If the cache fortransferInputis 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.- Specified by:
- runAnalysisForin interface- Analysis<V extends AbstractValue<V>,- S extends Store<S>, - T extends ForwardTransferFunction<V, - S>> 
- Parameters:
- node- the node to analyze
- preOrPost- which store to return: the store immediately before- nodeor the store after- node
- blockTransferInput- the transfer input of the block of this node
- nodeValues- abstract values of nodes
- analysisCaches- caches of analysis results
- Returns:
- the store before or after node(depends on the value ofbefore) after running the analysis
 
- 
initFieldsDescription copied from class:AbstractAnalysisInitialize fields of this object based on a given control flow graph. Sub-class may override this method to initialize customized fields.- Overrides:
- initFieldsin class- AbstractAnalysis<V extends AbstractValue<V>,- S extends Store<S>, - T extends ForwardTransferFunction<V, - S>> 
- Parameters:
- cfg- a given control flow graph
 
- 
initInitialInputsDescription copied from class:AbstractAnalysisInitialize the transfer inputs of every basic block before performing the analysis.- Specified by:
- initInitialInputsin class- AbstractAnalysis<V extends AbstractValue<V>,- S extends Store<S>, - T extends ForwardTransferFunction<V, - S>> 
 
- 
callTransferFunctionDescription copied from class:AbstractAnalysisCall the transfer function for nodenode, and set that node as current node first. This method requires atransferInputthat the method can modify.- Overrides:
- callTransferFunctionin class- AbstractAnalysis<V extends AbstractValue<V>,- S extends Store<S>, - T extends ForwardTransferFunction<V, - S>> 
- Parameters:
- node- the given node
- input- the transfer input
- Returns:
- the output of the transfer function
 
- 
propagateStoresToprotected void propagateStoresTo(Block succ, @Nullable Node node, TransferInput<V, S> currentInput, Store.FlowRule flowRule, boolean addToWorklistAgain) Description copied from class:AbstractAnalysisPropagate the stores incurrentInputto the next block in the direction of analysis, according to theflowRule.- Specified by:
- propagateStoresToin class- AbstractAnalysis<V extends AbstractValue<V>,- S extends Store<S>, - T extends ForwardTransferFunction<V, - S>> 
- Parameters:
- succ- the target block to propagate the stores to
- node- the node of the target block
- currentInput- the current transfer input
- flowRule- the flow rule being used
- addToWorklistAgain- whether the block should be added to- AbstractAnalysis.worklistagain
 
- 
addStoreBeforeprotected void addStoreBefore(Block b, @Nullable Node node, S s, Store.Kind kind, boolean addBlockToWorklist) Add a store before the basic blockbby merging with the existing stores for that location.- Parameters:
- b- a basic block
- node- the node of the basic block- b
- s- the store being added
- kind- the kind of store- s
- addBlockToWorklist- whether the basic block- bshould be added back to- Worklist
 
- 
getStoreBeforeReturn the store corresponding to the location right before the basic blockb.- Parameters:
- b- a block
- kind- the kind of store which will be returned
- Returns:
- the store corresponding to the location right before the basic block b
 
- 
getInputBeforeReturns the transfer input corresponding to the location right before the basic blockb.- Parameters:
- b- a block
- Returns:
- the transfer input corresponding to the location right before the basic block b
 
 
-