Class AnalysisResult<V extends AbstractValue<V>,S extends Store<S>>

java.lang.Object
org.checkerframework.dataflow.analysis.AnalysisResult<V,S>
Type Parameters:
V - type of the abstract value that is tracked
S - the store type used in the analysis
All Implemented Interfaces:
org.plumelib.util.UniqueId

public class AnalysisResult<V extends AbstractValue<V>,S extends Store<S>> extends Object implements org.plumelib.util.UniqueId
An 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.
  • Field Details

  • Constructor Details

  • Method Details

    • getUid

      public long getUid(@UnknownInitialization AnalysisResult<V extends AbstractValue<V>,S extends Store<S>> this)
      Specified by:
      getUid in interface org.plumelib.util.UniqueId
    • combine

      public void combine(AnalysisResult<V,S> other)
      Combine with another analysis result.
      Parameters:
      other - an analysis result to combine with this
    • getFinalLocalValues

      public Map<VariableElement,V> getFinalLocalValues()
      Returns the value of effectively final local variables.
      Returns:
      the value of effectively final local variables
    • getValue

      public @Nullable V getValue(Node n)
      Returns the abstract value for 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.
      Parameters:
      n - a node
      Returns:
      the abstract value for Node n, or null if no information is available
    • getValue

      public @Nullable V getValue(Tree t)
      Returns the abstract value for 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.
      Parameters:
      t - a tree
      Returns:
      the abstract value for Tree t, or null if no information is available
    • getNodesForTree

      public @Nullable Set<Node> getNodesForTree(Tree tree)
      Returns the Nodes corresponding to a particular Tree. Multiple Nodes can correspond to a single Tree because of several reasons:
      1. In a lambda expression such as () -> 5 the 5 is both an IntegerLiteralNode and a LambdaResultExpressionNode.
      2. Widening and narrowing primitive conversions can result in WideningConversionNode and NarrowingConversionNode.
      3. Automatic String conversion can result in a StringConversionNode.
      4. Trees for finally blocks are cloned to achieve a precise CFG. Any Tree within a finally block can have multiple corresponding Nodes attached to them.
      Callers of this method should always iterate through the returned set, possibly ignoring all Nodes they are not interested in.
      Parameters:
      tree - a tree
      Returns:
      the set of Nodes for a given Tree
    • getPostfixBinaryTree

      public BinaryTree getPostfixBinaryTree(UnaryTree postfixTree)
      Returns the synthetic v + 1 or v - 1 corresponding to the postfix increment or decrement tree.
      Parameters:
      postfixTree - a postfix increment or decrement tree
      Returns:
      the synthetic v + 1 or v - 1 corresponding to the postfix increment or decrement tree
    • getStoreBefore

      public @Nullable S getStoreBefore(Tree tree)
      Returns the store immediately before a given Tree.
      Parameters:
      tree - a tree
      Returns:
      the store immediately before a given Tree
    • getStoreBefore

      public @Nullable S getStoreBefore(Node node)
      Returns the store immediately before a given Node.
      Parameters:
      node - a node
      Returns:
      the store immediately before a given Node
    • getStoreBefore

      public S getStoreBefore(Block block)
      Returns the regular store immediately before a given Block.
      Parameters:
      block - a block
      Returns:
      the store right before the given block
    • getStoreAfter

      public S getStoreAfter(Block block)
      Returns the regular store immediately after a given block.
      Parameters:
      block - a block
      Returns:
      the store after the given block
    • getStoreAfter

      public @Nullable S getStoreAfter(Tree tree)
      Returns the store immediately after a given Tree.
      Parameters:
      tree - a tree
      Returns:
      the store immediately after a given Tree
    • getStoreAfter

      public @Nullable S getStoreAfter(Node node)
      Returns the store immediately after a given Node.
      Parameters:
      node - a node
      Returns:
      the store immediately after a given Node
    • runAnalysisFor

      protected @Nullable 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. 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.

      Parameters:
      node - the node to analyze
      preOrPost - which store to return: the store immediately before node or the store after node
      Returns:
      the store before or after node (depends on the value of before) after running the analysis
    • runAnalysisFor

      public static <V extends AbstractValue<V>, S extends Store<S>> S runAnalysisFor(Node node, Analysis.BeforeOrAfter preOrPost, TransferInput<V,S> transferInput, IdentityHashMap<Node,V> nodeValues, @Nullable 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. 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.
      Type Parameters:
      V - the abstract value type to be tracked by the analysis
      S - the store type used in the analysis
      Parameters:
      node - the node to analyze
      preOrPost - which store to return: the store immediately before node or the store after node
      transferInput - a transfer input
      nodeValues - nodeValues
      analysisCaches - analysisCaches
      Returns:
      the store before or after node (depends on the value of before) after running the analysis
    • lookupResult

      public @Nullable TransferResult<V,S> lookupResult(Node node)
      Returns the cached TransferResult for a given node.
      Parameters:
      node - the node for which to look up a result
      Returns:
      the TransferResult at the given node
    • toStringDebug

      public String toStringDebug()
      Returns a verbose string representation of this, useful for debugging.
      Returns:
      a string representation of this
    • nodeValuesToString

      public static <V> String nodeValuesToString(Map<Node,V> nodeValues)
      Returns a verbose string representation, useful for debugging. The map has the same type as the nodeValues field.
      Type Parameters:
      V - the type of values in the map
      Parameters:
      nodeValues - a map to format
      Returns:
      a printed representation of the given map
    • treeLookupToString

      public static String treeLookupToString(Map<Tree,Set<Node>> treeLookup)
      Returns a verbose string representation of a map, useful for debugging. The map has the same type as the treeLookup field.
      Parameters:
      treeLookup - a map to format
      Returns:
      a printed representation of the given map