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

hlt.language.design.kernel

## Class Abstraction

- java.lang.Object
- - hlt.language.design.kernel.Expression
  - - hlt.language.design.kernel.ProtoExpression
    - - hlt.language.design.kernel.Scope
      - - hlt.language.design.kernel.Abstraction

- All Implemented Interfaces:
    Locatable

      public class Abstraction
      extends Scope

  This class represents λ-calculus abstractions. More precisely, it represents multiple-parameter abstractions. This enables application to multiple arguments without having to "curry" it into a composition of single-parameter abstractions. This class extends `Scope` with the added mechanism needed to encapsulate lexically closed variables.

- - ### Field Summary

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

      `VOID_ASSIGNMENTS`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Abstraction(java.util.AbstractList parameters, Expression body)`
    `Abstraction(Expression body)`
    `Abstraction(Parameter[] parameters, Expression body)` Creates a new `Abstraction` instance.
    `Abstraction(Parameter parameter, Expression body)`
    `Abstraction(java.lang.String name, Expression body)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addToFrame(Local local)`
    `Expression` | `copy()` Returns a deep copy of this expression.
    `boolean` | `isExitable()`
    `void` | `sanitizeSorts(Enclosure enclosure)` This method walks down the expression gathering information relating each `Local` object to the `Scope` containing the corresponding `Parameter` in its array of formal parameters.
    `Scope` | `setIsExitable(boolean flag)`
    `Scope` | `setNonExitable()`
    `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).
    `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.Scope

      `arity, body, compile, containsFreeName, enclosingScope, intArity, numberOfSubexpressions, objectArity, parameter, parameters, realArity, sanitizeNames, setBody, setCheckedType, setCheckedType, setSortedArities, setSubexpression, subexpression, substitute, voidArity`

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

      `checkedType, setType, type, typeRef`

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

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

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

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

- - ### Constructor Detail

    - #### Abstraction

          public Abstraction(Parameter[] parameters,
                     Expression body)

      Creates a new `Abstraction` instance.
      Parameters:
        `parameters` - a `Parameter[]` value
        `body` - an `Expression` value

    - #### Abstraction

          public Abstraction(Parameter parameter,
                     Expression body)

    - #### Abstraction

          public Abstraction(java.lang.String name,
                     Expression body)

    - #### Abstraction

          public Abstraction(Expression body)

    - #### Abstraction

          public Abstraction(java.util.AbstractList parameters,
                     Expression body)

  - ### 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.
      Overrides:
        `copy` in class `Scope`

    - #### 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.
      Overrides:
        `typedCopy` in class `Scope`

    - #### isExitable

          public final boolean isExitable()

    - #### setIsExitable

          public final Scope setIsExitable(boolean flag)

    - #### setNonExitable

          public final Scope setNonExitable()

    - #### addToFrame

          public final void addToFrame(Local local)

    - #### sanitizeSorts

          public final void sanitizeSorts(Enclosure enclosure)

      Description copied from class: `Expression`
      This method walks down the expression gathering information relating each `Local` object to the `Scope` containing the corresponding `Parameter` in its array of formal parameters. It takes as an argument an `Enclosure`, which is a `Stack` containing all `Scope`s encountered along the way, equipped with a method to compute all the information necessary in computing the local's offset.
      Overrides:
        `sanitizeSorts` in class `Scope`

    - #### 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 `Scope`

    - #### 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`.
      Overrides:
        `typeCheck` in class `Scope`
      Throws:
        `TypingErrorException`

    - #### toString

          public final java.lang.String toString()

      Overrides:
        `toString` in class `Scope`