V - type of the abstract value that is trackedS - the store type used in the analysispublic class AnalysisResult<V extends AbstractValue<V>,S extends Store<S>> extends Object implements org.plumelib.util.UniqueId
AnalysisResult represents the result of a org.checkerframework.dataflow analysis by
providing the abstract values given a node or a tree. Note that it does not keep track of custom
results computed by some analysis.| Modifier and Type | Field and Description |
|---|---|
protected Map<TransferInput<V,S>,IdentityHashMap<Node,TransferResult<V,S>>> |
analysisCaches
Caches of the analysis results for each input for the block of the node and each node.
|
protected HashMap<Element,V> |
finalLocalValues
Map from (effectively final) local variable elements to their abstract value.
|
protected IdentityHashMap<Node,V> |
nodeValues
Abstract values of nodes.
|
protected IdentityHashMap<UnaryTree,BinaryTree> |
postfixLookup
Map from postfix increment or decrement trees that are AST
UnaryTrees to the synthetic
tree that is v + 1 or v - 1. |
protected IdentityHashMap<Block,TransferInput<V,S>> |
stores
The stores before every method call.
|
protected IdentityHashMap<Tree,Set<Node>> |
treeLookup
|
| Modifier | Constructor and Description |
|---|---|
|
AnalysisResult(IdentityHashMap<Node,V> nodeValues,
IdentityHashMap<Block,TransferInput<V,S>> stores,
IdentityHashMap<Tree,Set<Node>> treeLookup,
IdentityHashMap<UnaryTree,BinaryTree> postfixLookup,
HashMap<Element,V> finalLocalValues)
Initialize with given mappings and empty cache.
|
protected |
AnalysisResult(IdentityHashMap<Node,V> nodeValues,
IdentityHashMap<Block,TransferInput<V,S>> stores,
IdentityHashMap<Tree,Set<Node>> treeLookup,
IdentityHashMap<UnaryTree,BinaryTree> postfixLookup,
HashMap<Element,V> finalLocalValues,
Map<TransferInput<V,S>,IdentityHashMap<Node,TransferResult<V,S>>> analysisCaches)
Initialize with given mappings.
|
|
AnalysisResult(Map<TransferInput<V,S>,IdentityHashMap<Node,TransferResult<V,S>>> analysisCaches)
Initialize empty result with specified cache.
|
| Modifier and Type | Method and Description |
|---|---|
void |
combine(AnalysisResult<V,S> other)
Combine with another analysis result.
|
HashMap<Element,V> |
getFinalLocalValues()
Returns the value of effectively final local variables.
|
@Nullable Set<Node> |
getNodesForTree(Tree tree)
Returns the
Nodes corresponding to a particular Tree. |
BinaryTree |
getPostfixBinaryTree(UnaryTree postfixTree)
Returns the synthetic
v + 1 or v - 1 corresponding to the postfix increment or
decrement tree. |
S |
getStoreAfter(Block block)
Returns the regular store immediately after a given block.
|
S |
getStoreAfter(Node node)
Returns the store immediately after a given
Node. |
S |
getStoreAfter(Tree tree)
Returns the store immediately after a given
Tree. |
S |
getStoreBefore(Block block)
Returns the regular store immediately before a given
Block. |
S |
getStoreBefore(Node node)
Returns the store immediately before a given
Node. |
S |
getStoreBefore(Tree tree)
Returns the store immediately before a given
Tree. |
long |
getUid() |
V |
getValue(Node n)
|
V |
getValue(Tree t)
|
static <V> String |
nodeValuesToString(Map<Node,V> nodeValues)
Returns a verbose string representation, useful for debugging.
|
protected S |
runAnalysisFor(Node node,
Analysis.BeforeOrAfter preOrPost)
Runs the analysis again within the block of
node and returns the store at the location
of node. |
static <V extends AbstractValue<V>,S extends Store<S>> |
runAnalysisFor(Node node,
Analysis.BeforeOrAfter preOrPost,
TransferInput<V,S> transferInput,
IdentityHashMap<Node,V> nodeValues,
Map<TransferInput<V,S>,IdentityHashMap<Node,TransferResult<V,S>>> analysisCaches)
Runs the analysis again within the block of
node and returns the store at the location
of node. |
String |
toStringDebug()
Returns a verbose string representation of this, useful for debugging.
|
static String |
treeLookupToString(Map<Tree,Set<Node>> treeLookup)
Returns a verbose string representation of a map, useful for debugging.
|
protected final IdentityHashMap<Node,V extends AbstractValue<V>> nodeValues
protected final IdentityHashMap<Tree,Set<Node>> treeLookup
Trees to sets of Nodes.
Some of those Nodes might not be keys in nodeValues. One reason is that the Node is
unreachable in the control flow graph, so dataflow never gave it a value.
protected final IdentityHashMap<UnaryTree,BinaryTree> postfixLookup
UnaryTrees to the synthetic
tree that is v + 1 or v - 1.protected final HashMap<Element,V extends AbstractValue<V>> finalLocalValues
protected final IdentityHashMap<Block,TransferInput<V extends AbstractValue<V>,S extends Store<S>>> stores
protected final Map<TransferInput<V extends AbstractValue<V>,S extends Store<S>>,IdentityHashMap<Node,TransferResult<V extends AbstractValue<V>,S extends Store<S>>>> analysisCaches
protected AnalysisResult(IdentityHashMap<Node,V> nodeValues, IdentityHashMap<Block,TransferInput<V,S>> stores, IdentityHashMap<Tree,Set<Node>> treeLookup, IdentityHashMap<UnaryTree,BinaryTree> postfixLookup, HashMap<Element,V> finalLocalValues, Map<TransferInput<V,S>,IdentityHashMap<Node,TransferResult<V,S>>> analysisCaches)
nodeValues - nodeValuesstores - storestreeLookup - treeLookuppostfixLookup - postfixLookupfinalLocalValues - finalLocalValuesanalysisCaches - analysisCachespublic AnalysisResult(IdentityHashMap<Node,V> nodeValues, IdentityHashMap<Block,TransferInput<V,S>> stores, IdentityHashMap<Tree,Set<Node>> treeLookup, IdentityHashMap<UnaryTree,BinaryTree> postfixLookup, HashMap<Element,V> finalLocalValues)
nodeValues - nodeValuesstores - storestreeLookup - treeLookuppostfixLookup - postfixLookupfinalLocalValues - finalLocalValuespublic AnalysisResult(Map<TransferInput<V,S>,IdentityHashMap<Node,TransferResult<V,S>>> analysisCaches)
analysisCaches - analysisCachespublic long getUid(@UnknownInitialization AnalysisResult<V extends AbstractValue<V>,S extends Store<S>> this)
getUid in interface org.plumelib.util.UniqueIdpublic void combine(AnalysisResult<V,S> other)
other - an analysis result to combine with thispublic HashMap<Element,V> getFinalLocalValues()
public V getValue(Node n)
Node n, or null 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.n - a nodeNode n, or null if no information is
availablepublic V getValue(Tree t)
Tree t, or null 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.t - a treeTree t, or null if no information is
availablepublic @Nullable Set<Node> getNodesForTree(Tree tree)
Nodes corresponding to a particular Tree. Multiple Nodes
can correspond to a single Tree because of several reasons:
() -> 5 the 5 is both an IntegerLiteralNode and a LambdaResultExpressionNode.
WideningConversionNode
and NarrowingConversionNode.
StringConversionNode.
finally blocks are cloned to achieve a precise CFG. Any Tree
within a finally block can have multiple corresponding Nodes attached to them.
Nodes they are not interested in.public BinaryTree getPostfixBinaryTree(UnaryTree postfixTree)
v + 1 or v - 1 corresponding to the postfix increment or
decrement tree.postfixTree - a postfix increment or decrement treev + 1 or v - 1 corresponding to the postfix increment or
decrement treepublic S getStoreBefore(Tree tree)
Tree.tree - a treeTreepublic S getStoreBefore(Node node)
Node.node - a nodeNodepublic S getStoreBefore(Block block)
Block.block - a blockpublic S getStoreAfter(Block block)
block - a blockpublic S getStoreAfter(Tree tree)
Tree.tree - a treeTreepublic S getStoreAfter(Node node)
Node.node - a nodeNodeprotected S runAnalysisFor(Node node, Analysis.BeforeOrAfter preOrPost)
node and returns the store at the location
of node. If before is true, then the store immediately before the Node
node is returned. Otherwise, the store after node is returned.
If the given Node cannot be reached (in the control flow graph), then null
is returned.
node - the node to analyzepreOrPost - which store to return: the store immediately before node or the store
after nodenode (depends on the value of before) after
running the analysispublic static <V extends AbstractValue<V>,S extends Store<S>> S runAnalysisFor(Node node, Analysis.BeforeOrAfter preOrPost, TransferInput<V,S> transferInput, IdentityHashMap<Node,V> nodeValues, Map<TransferInput<V,S>,IdentityHashMap<Node,TransferResult<V,S>>> analysisCaches)
node and returns the store at the location
of node. If before is true, then the store immediately before the Node
node is returned. Otherwise, the store immediately after node is returned. If
analysisCaches 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 for transferInput is not
in analysisCaches, this method creates new cache and stores it in analysisCaches. The cache is a map of nodes to the analysis results of the nodes.V - the abstract value type to be tracked by the analysisS - the store type used in the analysisnode - the node to analyzepreOrPost - which store to return: the store immediately before node or the store
after nodetransferInput - a transfer inputnodeValues - nodeValuesanalysisCaches - analysisCachesnode (depends on the value of before) after
running the analysispublic String toStringDebug()
public static <V> String nodeValuesToString(Map<Node,V> nodeValues)
nodeValues field.V - the type of values in the mapnodeValues - a map to formatpublic static String treeLookupToString(Map<Tree,Set<Node>> treeLookup)
treeLookup field.treeLookup - a map to format