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<Block,TransferInput<V,S>> |
stores
The stores before every method call.
|
protected IdentityHashMap<Tree,Set<Node>> |
treeLookup
|
protected IdentityHashMap<UnaryTree,AssignmentNode> |
unaryAssignNodeLookup
Map from AST
UnaryTree s to corresponding AssignmentNode s. |
Modifier | Constructor and Description |
---|---|
|
AnalysisResult(Map<Node,V> nodeValues,
IdentityHashMap<Block,TransferInput<V,S>> stores,
IdentityHashMap<Tree,Set<Node>> treeLookup,
IdentityHashMap<UnaryTree,AssignmentNode> unaryAssignNodeLookup,
HashMap<Element,V> finalLocalValues)
Initialize with given mappings and empty cache.
|
protected |
AnalysisResult(Map<Node,V> nodeValues,
IdentityHashMap<Block,TransferInput<V,S>> stores,
IdentityHashMap<Tree,Set<Node>> treeLookup,
IdentityHashMap<UnaryTree,AssignmentNode> unaryAssignNodeLookup,
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.
|
AssignmentNode |
getAssignForUnaryTree(UnaryTree tree)
Returns the corresponding
AssignmentNode for a given UnaryTree . |
HashMap<Element,V> |
getFinalLocalValues()
Returns the value of effectively final local variables.
|
@Nullable Set<Node> |
getNodesForTree(Tree tree)
Returns the
Node s corresponding to a particular 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,
boolean before)
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,
boolean before,
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
Tree
s to sets of Node
s.
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,AssignmentNode> unaryAssignNodeLookup
UnaryTree
s to corresponding AssignmentNode
s.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(Map<Node,V> nodeValues, IdentityHashMap<Block,TransferInput<V,S>> stores, IdentityHashMap<Tree,Set<Node>> treeLookup, IdentityHashMap<UnaryTree,AssignmentNode> unaryAssignNodeLookup, HashMap<Element,V> finalLocalValues, Map<TransferInput<V,S>,IdentityHashMap<Node,TransferResult<V,S>>> analysisCaches)
nodeValues
- nodeValues
stores
- stores
treeLookup
- treeLookup
unaryAssignNodeLookup
- unaryAssignNodeLookup
finalLocalValues
- finalLocalValues
analysisCaches
- analysisCaches
public AnalysisResult(Map<Node,V> nodeValues, IdentityHashMap<Block,TransferInput<V,S>> stores, IdentityHashMap<Tree,Set<Node>> treeLookup, IdentityHashMap<UnaryTree,AssignmentNode> unaryAssignNodeLookup, HashMap<Element,V> finalLocalValues)
nodeValues
- nodeValues
stores
- stores
treeLookup
- treeLookup
unaryAssignNodeLookup
- unaryAssignNodeLookup
finalLocalValues
- finalLocalValues
public AnalysisResult(Map<TransferInput<V,S>,IdentityHashMap<Node,TransferResult<V,S>>> analysisCaches)
analysisCaches
- analysisCaches
public long getUid()
getUid
in interface org.plumelib.util.UniqueId
public 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)
Node
s corresponding to a particular Tree
. Multiple Node
s
can correspond to a single Tree
because of several reasons:
() -> 5
the 5
is both an IntegerLiteralNode
and a LambdaResultExpressionNode
.
NarrowingConversionNode
and WideningConversionNode
.
StringConversionNode
.
finally
blocks are cloned to achieve a precise CFG. Any Tree
within a finally block can have multiple corresponding Node
s attached to them.
Node
s they are not interested in.public AssignmentNode getAssignForUnaryTree(UnaryTree tree)
AssignmentNode
for a given UnaryTree
.tree
- a unary treepublic S getStoreBefore(Tree tree)
Tree
.tree
- a treeTree
public S getStoreBefore(Node node)
Node
.node
- a nodeNode
public S getStoreBefore(Block block)
Block
.block
- a blockpublic S getStoreAfter(Block block)
block
- a blockpublic S getStoreAfter(Tree tree)
Tree
.tree
- a treeTree
public S getStoreAfter(Node node)
Node
.node
- a nodeNode
protected S runAnalysisFor(Node node, boolean before)
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 analyzebefore
- the boolean value to indicate which store to return (if it is true, return the
store immediately before node
; otherwise, the store after node
is
returned)node
(depends on the value of before
) after
running the analysispublic static <V extends AbstractValue<V>,S extends Store<S>> S runAnalysisFor(Node node, boolean before, 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 analyzebefore
- the boolean value to indicate which store to return (if it is true, return the
store immediately before node
; otherwise, the store after node
is
returned)transferInput
- a transfer inputnodeValues
- nodeValues
analysisCaches
- analysisCaches
node
(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