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 Summary
Modifier and TypeMethodDescriptionvoid
This function starts a new scope in which types can be declared.void
declareFieldType
(String recordTypeName, Identifier name, Type type) This method declares a variable within a record-type object.void
declareVariableType
(Identifier variableName, Type type) This method declares a variable of a type within this scope.void
endScope()
This function ends the current scope and cleans up all the types declared within this scope.Locates an expression template based on its name.Locates functions based on their name.getSharedAncestor
(String expectedType, String receivedType) This function locates the shared ancestor type for the 2 passed arguments.lookupRecordType
(Identifier typeName) This method checks if there is a record type for the specified name.lookupRecordType
(String recordTypeName, Identifier name) Looks up a record type accessor, person.name (name is a record type).lookupVariable
(Identifier name) Locates a variable as specified by the name.lookupVariable
(String recordTypeName, Identifier instanceName) Locates an object type with the specified instance name for the type name.
-
Method Details
-
lookupVariable
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
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
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
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
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
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
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
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.