Class EnvironmentBuilder
- Namespace
- MuLang.Core.Environment
- Assembly
- MuLang.Core.dll
Builds an environment schema for MuLang compilation and execution.
public sealed class EnvironmentBuilder
- Inheritance
-
EnvironmentBuilder
- Inherited Members
Constructors
EnvironmentBuilder()
public EnvironmentBuilder()
Methods
AddFunction(string, string, IEnumerable<ParameterSymbol>, TypeSymbol)
Adds a provider function to the environment.
public EnvironmentBuilder AddFunction(string id, string name, IEnumerable<ParameterSymbol> parameters, TypeSymbol returnType)
Parameters
idstringThe provider identifier.
namestringThe language name.
parametersIEnumerable<ParameterSymbol>The function parameters.
returnTypeTypeSymbolThe function return type.
Returns
- EnvironmentBuilder
The same EnvironmentBuilder instance, for chaining.
Exceptions
- ArgumentNullException
Thrown when
parametersorreturnTypeisnull.- ArgumentException
Thrown when a symbol value is invalid or its name or identifier is already registered.
AddGlobal(string, string, TypeSymbol)
Adds a global value to the environment.
public EnvironmentBuilder AddGlobal(string id, string name, TypeSymbol type)
Parameters
idstringThe provider identifier.
namestringThe language name.
typeTypeSymbolThe type.
Returns
- EnvironmentBuilder
The same EnvironmentBuilder instance, for chaining.
Exceptions
- ArgumentNullException
Thrown when
typeisnull.- ArgumentException
Thrown when a symbol value is invalid or its name or identifier is already registered.
AddType(ObjectTypeSymbol)
Adds a structured type to the environment.
public EnvironmentBuilder AddType(ObjectTypeSymbol type)
Parameters
typeObjectTypeSymbolThe type.
Returns
- EnvironmentBuilder
The same EnvironmentBuilder instance, for chaining.
Exceptions
- ArgumentNullException
Thrown when
typeisnull.- ArgumentException
Thrown when the type is anonymous or its name or identifier is already registered.
Build(LanguageVersion)
Creates an immutable environment schema from the registered symbols.
public EnvironmentSchema Build(LanguageVersion languageVersion = LanguageVersion.Version1_2)
Parameters
languageVersionLanguageVersionThe language version.
Returns
- EnvironmentSchema
The immutable environment schema.
Exceptions
- ArgumentOutOfRangeException
Thrown when
languageVersionis not defined.- InvalidOperationException
Thrown when a symbol name is reserved in the selected language version or a referenced structured type is not registered by the same instance.