accrue.analysis.interprocanalysis

## Class AnalysisUtil<A extends Ordered<A>>

- java.lang.Object
- - accrue.analysis.interprocanalysis.AnalysisUtil<A>

- Type Parameters:
    `A` - Type of the analysis results
  Direct Known Subclasses:
    AnalysisUtilVarContext, CtlDepAnalysisUtil, DominationAnalysisUtil, PreciseCallGraphAnalysisUtil, PreciseExAnalysisUtil, ReadWriteSetsAnalysisUtil

      public abstract class AnalysisUtil<A extends Ordered<A>>
      extends java.lang.Object

  Abstract utility class for performing an object sensitive analysis.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected AccrueExtensionInfo` | `extInfo` Compiler extension info
    `protected boolean` | `instanceInitializersChecked`
    `protected WorkQueue<A>` | `workQueue` Analysis item work queue

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AnalysisUtil(WorkQueue<A> workQueue, AnalysisUnit currentAnalysisUnit, AccrueExtensionInfo extInfo)` Create a new utility class

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static java.util.Set<AbstractLocation>` | `abstractLocations(AccrueExtensionInfo extInfo, AnalysisContext context, polyglot.ast.ArrayAccess aa)` Get the set of abstract locations the given array access in the given context parameter could reference
    `static java.util.Set<AbstractLocation>` | `abstractLocations(AccrueExtensionInfo extInfo, AnalysisContext context, polyglot.ast.Field f)` Get the set of abstract locations the given field in the given context parameter could reference
    `java.util.Set<AbstractLocation>` | `abstractLocations(polyglot.ast.ArrayAccess aa)`
    `java.util.Set<AbstractLocation>` | `abstractLocations(polyglot.ast.Expr receiver, polyglot.types.FieldInstance fi)` Get the set of abstract locations the given field in the given receiver could reference
    `java.util.Set<AbstractLocation>` | `abstractLocations(polyglot.ast.Expr e, java.util.List<java.lang.String> path, java.util.List<polyglot.types.Type> types)` if path = f1, f2, f3, then returns abstract locations for e.f1.f2.f3 if types = t1.t2.t3, then e.f1 is of type t1, e.f1.f2 is of type t2, etc.
    `java.util.Set<AbstractLocation>` | `abstractLocations(polyglot.ast.Field f)` Get the set of abstract locations the given field could point to
    `java.util.Set<AbstractLocation>` | `abstractLocations(polyglot.ast.Formal f, polyglot.types.FieldInstance fi)` Get the set of abstract locations the given field in the given formal parameter could reference
    `java.util.Set<AbstractLocation>` | `abstractLocations(HContext receiver, polyglot.types.FieldInstance fi)` Get the set of abstract locations the given field in the given context could reference
    `java.util.Set<AbstractLocation>` | `abstractLocations(HContext receiver, java.lang.String fieldName)` Get the set of abstract locations the given field in the given context could reference
    `java.util.Set<AbstractLocation>` | `abstractLocationsForArray(polyglot.ast.Expr array)`
    `java.util.Set<AbstractLocation>` | `abstractLocationsForArray(polyglot.ast.Formal f)`
    `java.util.Set<AbstractLocation>` | `abstractLocationsForArray(java.util.Set<HContext> arrayObjects)`
    `java.util.Set<AbstractLocation>` | `abstractLocationsImplicitTarget(polyglot.types.FieldInstance fi)` Get the set of abstract locations the given field could point to.
    `java.lang.String` | `analysisName()`
    `abstract ExitMap<A>` | `analyze(polyglot.ast.CodeNode n, A before)` Analyze the given code with the given current analysis results
    `ExitMap<A>` | `analyzeInitializers(A input)` Analyze the initializers for the current analysis unit given the current analysis results
    `protected ExitMap<A>` | `analyzeStaticInitializers(A input)` Analyze the static initializers for the current analysis unit given the current analysis results
    `ExitMap<A>` | `createExitMap(A input)` Create a map from exit key to the given analysis result
    `AnalysisUnit` | `currentAnalysisUnit()`
    `polyglot.types.ClassType` | `currentClass()`
    `AnalysisContext` | `currentContext()`
    `AccrueExtensionInfo` | `extensionInfo()`
    `java.util.List<polyglot.ast.CodeNode>` | `instanceInitializers(polyglot.types.ClassType container)`
    `static <O extends Ordered<O>> boolean` | `leq(O x, O y)`
    `protected boolean` | `maybeRecursiveCall(AnalysisUnit callee)` Check if a call to the given analysis unit from the current analysis unit could be recursive
    `java.util.Set<HContext>` | `pointsTo(polyglot.ast.Expr e)` Get the points-to set for the given expression in the current analysis context
    `static java.util.Set<HContext>` | `pointsTo(polyglot.ast.Expr e, AnalysisContext context, AccrueExtensionInfo extInfo)` The set of heap objects the expression could point to given the `AnalysisContext`
    `java.util.Set<HContext>` | `pointsTo(polyglot.ast.Formal f)`
    `static java.util.Set<HContext>` | `pointsTo(polyglot.ast.Formal f, AnalysisContext context, AccrueExtensionInfo extInfo)` The set of heap objects the formal could point to given the `AnalysisContext`
    `protected static java.util.Set<HContext>` | `pointsTo(ReferenceVariable ln, AnalysisContext context, AccrueExtensionInfo extInfo)` The set of heap objects the node could point to given the `AnalysisContext`
    `java.util.Set<HContext>` | `pointsTo(java.util.Set<HContext> os, polyglot.types.FieldInstance fi)` Return the set of abstract objects that may be pointed to by the field instance fi of the abstract objects os.
    `static java.util.Set<HContext>` | `pointsTo(java.util.Set<HContext> os, polyglot.types.FieldInstance fi, polyglot.frontend.ExtensionInfo extInfo)` Return the set of abstract objects that may be pointed to by the field instance fi of the abstract objects os.
    `java.util.Set<HContext>` | `pointsTo(java.util.Set<HContext> os, java.lang.String field, polyglot.types.Type type)` Return the set of abstract objects that may be pointed to by the field `field` of type `type of the abstract objects os.`
    `static java.util.Set<HContext>` | `pointsTo(java.util.Set<HContext> os, java.lang.String field, polyglot.types.Type type, polyglot.frontend.ExtensionInfo extInfo)` Return the set of abstract objects that may be pointed to by the field `field` of type `type of the abstract objects os.`
    `static PointsToGraph` | `pointsToGraph(polyglot.frontend.ExtensionInfo extInfo)`
    `java.util.Set<HContext>` | `pointsToThis()` Return the pointsto set for "this" in the current analysis context.
    `ExitMap<A>` | `process(polyglot.ast.CodeNode cn, A input)` Run the analysis on the given code and current results ( `input`)
    `void` | `recordMissingCode(polyglot.types.CodeInstance ci)` Add the missing code to the compiler debug report
    `polyglot.types.TypeSystem` | `typeSystem()`
    `static <O extends Ordered<O>> O` | `upperBound(O x, O y)`
    `WorkQueue<A>` | `workQueue()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### workQueue

          protected final WorkQueue<A extends Ordered<A>> workQueue

      Analysis item work queue

    - #### extInfo

          protected final AccrueExtensionInfo extInfo

      Compiler extension info

    - #### instanceInitializersChecked

          protected boolean instanceInitializersChecked

  - ### Constructor Detail

    - #### AnalysisUtil

          public AnalysisUtil(WorkQueue<A> workQueue,
                      AnalysisUnit currentAnalysisUnit,
                      AccrueExtensionInfo extInfo)

      Create a new utility class
      Parameters:
        `workQueue` - Queue of analysis units
        `currentAnalysisUnit` - Current analysis unit from the queue
        `extInfo` - compiler analysis unit

  - ### Method Detail

    - #### extensionInfo

          public AccrueExtensionInfo extensionInfo()

      Returns:
        the compiler extension info

    - #### typeSystem

          public polyglot.types.TypeSystem typeSystem()

      Returns:
        the Polyglot `TypeSystem`

    - #### workQueue

          public WorkQueue<A> workQueue()

      Returns:
        queue of analysis units

    - #### currentAnalysisUnit

          public AnalysisUnit currentAnalysisUnit()

      Returns:
        analysis unit currently being analyzed

    - #### currentContext

          public AnalysisContext currentContext()

      Returns:
        the context of the current analysis unit

    - #### currentClass

          public polyglot.types.ClassType currentClass()

      Returns:
        the Polyglot `ClassType` for the current analysis unit

    - #### createExitMap

          public ExitMap<A> createExitMap(A input)

      Create a map from exit key to the given analysis result
      Parameters:
        `input` - analysis result to put into the exit map

    - #### maybeRecursiveCall

          protected boolean maybeRecursiveCall(AnalysisUnit callee)

      Check if a call to the given analysis unit from the current analysis unit could be recursive
      Parameters:
        `callee` - target of the potentially recursive call
      Returns:
        `true` if the current analysis unit make a recursive call on the callee

    - #### upperBound

          public static <O extends Ordered<O>> O upperBound(O x,
                                            O y)

      Returns:
        Upper bound of `x` and `y`

    - #### leq

          public static <O extends Ordered<O>> boolean leq(O x,
                                           O y)

      Returns:
        `true` if `x` is less than `y`

    - #### process

          public ExitMap<A> process(polyglot.ast.CodeNode cn,
                           A input)
                                                throws polyglot.types.SemanticException

      Run the analysis on the given code and current results ( `input`)
      Parameters:
        `cn` - Code to analyze
        `input` - current analysis results
      Returns:
        Map from exit condition to analysis result
      Throws:
        `polyglot.types.SemanticException` - thrown if the analysis fails

    - #### analyzeInitializers

          public ExitMap<A> analyzeInitializers(A input)
                                                            throws polyglot.types.SemanticException

      Analyze the initializers for the current analysis unit given the current analysis results
      Parameters:
        `input` - current analysis results
      Returns:
        Map from exit condition to analysis result
      Throws:
        `polyglot.types.SemanticException` - thrown if the analysis fails

    - #### analyzeStaticInitializers

          protected ExitMap<A> analyzeStaticInitializers(A input)
                                                                     throws polyglot.types.SemanticException

      Analyze the static initializers for the current analysis unit given the current analysis results
      Parameters:
        `input` - current analysis results
      Returns:
        Map from exit condition to analysis result
      Throws:
        `polyglot.types.SemanticException` - thrown if the analysis fails

    - #### analyze

          public abstract ExitMap<A> analyze(polyglot.ast.CodeNode n,
                           A before)
                                                         throws polyglot.types.SemanticException

      Analyze the given code with the given current analysis results
      Parameters:
        `n` - Code to analyze
        `before` - analysis result before analyzing the given code
      Returns:
        Map from exit condition to analysis result
      Throws:
        `polyglot.types.SemanticException` - thrown if the analysis fails

    - #### analysisName

          public java.lang.String analysisName()

      Returns:
        Name of the current analysis

    - #### abstractLocations

          public java.util.Set<AbstractLocation> abstractLocations(polyglot.ast.Field f)

      Get the set of abstract locations the given field could point to
      Parameters:
        `f` - field to check
      Returns:
        Set of abstract locations the given field could point to

    - #### abstractLocationsImplicitTarget

          public java.util.Set<AbstractLocation> abstractLocationsImplicitTarget(polyglot.types.FieldInstance fi)

      Get the set of abstract locations the given field could point to. NOTE: if the field is an instance field, then we assume that the target is implicitly "this".
      Parameters:
        `fi` - field to check
      Returns:
        Set of abstract locations the given field could point to

    - #### abstractLocations

          public java.util.Set<AbstractLocation> abstractLocations(polyglot.ast.Expr receiver,
                                                          polyglot.types.FieldInstance fi)

      Get the set of abstract locations the given field in the given receiver could reference
      Parameters:
        `receiver` - Expression containing the field
        `f` - field to check
      Returns:
        Set of abstract locations the given field could point to

    - #### abstractLocations

          public java.util.Set<AbstractLocation> abstractLocations(HContext receiver,
                                                          polyglot.types.FieldInstance fi)

      Get the set of abstract locations the given field in the given context could reference
      Parameters:
        `receiver` - Context to evaluate the points-to set in
        `f` - field to check
      Returns:
        Set of abstract locations the given field could point to

    - #### abstractLocations

          public java.util.Set<AbstractLocation> abstractLocations(HContext receiver,
                                                          java.lang.String fieldName)

      Get the set of abstract locations the given field in the given context could reference
      Parameters:
        `receiver` - Context to evaluate the points-to set in
        `f` - name of field to check
      Returns:
        Set of abstract locations the given field could point to

    - #### abstractLocations

          public java.util.Set<AbstractLocation> abstractLocations(polyglot.ast.Formal f,
                                                          polyglot.types.FieldInstance fi)

      Get the set of abstract locations the given field in the given formal parameter could reference
      Parameters:
        `f` - formal parameter containing the field
        `fi` - field to check
      Returns:
        Set of abstract locations the given field could point to

    - #### abstractLocations

          public java.util.Set<AbstractLocation> abstractLocations(polyglot.ast.Expr e,
                                                          java.util.List<java.lang.String> path,
                                                          java.util.List<polyglot.types.Type> types)

      if path = f1, f2, f3, then returns abstract locations for e.f1.f2.f3 if types = t1.t2.t3, then e.f1 is of type t1, e.f1.f2 is of type t2, etc.

    - #### abstractLocations

          public java.util.Set<AbstractLocation> abstractLocations(polyglot.ast.ArrayAccess aa)

      Returns:
        The abstract locations the array being accessed could point to

    - #### abstractLocationsForArray

          public java.util.Set<AbstractLocation> abstractLocationsForArray(polyglot.ast.Expr array)

      Parameters:
        `array` - Expression representing the array to get the points-to set for
      Returns:
        The abstract locations for the contents of the array

    - #### abstractLocationsForArray

          public java.util.Set<AbstractLocation> abstractLocationsForArray(java.util.Set<HContext> arrayObjects)

      Returns:
        The abstract locations for the contents of the array

    - #### abstractLocationsForArray

          public java.util.Set<AbstractLocation> abstractLocationsForArray(polyglot.ast.Formal f)

      Returns:
        The abstract locations for the contents of the array

    - #### pointsTo

          protected static java.util.Set<HContext> pointsTo(ReferenceVariable ln,
                                         AnalysisContext context,
                                         AccrueExtensionInfo extInfo)

      The set of heap objects the node could point to given the `AnalysisContext`
      Parameters:
        `ln` - node to get the points-to set for
        `context` - Procedure analysis context
        `extInfo` - Compiler extension info
      Returns:
        points-to set for the given node

    - #### pointsToGraph

          public static PointsToGraph pointsToGraph(polyglot.frontend.ExtensionInfo extInfo)

      Parameters:
        `Compiler` - extension info
      Returns:
        The entire points-to graph

    - #### pointsTo

          public java.util.Set<HContext> pointsTo(polyglot.ast.Expr e)

      Get the points-to set for the given expression in the current analysis context
      Parameters:
        `e` - expression
      Returns:
        points-to set for `e`

    - #### pointsTo

          public static java.util.Set<HContext> pointsTo(polyglot.ast.Expr e,
                                         AnalysisContext context,
                                         AccrueExtensionInfo extInfo)

      The set of heap objects the expression could point to given the `AnalysisContext`
      Parameters:
        `e` - expression to get the points-to set for
        `context` - Procedure analysis context
        `extInfo` - Compiler extension info
      Returns:
        points-to set for the given expression

    - #### pointsToThis

          public java.util.Set<HContext> pointsToThis()

      Return the pointsto set for "this" in the current analysis context. Will throw an exception if the current analysis context is a static context.
      Returns:
        points-to set for the "this" variable in the current scope.

    - #### pointsTo

          public java.util.Set<HContext> pointsTo(polyglot.ast.Formal f)

      Returns:
        points-to set for the given formal in the current context

    - #### pointsTo

          public static java.util.Set<HContext> pointsTo(polyglot.ast.Formal f,
                                         AnalysisContext context,
                                         AccrueExtensionInfo extInfo)

      The set of heap objects the formal could point to given the `AnalysisContext`
      Parameters:
        `f` - formal to get the points-to set for
        `context` - Procedure analysis context
        `extInfo` - Compiler extension info
      Returns:
        points-to set for the given expression

    - #### pointsTo

          public java.util.Set<HContext> pointsTo(java.util.Set<HContext> os,
                                         java.lang.String field,
                                         polyglot.types.Type type)

      Return the set of abstract objects that may be pointed to by the field `field` of type `type of the abstract objects os. That is, if o is in os, and the field `field` of the abstract object o may point to object m, and m is a subtype of `type` then m is in the set returned by this method. The pointsTo graph associated with the extInfo field of this AnalysisUtil is used.`

    - #### pointsTo

          public static java.util.Set<HContext> pointsTo(java.util.Set<HContext> os,
                                         java.lang.String field,
                                         polyglot.types.Type type,
                                         polyglot.frontend.ExtensionInfo extInfo)

      Return the set of abstract objects that may be pointed to by the field `field` of type `type of the abstract objects os. That is, if o is in os, and the field `field` of the abstract object o may point to object m, and m is a subtype of `type` then m is in the set returned by this method. The pointsTo graph associated with extInfo is used.`

    - #### pointsTo

          public java.util.Set<HContext> pointsTo(java.util.Set<HContext> os,
                                         polyglot.types.FieldInstance fi)

      Return the set of abstract objects that may be pointed to by the field instance fi of the abstract objects os. That is, if o is in os, and the field fi of the abstract object o may point to object m, then m is in the set returned by this method. The pointsTo graph associated with the extInfo field of this AnalysisUtil is used.

    - #### pointsTo

          public static java.util.Set<HContext> pointsTo(java.util.Set<HContext> os,
                                         polyglot.types.FieldInstance fi,
                                         polyglot.frontend.ExtensionInfo extInfo)

      Return the set of abstract objects that may be pointed to by the field instance fi of the abstract objects os. That is, if o is in os, and the field fi of the abstract object o may point to object m, then m is in the set returned by this method. The pointsTo graph associated with extInfo is used.

    - #### abstractLocations

          public static java.util.Set<AbstractLocation> abstractLocations(AccrueExtensionInfo extInfo,
                                                          AnalysisContext context,
                                                          polyglot.ast.Field f)

      Get the set of abstract locations the given field in the given context parameter could reference
      Parameters:
        `extInfo` - Compiler extension info
        `context` - Procedure analysis context
        `f` - field to check
      Returns:
        Set of abstract locations the given field could point to

    - #### abstractLocations

          public static java.util.Set<AbstractLocation> abstractLocations(AccrueExtensionInfo extInfo,
                                                          AnalysisContext context,
                                                          polyglot.ast.ArrayAccess aa)

      Get the set of abstract locations the given array access in the given context parameter could reference
      Parameters:
        `extInfo` - Compiler extension info
        `context` - Procedure analysis context
        `aa` - array access to check
      Returns:
        Set of abstract locations the given field could point to

    - #### instanceInitializers

          public java.util.List<polyglot.ast.CodeNode> instanceInitializers(polyglot.types.ClassType container)

      Returns:
        List of instance initializers and non-static field declarations

    - #### recordMissingCode

          public void recordMissingCode(polyglot.types.CodeInstance ci)

      Add the missing code to the compiler debug report
      Parameters:
        `ci` - missing code