The ezr² Project 0.1.1
The codebase for the ezr² programming language.
|
Stores all user defined variables/constant references, called symbols. More...
Public Types | |
enum | GetStatus { Ok , UndefinedSymbolAccessNotAllowed , AccessToPrivateSymbolNotAllowed , StaticAccessWithoutDefinedContextNotAllowed , InvalidGlobalPrivateAccessNotAllowed } |
Represents the status of a Get(Context?, string, out Reference, AccessMod, bool) call. More... | |
enum | SetStatus { Ok , ConstantAssignmentNotAllowed , PrivateSymbolAssignmentNotAllowed , SymbolAccessibilityChangeInParentNotAllowed , PrivateSymbolAssignmentInChildNotAllowed , UnregisteredSymbolScopeOrVariabilityChangeNotAllowed , StaticAssignmentWithoutDefinedContextNotAllowed , InvalidGlobalPrivateAssignmentNotAllowed } |
Represents the status of a set call. More... | |
Public Member Functions | |
Context (string name, bool isStatic, Position startPosition, Context? parent=null, Context? staticContext=null, int linkedContexts=0) | |
Creates a new Context. | |
void | SetNewLinkedContexts (int contexts) |
Clears the existing LinkedContexts and creates a new empty Array of Contexts. | |
void | UpdateStaticContext (Context? newStaticContext) |
Updates the StaticContext to a new one. | |
void | UpdateParent (Context newParent) |
Updates the parent of this Context/. | |
void | UpdatePosition (Position startPosition) |
Updates the starting Position of this Context/. | |
GetStatus | Get (Context? callingContext, string symbol, out Reference objectReference, AccessMod accessibilityModifiers=AccessMod.None, bool ignoreLinkedContexts=false) |
Retrieves the Reference of the requested symbol. | |
Reference | Set (Context? callingContext,(IEzrObject Object, string Name) newObject, Reference oldReference, AccessMod accessibilityModifiers=AccessMod.None) |
SetStatus | Set (Context? callingContext, string symbol, Reference objectReference) |
Sets the Reference to a new symbol. | |
bool | IsDefined (string name) |
Checks if a symbol has been defined in this Context/. | |
Context? | DeepCopy (RuntimeResult result, IEzrObject[] excludedSymbols) |
Creates a deep copy of the context. | |
void | Release () |
Releases all references in the context and clears the symbols dictionary. | |
Public Attributes | |
readonly string | Name |
The name of the Context. | |
readonly long | Id |
The unique identifier of the Context. | |
readonly bool | IsStatic |
Is this a static Context? | |
Static Public Attributes | |
static readonly Context | Empty = new(string.Empty, false, Position.None) |
An empty context. | |
Properties | |
int | Count [get] |
The number of symbols in the context. | |
Position | StartPosition [get, private set] |
The starting Position of the Context. | |
Context[] | LinkedContexts [get, private set] |
Other Contexts which are linked to this. | |
Context? | Parent [get, private set] |
The parent of this Context. May be null . | |
Context? | StaticContext [get, private set] |
The static Context in relation to this Context. May be null . | |
Private Member Functions | |
bool | IsContextParent (Context context) |
Checks if the given Context is a parent of this Context. | |
~Context () | |
Destructor. | |
Private Attributes | |
Dictionary< string, Reference > | _symbols |
The symbols of this Context. | |
Stores all user defined variables/constant references, called symbols.
Represents the status of a Get(Context?, string, out Reference, AccessMod, bool) call.
Enumerator | |
---|---|
Ok | The operation was successful. |
UndefinedSymbolAccessNotAllowed | The requested symbol was not found. |
AccessToPrivateSymbolNotAllowed | Accessing privates symbols from Contexts without permission is not allowed. |
StaticAccessWithoutDefinedContextNotAllowed | Cannot access static symbols without a known static Context. |
InvalidGlobalPrivateAccessNotAllowed | Cannot access symbols with both AccessMod.Global and AccessMod.Private accessibility modifiers. |
Represents the status of a set call.
Sets a new IEzrObject to an existing Reference.
This includes both Set(Context?, string, Reference) and Set(Context?, ValueTuple<IEzrObject, string>, Reference, AccessMod).
If oldReference is Reference.Empty, the operation is passed onto Set(Context?, string, Reference).
callingContext | The Context from which the operation is being called. |
newObject | The new IEzrObject to be assigned and the name of the symbol, in the format (IEzrObject Object, string Name). |
oldReference | The old reference to assign to. |
accessibilityModifiers | Accessibility modifiers of the operation, AccessMod.None by default. |
Enumerator | |
---|---|
Ok | The operation was successful. |
ConstantAssignmentNotAllowed | Assigning new values to a constant reference is not allowed. |
PrivateSymbolAssignmentNotAllowed | Assigning privates symbols from Contexts without permission is not allowed. |
SymbolAccessibilityChangeInParentNotAllowed | Changing the accessibility of an existing symbol in a parent Context is not allowed. |
PrivateSymbolAssignmentInChildNotAllowed | Assigning a private symbol to a child Context is not allowed. |
UnregisteredSymbolScopeOrVariabilityChangeNotAllowed | Changing the accessibility of a symbol which has not been assigned to a Context is not allowed. |
StaticAssignmentWithoutDefinedContextNotAllowed | Assigning static symbols without a known static Context is not allowed. |
InvalidGlobalPrivateAssignmentNotAllowed | Cannot assign symbols with both AccessMod.Global and AccessMod.Private accessibility modifiers. |
EzrSquared.Runtime.Context.Context | ( | string | name, |
bool | isStatic, | ||
Position | startPosition, | ||
Context? | parent = null, | ||
Context? | staticContext = null, | ||
int | linkedContexts = 0 ) |
Creates a new Context.
name | The name of the Context. |
isStatic | Is this a static Context? |
startPosition | The starting Position of the Context. |
parent | The parent of this Context. Can be null . |
staticContext | The static Context in relation to this Context. Can be null . |
linkedContexts | The number of other Contexts which are linked to this. See
|
Context? EzrSquared.Runtime.Context.DeepCopy | ( | RuntimeResult | result, |
IEzrObject[] | excludedSymbols ) |
Creates a deep copy of the context.
It is the caller's responsibility to handle linked contexts.
result | Runtime result for raising errors/ |
excludedSymbols | Symbols to exclude when copying. |
null
if failed.GetStatus EzrSquared.Runtime.Context.Get | ( | Context? | callingContext, |
string | symbol, | ||
out Reference | objectReference, | ||
AccessMod | accessibilityModifiers = AccessMod::None, | ||
bool | ignoreLinkedContexts = false ) |
Retrieves the Reference of the requested symbol.
callingContext | The Context from which the operation is being called. |
symbol | The symbol to retrieve. |
objectReference | The resulting Reference. |
accessibilityModifiers | Accessibility modifiers of the operation, AccessMod.None by default. |
ignoreLinkedContexts | Should the Context ignore its linked contexts? (Used mainly for retrieving a reference before symbol assignment) |
|
private |
bool EzrSquared.Runtime.Context.IsDefined | ( | string | name | ) |
Checks if a symbol has been defined in this Context/.
name | The name of the symbol to check. |
true
if it is, false
otherwise.void EzrSquared.Runtime.Context.SetNewLinkedContexts | ( | int | contexts | ) |
Clears the existing LinkedContexts and creates a new empty Array of Contexts.
contexts | The number of Contexts to allocate the Array for. |
void EzrSquared.Runtime.Context.UpdateParent | ( | Context | newParent | ) |
void EzrSquared.Runtime.Context.UpdatePosition | ( | Position | startPosition | ) |
void EzrSquared.Runtime.Context.UpdateStaticContext | ( | Context? | newStaticContext | ) |
Updates the StaticContext to a new one.
newStaticContext | The new static Context. |
|
getprivate set |
Other Contexts which are linked to this.
This allowed the Interpreter to access variables from multiple Contexts while in a local scope.