Definition (API documentation of hlt.language packages)
Date: 2013-01-30

hlt.language.design.kernel

## Class Definition

- java.lang.Object
- - hlt.language.design.kernel.Expression
  - - hlt.language.design.kernel.ProtoExpression
    - - hlt.language.design.kernel.Definition

- All Implemented Interfaces:
    Locatable

      public class Definition
      extends ProtoExpression

- - ### Field Summary

    - ### Fields inherited from class hlt.language.design.kernel.Expression

      `VOID_ASSIGNMENTS`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Definition(Symbol symbol, Expression body)`
    `Definition(Tables tables, java.lang.String symbol, java.util.AbstractList args, Expression body)`
    `Definition(Tables tables, java.lang.String symbol, java.util.AbstractList args, Expression body, boolean isField)`
    `Definition(Tables tables, java.lang.String name, Expression body)`
    `Definition(Tables tables, java.lang.String symbol, Expression body, boolean isField)`
    `Definition(Tables tables, java.lang.String symbol, java.lang.String arg, Expression body)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `DefinedEntry` | `codeEntry()`
    `void` | `compile(Compiler compiler)` Compiling a definition amounts to assigning a code array to the defined symbol for its type and compiling its body into this code array.
    `Expression` | `copy()` Returns a deep copy of this expression.
    `boolean` | `isProjection()`
    `boolean` | `isSetOnEvaluation()`
    `int` | `numberOfSubexpressions()` Returns the number of subexpressions
    `void` | `registerCodeEntry()` This method registers a definitively type-checked definition of a global symbol.
    `void` | `setCheckedType()` This method sets the final unambiguously checked type of this expression, possibly along with other final information that may be needed by the compiler for generating code.
    `Definition` | `setIsProjection()`
    `Definition` | `setOnEvaluation()`
    `Expression` | `setSubexpression(int n, Expression expression)` Returns this expression after setting its n-th subexpression to the specified expression; if there is no subexpression at the given position, this throws a `NoSuchSubexpressionException`
    `Expression` | `shiftOffsets(int intShift, int realShift, int objectShift, int intDepth, int realDepth, int objectDepth)` This methods visits this expression shifting the offset of all the `Local`s it encounters by the specified amount (per sort) as long as the offset it sees is referencing a parameter within the specified scope depth (per sort); This method is used when the compiler needs to synthesize an scope from an already typechecked expression (i.e., for currying or un/boxing - e.g., see the `pad` method below).
    `Expression` | `subexpression(int n)` Returns the n-th subexpression of this expression; if there is no subexpression at the given position, this throws a `NoSuchSubexpressionException`
    `Symbol` | `symbol()`
    `java.lang.String` | `toString()`
    `void` | `typeCheck(TypeChecker typeChecker)` This method type-checks this expression in the context of the specified `TypeChecker`.
    `Expression` | `typedCopy()` Returns a deep copy of this expression this and all its subexpressions share the same type as their copy's counterparts.

    - ### Methods inherited from class hlt.language.design.kernel.ProtoExpression

      `checkedType, setCheckedType, setType, type, typeRef`

    - ### Methods inherited from class hlt.language.design.kernel.Expression

      `addType, addTypes, boxSort, containsFreeName, enclosingScope, extent, getEnd, getStart, isConstant, isEquality, isFalse, isHiddenSlicing, isNull, isSelector, isSlicing, isTrue, isVoid, locationString, otherTypes, parameters, sanitizeNames, sanitizeSorts, setCheckedTypeLocked, setEnd, setExtent, setOtherTypes, setStart, shiftOffsets, sort, substitute, typeCheck, typeCheck, typeCheckLocked`

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

      `equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### Definition

          public Definition(Symbol symbol,
                    Expression body)

    - #### Definition

          public Definition(Tables tables,
                    java.lang.String name,
                    Expression body)

    - #### Definition

          public Definition(Tables tables,
                    java.lang.String symbol,
                    java.lang.String arg,
                    Expression body)

    - #### Definition

          public Definition(Tables tables,
                    java.lang.String symbol,
                    java.util.AbstractList args,
                    Expression body)

    - #### Definition

          public Definition(Tables tables,
                    java.lang.String symbol,
                    Expression body,
                    boolean isField)

    - #### Definition

          public Definition(Tables tables,
                    java.lang.String symbol,
                    java.util.AbstractList args,
                    Expression body,
                    boolean isField)

  - ### Method Detail

    - #### copy

          public final Expression copy()

      Description copied from class: `Expression`
      Returns a deep copy of this expression. The types are not not copied. NB: This is a convenience for building expressions that should be used exclusively before any processing (in particular sanitizing), is done on this expression.
      Specified by:
        `copy` in class `Expression`

    - #### typedCopy

          public final Expression typedCopy()

      Description copied from class: `Expression`
      Returns a deep copy of this expression this and all its subexpressions share the same type as their copy's counterparts. NB: This is a convenience for building expressions that should be used exclusively before any processing (in particular sanitizing), is done on this expression.
      Specified by:
        `typedCopy` in class `Expression`

    - #### numberOfSubexpressions

          public final int numberOfSubexpressions()

      Description copied from class: `Expression`
      Returns the number of subexpressions
      Overrides:
        `numberOfSubexpressions` in class `Expression`

    - #### subexpression

          public final Expression subexpression(int n)
                                         throws NoSuchSubexpressionException

      Description copied from class: `Expression`
      Returns the n-th subexpression of this expression; if there is no subexpression at the given position, this throws a `NoSuchSubexpressionException`
      Overrides:
        `subexpression` in class `Expression`
      Throws:
        `NoSuchSubexpressionException`

    - #### setSubexpression

          public final Expression setSubexpression(int n,
                                    Expression expression)
                                            throws NoSuchSubexpressionException

      Description copied from class: `Expression`
      Returns this expression after setting its n-th subexpression to the specified expression; if there is no subexpression at the given position, this throws a `NoSuchSubexpressionException`
      Overrides:
        `setSubexpression` in class `Expression`
      Throws:
        `NoSuchSubexpressionException`

    - #### symbol

          public final Symbol symbol()

    - #### isProjection

          public final boolean isProjection()

    - #### setIsProjection

          public final Definition setIsProjection()

    - #### setCheckedType

          public final void setCheckedType()

      Description copied from class: `Expression`
      This method sets the final unambiguously checked type of this expression, possibly along with other final information that may be needed by the compiler for generating code.
      Specified by:
        `setCheckedType` in class `Expression`

    - #### codeEntry

          public final DefinedEntry codeEntry()

    - #### setOnEvaluation

          public final Definition setOnEvaluation()

    - #### isSetOnEvaluation

          public final boolean isSetOnEvaluation()

    - #### registerCodeEntry

          public final void registerCodeEntry()
                                       throws DefinitionException

      This method registers a definitively type-checked definition of a global symbol. It must be called only after type-checking of the definition has been completed; namely, after the `setCheckedType` method has been invoked, which ensures that the checked typed has been standardized.
      Throws:
        `DefinitionException`

    - #### typeCheck

          public final void typeCheck(TypeChecker typeChecker)
                               throws TypingErrorException

      Description copied from class: `Expression`
      This method type-checks this expression in the context of the specified `TypeChecker`.
      Specified by:
        `typeCheck` in class `Expression`
      Throws:
        `TypingErrorException`

    - #### shiftOffsets

          public final Expression shiftOffsets(int intShift,
                                int realShift,
                                int objectShift,
                                int intDepth,
                                int realDepth,
                                int objectDepth)

      Description copied from class: `Expression`
      This methods visits this expression shifting the offset of all the `Local`s it encounters by the specified amount (per sort) as long as the offset it sees is referencing a parameter within the specified scope depth (per sort); This method is used when the compiler needs to synthesize an scope from an already typechecked expression (i.e., for currying or un/boxing - e.g., see the `pad` method below).
      Overrides:
        `shiftOffsets` in class `Expression`

    - #### compile

          public final void compile(Compiler compiler)

      Compiling a definition amounts to assigning a code array to the defined symbol for its type and compiling its body into this code array. This will also make the compiler be aware that it is compiling a definition (as opposed to an expression to evaluate), by setting its "`codeEntry`" field to the defined symbol's `DefinedEntry` of any unsafe definition where calls to it appear.
      Specified by:
        `compile` in class `Expression`

    - #### toString

          public final java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`