Class TypeEnvironment
java.lang.Object
com.aquima.interactions.expressions.environment.TypeEnvironment
- All Implemented Interfaces:
ITypeEnvironment
This class is an implementation of the
ITypeEnvironment
interface which uses the TypeScope class to define
elements within the scope.- Since:
- 6.0
- Author:
- F. van der Meer
-
Constructor Summary
ConstructorDescriptionTypeEnvironment
(ITypeDefinitions definitions) Constructs this object with the initial definitions object. -
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 recordTypeName) This method checks if there is a record type for the specified name.lookupRecordType
(String entityType, Identifier ident) Looks up a record type accessor, person.name (name is a record type).lookupVariable
(Identifier typeName) 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.
-
Constructor Details
-
TypeEnvironment
Constructs this object with the initial definitions object. A definitions object contains all information for variables/objects/functions and templates.- Parameters:
definitions
- The definitions object which is mandatory.
-
-
Method Details
-
beginScope
public void beginScope()Description copied from interface:ITypeEnvironment
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.- Specified by:
beginScope
in interfaceITypeEnvironment
-
endScope
public void endScope()Description copied from interface:ITypeEnvironment
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.- Specified by:
endScope
in interfaceITypeEnvironment
-
declareVariableType
Description copied from interface:ITypeEnvironment
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.- Specified by:
declareVariableType
in interfaceITypeEnvironment
- Parameters:
variableName
- The name of the variable to use.type
- The type the variable name is bound to.
-
declareFieldType
Description copied from interface:ITypeEnvironment
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.- Specified by:
declareFieldType
in interfaceITypeEnvironment
- 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
Description copied from interface:ITypeEnvironment
Locates functions based on their name.- Specified by:
getFunctionDefinitions
in interfaceITypeEnvironment
- 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.
-
lookupRecordType
Description copied from interface:ITypeEnvironment
Looks up a record type accessor, person.name (name is a record type). If the type is found it will be returned- Specified by:
lookupRecordType
in interfaceITypeEnvironment
- Parameters:
entityType
- The type name of the record type ( entity )ident
- The accessor of the record type ( i.e. the attributename )- Returns:
- The type of the record identifier, null otherwise.
-
lookupRecordType
Description copied from interface:ITypeEnvironment
This method checks if there is a record type for the specified name.- Specified by:
lookupRecordType
in interfaceITypeEnvironment
- Parameters:
recordTypeName
- The type name identifier which is mandatory.- Returns:
- The Type object when available, null otherwise.
-
lookupVariable
Description copied from interface:ITypeEnvironment
Locates a variable as specified by the name. ( This method only checks the 'scope' and does not do type-as-name tricks )- Specified by:
lookupVariable
in interfaceITypeEnvironment
- Parameters:
typeName
- The variable name which is a mandatory parameter.- Returns:
- The type of this variable if it is known, null otherwise.
-
lookupVariable
Description copied from interface:ITypeEnvironment
Locates an object type with the specified instance name for the type name. If the object was not found null will be returned.- Specified by:
lookupVariable
in interfaceITypeEnvironment
- 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.
-
getExpressionTemplate
Description copied from interface:ITypeEnvironment
Locates an expression template based on its name.- Specified by:
getExpressionTemplate
in interfaceITypeEnvironment
- Parameters:
name
- The name of the expression template which is mandatory.- Returns:
- The expression template, null when not found.
-