jif.ast

## Class JifInstantiator

- java.lang.Object
- - jif.ast.JifInstantiator

-     public class JifInstantiator
      extends java.lang.Object

  This class contains a number of static utility methods to help instantiate labels, principals and types. Instantiation includes:
  - the substitution of actual parameters for formal parameters in parametric types;
  - the substitution of receiver labels for the "this" label;
  - the substitution of actual arg labels for the formal arg labels;
  - the substitution of the receiver expression for dynamic labels and principals mentioning the "this" access path;
  - the substitution of the actual argument expressions for dynamic labels and principals mentioning formal arguments in their access path.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected java.util.List<polyglot.ast.Expr>` | `actualArgExprs`
    `protected java.util.List<? extends Label>` | `actualArgLabels`
    `protected java.util.List<? extends Label>` | `actualParamLabels`
    `protected JifContext` | `callerContext`
    `protected java.util.List<ArgLabel>` | `formalArgLabels`
    `protected java.util.List<? extends polyglot.types.Type>` | `formalArgTypes`
    `protected java.util.List<AccessPathRoot>` | `formalTempAccessPathRoots`
    `protected java.util.List<Label>` | `formalTempLabels`
    `protected Label` | `receiverLbl`
    `protected AccessPath` | `receiverPath`
    `protected polyglot.types.ReferenceType` | `receiverType`
    `protected Label` | `tempThisLbl`
    `protected AccessPathRoot` | `tempThisRoot`
    `protected JifTypeSystem` | `ts`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `JifInstantiator(polyglot.types.ReferenceType receiverType, Label receiverLbl, AccessPath receiverPath, java.util.List<ArgLabel> formalArgLabels, java.util.List<? extends polyglot.types.Type> formalArgTypes, java.util.List<? extends Label> actualArgLabels, java.util.List<polyglot.ast.Expr> actualArgExprs, java.util.List<? extends Label> actualParamLabels, JifContext callerContext)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Label` | `instantiate(Label L)`
    `static Label` | `instantiate(Label L, JifContext callerContext, AccessPath receiverPath, polyglot.types.ReferenceType receiverType, Label receiverLbl)`
    `static Label` | `instantiate(Label L, JifContext callerContext, polyglot.ast.Expr receiverExpr, polyglot.types.ReferenceType receiverType, Label receiverLbl)` Instantiate a label into a new context where some of the names it mentions may have a different meaning.
    `static Label` | `instantiate(Label L, JifContext callerContext, polyglot.ast.Expr receiverExpr, polyglot.types.ReferenceType receiverType, Label receiverLabel, java.util.List<ArgLabel> formalArgLabels, java.util.List<? extends polyglot.types.Type> formalArgTypes, java.util.List<Label> actualArgLabels, java.util.List<polyglot.ast.Expr> actualArgExprs, java.util.List<Label> actualParamLabels)`
    `Principal` | `instantiate(Principal p)`
    `static Principal` | `instantiate(Principal p, JifContext callerContext, polyglot.ast.Expr receiverExpr, polyglot.types.ReferenceType receiverType, Label receiverLabel, java.util.List<ArgLabel> formalArgLabels, java.util.List<? extends polyglot.types.Type> formalArgTypes, java.util.List<polyglot.ast.Expr> actualArgExprs, java.util.List<Label> actualParamLabels)`
    `polyglot.types.Type` | `instantiate(polyglot.types.Type t)`
    `static polyglot.types.Type` | `instantiate(polyglot.types.Type t, JifContext callerContext, AccessPath receiverPath, polyglot.types.ReferenceType receiverType, Label receiverLbl)`
    `static polyglot.types.Type` | `instantiate(polyglot.types.Type t, JifContext callerContext, polyglot.ast.Expr receiverExpr, polyglot.types.ReferenceType receiverType, Label receiverLbl)`
    `static polyglot.types.Type` | `instantiate(polyglot.types.Type t, JifContext callerContext, polyglot.ast.Expr receiverExpr, polyglot.types.ReferenceType receiverType, Label receiverLabel, java.util.List<ArgLabel> formalArgLabels, java.util.List<? extends polyglot.types.Type> formalArgTypes, java.util.List<? extends Label> actualArgLabels, java.util.List<polyglot.ast.Expr> actualArgExprs, java.util.List<? extends Label> actualParamLabels)`
    `protected java.lang.Object` | `instantiateImpl(java.lang.Object L, polyglot.util.Position pos)`
    `protected java.lang.Object` | `substImpl(java.lang.Object o, LabelSubstitution lblsubst)`

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

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

- - ### Field Detail

    - #### ts

          protected final JifTypeSystem ts

    - #### receiverType

          protected final polyglot.types.ReferenceType receiverType

    - #### receiverLbl

          protected final Label receiverLbl

    - #### receiverPath

          protected final AccessPath receiverPath

    - #### formalArgLabels

          protected final java.util.List<ArgLabel> formalArgLabels

    - #### formalArgTypes

          protected final java.util.List<? extends polyglot.types.Type> formalArgTypes

    - #### actualArgLabels

          protected final java.util.List<? extends Label> actualArgLabels

    - #### actualArgExprs

          protected final java.util.List<polyglot.ast.Expr> actualArgExprs

    - #### actualParamLabels

          protected final java.util.List<? extends Label> actualParamLabels

    - #### callerContext

          protected final JifContext callerContext

    - #### formalTempLabels

          protected final java.util.List<Label> formalTempLabels

    - #### formalTempAccessPathRoots

          protected final java.util.List<AccessPathRoot> formalTempAccessPathRoots

    - #### tempThisRoot

          protected final AccessPathRoot tempThisRoot

    - #### tempThisLbl

          protected final Label tempThisLbl

  - ### Constructor Detail

    - #### JifInstantiator

          protected JifInstantiator(polyglot.types.ReferenceType receiverType,
                                    Label receiverLbl,
                                    AccessPath receiverPath,
                                    java.util.List<ArgLabel> formalArgLabels,
                                    java.util.List<? extends polyglot.types.Type> formalArgTypes,
                                    java.util.List<? extends Label> actualArgLabels,
                                    java.util.List<polyglot.ast.Expr> actualArgExprs,
                                    java.util.List<? extends Label> actualParamLabels,
                                    JifContext callerContext)

  - ### Method Detail

    - #### instantiateImpl

          protected java.lang.Object instantiateImpl(java.lang.Object L,
                                                     polyglot.util.Position pos)

    - #### substImpl

          protected java.lang.Object substImpl(java.lang.Object o,
                                               LabelSubstitution lblsubst)
                                        throws polyglot.types.SemanticException

      Throws:
        `polyglot.types.SemanticException`

    - #### instantiate

          public Principal instantiate(Principal p)

    - #### instantiate

          public Label instantiate(Label L)

    - #### instantiate

          public polyglot.types.Type instantiate(polyglot.types.Type t)

    - #### instantiate

          public static Label instantiate(Label L,
                                          JifContext callerContext,
                                          polyglot.ast.Expr receiverExpr,
                                          polyglot.types.ReferenceType receiverType,
                                          Label receiverLabel,
                                          java.util.List<ArgLabel> formalArgLabels,
                                          java.util.List<? extends polyglot.types.Type> formalArgTypes,
                                          java.util.List<Label> actualArgLabels,
                                          java.util.List<polyglot.ast.Expr> actualArgExprs,
                                          java.util.List<Label> actualParamLabels)
                                   throws polyglot.types.SemanticException

      Throws:
        `polyglot.types.SemanticException`

    - #### instantiate

          public static Label instantiate(Label L,
                                          JifContext callerContext,
                                          polyglot.ast.Expr receiverExpr,
                                          polyglot.types.ReferenceType receiverType,
                                          Label receiverLbl)
                                   throws polyglot.types.SemanticException

      Instantiate a label into a new context where some of the names it mentions may have a different meaning. Instantiation is needed because labels may be used in a context different from the one in which they are defined. For example, in the following code:

           class C [label A] {
             final label x;

             f {this; x} () {
             }
           }

           class D[principal A] {
             void g() { o.f(); }
           }

      The begin label of f is defined in a context containing:
      - x: label
      - A: label
      - this: C
      In the context of g(), the begin label of f ({this; x}) should be interpreted as {o; o.x}.
      Parameters:
        `L` - the label to be instantiated ({this;x} in the example)
        `callerContext` - the context in which result label will be used (g in the example)
        `receiverExpr` - the expression to be used for interpreting dynamic labels (o in the example)
        `receiverType` - the type in which L is defined (C in this example)
        `receiverLbl` - the label to be substituted for {this} ({o} in the example)
      Returns:
        the instantiated label ({o; o.x} in the example)
      Throws:
        `polyglot.types.SemanticException` - TODO

    - #### instantiate

          public static Label instantiate(Label L,
                                          JifContext callerContext,
                                          AccessPath receiverPath,
                                          polyglot.types.ReferenceType receiverType,
                                          Label receiverLbl)

    - #### instantiate

          public static polyglot.types.Type instantiate(polyglot.types.Type t,
                                                        JifContext callerContext,
                                                        AccessPath receiverPath,
                                                        polyglot.types.ReferenceType receiverType,
                                                        Label receiverLbl)

    - #### instantiate

          public static Principal instantiate(Principal p,
                                              JifContext callerContext,
                                              polyglot.ast.Expr receiverExpr,
                                              polyglot.types.ReferenceType receiverType,
                                              Label receiverLabel,
                                              java.util.List<ArgLabel> formalArgLabels,
                                              java.util.List<? extends polyglot.types.Type> formalArgTypes,
                                              java.util.List<polyglot.ast.Expr> actualArgExprs,
                                              java.util.List<Label> actualParamLabels)
                                       throws polyglot.types.SemanticException

      Throws:
        `polyglot.types.SemanticException`

    - #### instantiate

          public static polyglot.types.Type instantiate(polyglot.types.Type t,
                                                        JifContext callerContext,
                                                        polyglot.ast.Expr receiverExpr,
                                                        polyglot.types.ReferenceType receiverType,
                                                        Label receiverLabel,
                                                        java.util.List<ArgLabel> formalArgLabels,
                                                        java.util.List<? extends polyglot.types.Type> formalArgTypes,
                                                        java.util.List<? extends Label> actualArgLabels,
                                                        java.util.List<polyglot.ast.Expr> actualArgExprs,
                                                        java.util.List<? extends Label> actualParamLabels)
                                                 throws polyglot.types.SemanticException

      Throws:
        `polyglot.types.SemanticException`

    - #### instantiate

          public static polyglot.types.Type instantiate(polyglot.types.Type t,
                                                        JifContext callerContext,
                                                        polyglot.ast.Expr receiverExpr,
                                                        polyglot.types.ReferenceType receiverType,
                                                        Label receiverLbl)
                                                 throws polyglot.types.SemanticException

      Throws:
        `polyglot.types.SemanticException`