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

hlt.language.design.types

## Class Symbol

- java.lang.Object
- - hlt.language.design.types.Symbol

-     public class Symbol
      extends java.lang.Object

  A symbol object is essentially a (global) name and its type table. The type table is a list of `CodeEntry` objects.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static Symbol` | `COLLECTION` This is a dummy symbol that is given the types allowed for collections.
    `static Symbol` | `INDEX_SET` This is a dummy symbol that is given the types allowed for array index sets.
    `static Symbol` | `INDEXABLE` This is a dummy symbol that is given the types allowed for map index sets.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Symbol(java.lang.String name)`
    `Symbol(java.lang.String name, int index)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `defineBuiltIn(Type type, Instruction builtIn)` Installs this symbol as a built-in with specified type and instruction.
    `boolean` | `equals(java.lang.Object other)`
    `CodeEntry` | `getCodeEntry(Type type)` Assigns and returns a `CodeEntry` corresponding to the specified `Type` for this symbol if one does not exist for with this type; otherwise, returns the existing one.
    `CodeEntry` | `getCodeEntry(Type type, boolean noDuplicates)` Assigns and returns a `CodeEntry` corresponding to the specified `Type` for this symbol if one does not exist for with this type.
    `int` | `index()`
    `boolean` | `isDefined()`
    `boolean` | `isDefined(Type type)`
    `java.lang.String` | `name()`
    `DefinedEntry` | `registerCodeEntry(Type type)` This method registers a definitively checked type of this global symbol.
    `void` | `removeLatestEntry()` Removes the latest code entry in this symbol's type table.
    `Symbol` | `setNoCurrying(boolean flag)`
    `void` | `showCodeEntries()`
    `void` | `showDefinedEntries()`
    `java.lang.String` | `toString()`
    `ArrayList` | `typeTable()`

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

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

- - ### Field Detail

    - #### INDEX_SET

          public static final Symbol INDEX_SET

      This is a dummy symbol that is given the types allowed for array index sets. It is used for type-checking array dimension expressions for allocation via a dummy `Global` constructed with this symbol, thus enabling a choice point to be created for typing these expressions.

    - #### INDEXABLE

          public static final Symbol INDEXABLE

      This is a dummy symbol that is given the types allowed for map index sets. It is used for type-checking array dimension expressions for allocation via a dummy `Global` constructed with this symbol, thus enabling a choice point to be created for typing these expressions.

    - #### COLLECTION

          public static final Symbol COLLECTION

      This is a dummy symbol that is given the types allowed for collections. It is used for type-checking it using a dummy `Global` constructed with this symbol, thus enabling choice points to be created for typing its expression.

  - ### Constructor Detail

    - #### Symbol

          public Symbol(java.lang.String name)

    - #### Symbol

          public Symbol(java.lang.String name,
                int index)

  - ### Method Detail

    - #### name

          public final java.lang.String name()

    - #### index

          public final int index()

    - #### typeTable

          public final ArrayList typeTable()

    - #### setNoCurrying

          public final Symbol setNoCurrying(boolean flag)

    - #### registerCodeEntry

          public final DefinedEntry registerCodeEntry(Type type)
                                               throws DefinitionException

      This method registers a definitively checked type of this global symbol. It is meant to be called only (and it is) by its namesake method in the class `Definition`, itself only called after type-checking of this symbol's definition has been completed; namely, after the `setCheckedType` method has been invoked on the definition, which ensures that its type argument has been standardized.
      Throws:
        `DefinitionException`

    - #### getCodeEntry

          public final CodeEntry getCodeEntry(Type type)

      Assigns and returns a `CodeEntry` corresponding to the specified `Type` for this symbol if one does not exist for with this type; otherwise, returns the existing one.

    - #### getCodeEntry

          public final CodeEntry getCodeEntry(Type type,
                               boolean noDuplicates)
                                       throws DuplicateCodeEntryException

      Assigns and returns a `CodeEntry` corresponding to the specified `Type` for this symbol if one does not exist for with this type. If the `noDuplicates` is true, a `DuplicateCodeEntryException` is thrown whenever an entry already existed for this type; otherwise, returns the existing code entry.
      Throws:
        `DuplicateCodeEntryException`

    - #### removeLatestEntry

          public final void removeLatestEntry()

      Removes the latest code entry in this symbol's type table.

    - #### defineBuiltIn

          public final void defineBuiltIn(Type type,
                           Instruction builtIn)
                                   throws DuplicateCodeEntryException

      Installs this symbol as a built-in with specified type and instruction. N.B.: If this type was defined for this symbol before, a `DuplicateCodeEntryException` is thrown.
      Throws:
        `DuplicateCodeEntryException`

    - #### isDefined

          public final boolean isDefined()

    - #### isDefined

          public final boolean isDefined(Type type)

    - #### equals

          public final boolean equals(java.lang.Object other)

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

    - #### showDefinedEntries

          public final void showDefinedEntries()

    - #### showCodeEntries

          public final void showCodeEntries()

    - #### toString

          public final java.lang.String toString()

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