Interface ITypeEnvironment

All Known Implementing Classes:
TypeEnvironment

public interface ITypeEnvironment
This interface specifies a scoped parse time environment in which scoped-variables are connected to their types as well as functions.
Since:
6.0
Author:
F. van der Meer
  • Method Details

    • getSharedAncestor

      String getSharedAncestor(String expectedType, String receivedType)
      This function locates the shared ancestor type for the 2 passed arguments. It will try to find the 'first' shared ancestor within the ancestry tree. If they do not have a shared ancestor null will be returned.
      Parameters:
      expectedType - The first type argument.
      receivedType - The second type argument.
      Returns:
      A string representing the shared ancestor, null when they have no common ancestor.
    • lookupVariable

      Type lookupVariable(Identifier name)
      Locates a variable as specified by the name. ( This method only checks the 'scope' and does not do type-as-name tricks )
      Parameters:
      name - The variable name which is a mandatory parameter.
      Returns:
      The type of this variable if it is known, null otherwise.
    • lookupVariable

      Type lookupVariable(String recordTypeName, Identifier instanceName)
      Locates an object type with the specified instance name for the type name. If the object was not found null will be returned.
      Parameters:
      recordTypeName - The type name of the record-type (entity)
      instanceName - The instance name which is/should be unique for the specified recordTypeName
      Returns:
      The type object when the object could be found.
    • lookupRecordType

      Type lookupRecordType(String recordTypeName, Identifier name)
      Looks up a record type accessor, person.name (name is a record type). If the type is found it will be returned
      Parameters:
      recordTypeName - The type name of the record type ( entity )
      name - The accessor of the record type ( i.e. the attributename )
      Returns:
      The type of the record identifier, null otherwise.
    • lookupRecordType

      Type lookupRecordType(Identifier typeName)
      This method checks if there is a record type for the specified name.
      Parameters:
      typeName - The type name identifier which is mandatory.
      Returns:
      The Type object when available, null otherwise.
    • declareVariableType

      void declareVariableType(Identifier variableName, Type type)
      This method declares a variable of a type within this scope. Subsequent calls to lookupVariable will be able to see this variable as an existing variable.
      Parameters:
      variableName - The name of the variable to use.
      type - The type the variable name is bound to.
    • declareFieldType

      void declareFieldType(String recordTypeName, Identifier name, Type type)
      This method declares a variable within a record-type object. subsequent calls to lookupRecordVariable will be able to see this variable as an existing variable.
      Parameters:
      recordTypeName - the record type name ( entity type name )
      name - The name of the variable.
      type - The type the name within the record will be bound to.
    • getFunctionDefinitions

      IFunction[] getFunctionDefinitions(Identifier name)
      Locates functions based on their name.
      Parameters:
      name - The name of the function which is mandatory.
      Returns:
      An array containing all matching functions, an empty array is returned when there was no function with the specified name.
    • getExpressionTemplate

      IExpr getExpressionTemplate(Identifier name)
      Locates an expression template based on its name.
      Parameters:
      name - The name of the expression template which is mandatory.
      Returns:
      The expression template, null when not found.
    • beginScope

      void beginScope()
      This function starts a new scope in which types can be declared. It allows for variable (type) hiding until an end scope is called. Which in turn means a cleanup of the current scope.
    • endScope

      void endScope()
      This function ends the current scope and cleans up all the types declared within this scope. If an end scope is called while there was no begin scope called previously an exception is thrown.