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

hlt.osf.exec

## Class Context

- java.lang.Object
- - hlt.osf.exec.Context

-     public class Context
      extends java.lang.Object

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Context()` Constructs a new sort ordering context.
    `Context(int sortCodeArraySize)` Constructs a new sort ordering context with the specified sort code array size.
    `Context(int sortCodeArraySize, float namedSortTableFactor, float cachCodeTableFactor)` Constructs a new sort ordering context with the specified sort code array size, the named sort table's size factor, and the code cache's size.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static byte` | `AND()`
    `static byte` | `BNT()`
    `static Sort` | `bottom()` Returns the bottom sort symbol.
    `java.util.HashMap` | `codeCache()` Returns this OSF context's table associating a bit code to the sort it denotes if there is one, or the set of sorts that are its maximal lower bounds as an array or sorts.
    `void` | `declareIsa(java.lang.String s1, java.lang.String s2, Locatable where)` This declares that the sort named `s1` is a subsort of the sort named `s2`.
    `java.lang.Object` | `decode(BitCode code)` Given a bit code, this returns the object that it corresponds to in the current taxonomy.
    `java.lang.String` | `decodedString(BitCode code)` This returns a string form of the sorts whose codes are maximal lower bounds of the specified code.
    `static byte` | `DIS()`
    `DisplayManager` | `displayManager()`
    `void` | `encodeSorts()` Encodes all the sorts of this sort ordering context's taxonomy.
    `void` | `encodeSorts(int first, int last)` Encodes the sorts between index first and index last (both inclusive) of this sort ordering context's taxonomy.
    `ErrorLogger` | `errorLogger()`
    `BitCode` | `evaluate(SortExpression expression)` Compiles and evaluates the specified sort expression.
    `Sort` | `getSort(java.lang.String sortName)` If the specified name is an undefined sort, this defines the sort with this name initializing it in the sort array.
    `BitCode` | `getSortCode(java.lang.String name)` This returns the bit code of the sort bearing the specified name.
    `static boolean` | `isTracing()`
    `SortExpression` | `lastExpression()` Returns the last sort expression evaluated in this context.
    `java.util.HashMap` | `namedSorts()` Returns this OSF context's table associating a name to the sort it denotes.
    `static byte` | `NOT()`
    `static byte` | `OR()`
    `void` | `reset()` Resets this sort ordering context to a "virginal" state, preserving only built-in sorts.
    `void` | `setDisplayManager(DisplayManager displayManager)`
    `static byte` | `SYM()`
    `static void` | `tallyCodeCopy()`
    `Taxonomy` | `taxonomy()` Returns this OSF context's array where sorts are recorded.
    `static void` | `toggleTracing()`
    `static Sort` | `top()` Returns the top sort symbol.

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

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

- - ### Constructor Detail

    - #### Context

          public Context()

      Constructs a new sort ordering context.

    - #### Context

          public Context(int sortCodeArraySize)

      Constructs a new sort ordering context with the specified sort code array size.

    - #### Context

          public Context(int sortCodeArraySize,
                 float namedSortTableFactor,
                 float cachCodeTableFactor)

      Constructs a new sort ordering context with the specified sort code array size, the named sort table's size factor, and the code cache's size. These factors set the corresponding tables' sizes as multiple of the size of the sort code array.

  - ### Method Detail

    - #### taxonomy

          public Taxonomy taxonomy()

      Returns this OSF context's array where sorts are recorded.

    - #### errorLogger

          public ErrorLogger errorLogger()

    - #### top

          public static Sort top()
                          throws LockedCodeArrayException

      Returns the top sort symbol. This is safe only if the taxonomy has been encoded.
      Throws:
        `LockedCodeArrayException`

    - #### bottom

          public static Sort bottom()
                             throws LockedCodeArrayException

      Returns the bottom sort symbol. This is safe only if the taxonomy has been encoded.
      Throws:
        `LockedCodeArrayException`

    - #### reset

          public void reset()

      Resets this sort ordering context to a "virginal" state, preserving only built-in sorts.

    - #### namedSorts

          public java.util.HashMap namedSorts()

      Returns this OSF context's table associating a name to the sort it denotes.

    - #### codeCache

          public java.util.HashMap codeCache()

      Returns this OSF context's table associating a bit code to the sort it denotes if there is one, or the set of sorts that are its maximal lower bounds as an array or sorts.

    - #### getSort

          public Sort getSort(java.lang.String sortName)
                       throws UndefinedSymbolException

      If the specified name is an undefined sort, this defines the sort with this name initializing it in the sort array. Returns the defined sort with its context set to this one.
      Throws:
        `UndefinedSymbolException`

    - #### getSortCode

          public BitCode getSortCode(java.lang.String name)
                              throws LockedCodeArrayException,
                                     UndefinedSymbolException

      This returns the bit code of the sort bearing the specified name.
      Throws:
        `LockedCodeArrayException`
        `UndefinedSymbolException`

    - #### decodedString

          public java.lang.String decodedString(BitCode code)

      This returns a string form of the sorts whose codes are maximal lower bounds of the specified code. It is empty, this is bottom. If its cardinality is equal to the number of defined sorts, this is top. Otherwise, it checks the code cache in case this code had already been decoded before. Otherwise, it compute its maximal lower bounds and records it in the code cache before returning is display form.

    - #### decode

          public java.lang.Object decode(BitCode code)

      Given a bit code, this returns the object that it corresponds to in the current taxonomy. This object may be either a sort, or a disjunctive set of its maximal subsorts represented as a bit code set of these subsorts' indices.

    - #### declareIsa

          public void declareIsa(java.lang.String s1,
                        java.lang.String s2,
                        Locatable where)
                          throws LockedCodeArrayException,
                                 CyclicSortOrderingException

      This declares that the sort named `s1` is a subsort of the sort named `s2`. This assumes that the sort ordering has not been encoded yet.
      Throws:
        `LockedCodeArrayException`
        `CyclicSortOrderingException`

    - #### encodeSorts

          public void encodeSorts()
                           throws AnomalousSituationException

      Encodes all the sorts of this sort ordering context's taxonomy.
      Throws:
        `AnomalousSituationException`

    - #### encodeSorts

          public void encodeSorts(int first,
                         int last)
                           throws AnomalousSituationException

      Encodes the sorts between index first and index last (both inclusive) of this sort ordering context's taxonomy.
      Throws:
        `AnomalousSituationException`

    - #### displayManager

          public DisplayManager displayManager()

    - #### setDisplayManager

          public void setDisplayManager(DisplayManager displayManager)

    - #### SYM

          public static final byte SYM()

    - #### DIS

          public static final byte DIS()

    - #### NOT

          public static final byte NOT()

    - #### AND

          public static final byte AND()

    - #### OR

          public static final byte OR()

    - #### BNT

          public static final byte BNT()

    - #### lastExpression

          public SortExpression lastExpression()
                                        throws LockedCodeArrayException,
                                               AnomalousSituationException

      Returns the last sort expression evaluated in this context.
      Throws:
        `LockedCodeArrayException`
        `AnomalousSituationException`

    - #### evaluate

          public BitCode evaluate(SortExpression expression)
                           throws LockedCodeArrayException

      Compiles and evaluates the specified sort expression.
      Throws:
        `LockedCodeArrayException`

    - #### toggleTracing

          public static void toggleTracing()

    - #### isTracing

          public static boolean isTracing()

    - #### tallyCodeCopy

          public static void tallyCodeCopy()