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

hlt.language.design.kernel

## Class Application

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

- All Implemented Interfaces:
    Locatable
  Direct Known Subclasses:
    Let

      public class Application
      extends ProtoExpression

  This class represents functional applications à la λ-calculus. More precisely, it represents multiple-argument applications. This enables an application to handle many arguments without having to be "curryed" into a composition of single-argument applications.

- - ### Field Summary

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

      `VOID_ASSIGNMENTS`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Application(Expression function, java.util.AbstractList arguments)`
    `Application(Expression function, Expression argument)`
    `Application(Expression function, Expression[] arguments)`
    `Application(Expression function, Expression arg1, Expression arg2)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `Expression` | `argument(int n)`
    `Expression[]` | `arguments()`
    `int` | `arity()`
    `void` | `compile(Compiler compiler)` This method compiles this expression in the context of the specified `Compiler`.
    `Expression` | `copy()` Returns a deep copy of this expression.
    `Application` | `flatten()`
    `Expression` | `function()`
    `boolean` | `isFieldApplication()`
    `boolean` | `isHiddenSlicing(Tables tables, Parameter parameter)` Returns `true` iff this application is a "hidden" filter for the specified parameter; i.e., iff it is of the form `s(x) == e`, where `x` is the parameter, and `x` does not occur free in `e`.
    `boolean` | `isSelector(Tables tables, Parameter parameter)` Returns `true` iff this application is a selector filter for the specified parameter; i.e., iff it is of the form `x == e`, where `x` is the parameter, and `x` does not occur free in `e`.
    `boolean` | `isSlicing(Tables tables, Parameter parameter)` Returns `true` iff this application is a slicing filter for the specified parameter; i.e., iff it is of the form `x.s == e`, where `x` is the parameter, and `x` does not occur free in `e`.
    `boolean` | `isTupleProjection()`
    `boolean` | `isUnaryTupleProjection()`
    `boolean` | `noCurrying()`
    `int` | `numberOfSubexpressions()` Returns the number of subexpressions
    `void` | `setArguments(Expression[] arguments)`
    `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.
    `void` | `setCheckedType(Type type)` NB: this is not `final` because itis overridden in `Abstraction` and `Global`.
    `void` | `setFunction(Expression function)`
    `Application` | `setNoCurrying()`
    `Application` | `setNoCurrying(boolean flag)`
    `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`
    `boolean` | `slicesParameter(Parameter parameter)` Returns `true` iff this is of the form `p1(p2(...pk(x)...))` where `x` is a local occurrence of the specified parameter, and the `pi`s are unary tuple projections.
    `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`
    `java.lang.String` | `toString()`
    `void` | `typeCheck(TypeChecker typeChecker)` This method type-checks this expression in the context of the specified `TypeChecker`.
    `void` | `typeCheck(Type type, TypeChecker typeChecker)` This method ascertains that this expression has the specified type 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.
    `Expression` | `undoDummyLocal()` When this application is a slicing equality, this undoes the name-sanitizing of the "dummy local" parameter occurrence of the projection back to a plain dummy.

    - ### 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, containsFreeName, enclosingScope, extent, getEnd, getStart, isConstant, isEquality, isFalse, isNull, isTrue, isVoid, locationString, otherTypes, parameters, sanitizeNames, sanitizeSorts, setCheckedTypeLocked, setEnd, setExtent, setOtherTypes, setStart, shiftOffsets, shiftOffsets, sort, substitute, typeCheck, typeCheckLocked`

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

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

- - ### Constructor Detail

    - #### Application

          public Application(Expression function,
                     Expression[] arguments)

    - #### Application

          public Application(Expression function,
                     Expression arg1,
                     Expression arg2)

    - #### Application

          public Application(Expression function,
                     Expression argument)

    - #### Application

          public Application(Expression function,
                     java.util.AbstractList arguments)

  - ### Method Detail

    - #### flatten

          public final Application flatten()

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

    - #### isSlicing

          public final boolean isSlicing(Tables tables,
                          Parameter parameter)
                                  throws UndefinedEqualityException

      Returns `true` iff this application is a slicing filter for the specified parameter; i.e., iff it is of the form `x.s == e`, where `x` is the parameter, and `x` does not occur free in `e`.
      Overrides:
        `isSlicing` in class `Expression`
      Throws:
        `UndefinedEqualityException`

    - #### isHiddenSlicing

          public final boolean isHiddenSlicing(Tables tables,
                                Parameter parameter)
                                        throws UndefinedEqualityException

      Returns `true` iff this application is a "hidden" filter for the specified parameter; i.e., iff it is of the form `s(x) == e`, where `x` is the parameter, and `x` does not occur free in `e`.
      Overrides:
        `isHiddenSlicing` in class `Expression`
      Throws:
        `UndefinedEqualityException`

    - #### slicesParameter

          public final boolean slicesParameter(Parameter parameter)

      Returns `true` iff this is of the form `p1(p2(...pk(x)...))` where `x` is a local occurrence of the specified parameter, and the `pi`s are unary tuple projections.

    - #### isSelector

          public final boolean isSelector(Tables tables,
                           Parameter parameter)
                                   throws UndefinedEqualityException

      Returns `true` iff this application is a selector filter for the specified parameter; i.e., iff it is of the form `x == e`, where `x` is the parameter, and `x` does not occur free in `e`.
      Overrides:
        `isSelector` in class `Expression`
      Throws:
        `UndefinedEqualityException`

    - #### undoDummyLocal

          public final Expression undoDummyLocal()

      When this application is a slicing equality, this undoes the name-sanitizing of the "dummy local" parameter occurrence of the projection back to a plain dummy. This is used by a `Comprehension` when a selector filter for a generator has been identified - thus rendering all its slicings useless, which then must be reintegrated as simple filter conditions.

    - #### noCurrying

          public final boolean noCurrying()

    - #### setNoCurrying

          public final Application setNoCurrying()

    - #### setNoCurrying

          public final Application setNoCurrying(boolean flag)

    - #### numberOfSubexpressions

          public 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`

    - #### function

          public final Expression function()

    - #### arguments

          public final Expression[] arguments()

    - #### argument

          public final Expression argument(int n)

    - #### setFunction

          public final void setFunction(Expression function)

    - #### setArguments

          public final void setArguments(Expression[] arguments)

    - #### arity

          public final int arity()

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

    - #### setCheckedType

          public final void setCheckedType(Type type)

      Description copied from class: `ProtoExpression`
      NB: this is not `final` because itis overridden in `Abstraction` and `Global`.
      Overrides:
        `setCheckedType` in class `ProtoExpression`

    - #### typeCheck

          public final void typeCheck(Type type,
                       TypeChecker typeChecker)
                               throws TypingErrorException

      Description copied from class: `Expression`
      This method ascertains that this expression has the specified type in the context of the specified `TypeChecker`. It amounts to first type-checking this expression in the type-checker, then making sure the type found for it by the type-checker agrees (i.e.unifies) with the specified type.
      Overrides:
        `typeCheck` in class `Expression`
      Throws:
        `TypingErrorException`

    - #### typeCheck

          public 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`

    - #### isTupleProjection

          public final boolean isTupleProjection()

    - #### isUnaryTupleProjection

          public final boolean isUnaryTupleProjection()

    - #### isFieldApplication

          public final boolean isFieldApplication()

    - #### compile

          public void compile(Compiler compiler)

      Description copied from class: `Expression`
      This method compiles this expression in the context of the specified `Compiler`.
      Specified by:
        `compile` in class `Expression`

    - #### toString

          public java.lang.String toString()

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