Class EzrObject
- Namespace
- EzrSquared.Runtime.Types
- Assembly
- ezrSquared-lib.dll
The base root class of all built-in objects. Provides utility functions and bare-minimum operator handling.
public abstract class EzrObject : IEzrObject
- Inheritance
-
objectEzrObject
- Implements
- Derived
Constructors
EzrObject(Context, Position, Position)
Creates a new object with the specified parent context and position.
public EzrObject(Context parentContext, Position startPosition, Position endPosition)
Parameters
parentContextContextThe context in which this object was created.
startPositionPositionThe starting position of the object.
endPositionPositionThe ending position of the object.
EzrObject(Context?, Context, Position, Position)
Creates a new object with the specified internal context, parent context and position.
public EzrObject(Context? context, Context parentContext, Position startPosition, Position endPosition)
Parameters
contextContextThe internal context, if null, creates a new one.
parentContextContextThe context in which this object was created.
startPositionPositionThe starting position of the object.
endPositionPositionThe ending position of the object.
Fields
_executionContext
The current context in which the operation is being executed.
protected internal Context _executionContext
Field Value
_hashTag
The hash of Tag.
private int _hashTag
Field Value
- int
s_reflectionCache
Cache of reflection data for all EzrObject types.
internal static readonly ConcurrentDictionary<(Type ParentType, string MemberName), MemberInfo> s_reflectionCache
Field Value
- ConcurrentDictionary<(Type ParentType, string MemberName), MemberInfo>
Properties
Context
The Context of the object.
public Context Context { get; private set; }
Property Value
CreationContext
The context under which the object was created.
public Context CreationContext { get; private set; }
Property Value
EndPosition
The ending position of the object in source code.
public Position EndPosition { get; private set; }
Property Value
HashTag
The hash of Tag.
public int HashTag { get; }
Property Value
- int
IsReadOnly
Is the current object read-only?
public bool IsReadOnly { get; protected internal set; }
Property Value
- bool
StartPosition
The starting position of the object in source code.
public Position StartPosition { get; private set; }
Property Value
Tag
The tag of the type of this object, similar to C# namespace naming conventions.
public virtual string Tag { get; protected internal set; }
Property Value
- string
TypeName
The name of the type of this object, in plain text, all lowercase. Spaces are allowed.
public virtual string TypeName { get; protected internal set; }
Property Value
- string
Methods
Addition(IEzrObject, RuntimeResult)
Performs the addition operation between the current object and another.
public virtual void Addition(IEzrObject other, RuntimeResult result)
Parameters
otherIEzrObjectThe other object in the operation.
resultRuntimeResultRuntime result for carrying the result and any errors.
Affirmation(RuntimeResult)
Affirms the current object.
public virtual void Affirmation(RuntimeResult result)
Parameters
resultRuntimeResultRuntime result for carrying the result and any errors.
BitwiseAnd(IEzrObject, RuntimeResult)
Performs the bit-wise AND operation between the current object and another.
public virtual void BitwiseAnd(IEzrObject other, RuntimeResult result)
Parameters
otherIEzrObjectThe other object in the operation.
resultRuntimeResultRuntime result for carrying the result and any errors.
BitwiseLeftShift(IEzrObject, RuntimeResult)
Performs the bit-wise left-shift operation between the current object and another.
public virtual void BitwiseLeftShift(IEzrObject other, RuntimeResult result)
Parameters
otherIEzrObjectThe other object in the operation.
resultRuntimeResultRuntime result for carrying the result and any errors.
BitwiseNegation(RuntimeResult)
Bit-wise negates the current object.
public virtual void BitwiseNegation(RuntimeResult result)
Parameters
resultRuntimeResultRuntime result for carrying the result and any errors.
BitwiseOr(IEzrObject, RuntimeResult)
Performs the bit-wise OR operation between the current object and another.
public virtual void BitwiseOr(IEzrObject other, RuntimeResult result)
Parameters
otherIEzrObjectThe other object in the operation.
resultRuntimeResultRuntime result for carrying the result and any errors.
BitwiseRightShift(IEzrObject, RuntimeResult)
Performs the bit-wise right-shift operation between the current object and another.
public virtual void BitwiseRightShift(IEzrObject other, RuntimeResult result)
Parameters
otherIEzrObjectThe other object in the operation.
resultRuntimeResultRuntime result for carrying the result and any errors.
BitwiseXOr(IEzrObject, RuntimeResult)
Performs the bit-wise X-OR operation between the current object and another.
public virtual void BitwiseXOr(IEzrObject other, RuntimeResult result)
Parameters
otherIEzrObjectThe other object in the operation.
resultRuntimeResultRuntime result for carrying the result and any errors.
ComparisonEqual(IEzrObject, RuntimeResult)
Compares the object to another, checks equality.
public virtual void ComparisonEqual(IEzrObject other, RuntimeResult result)
Parameters
otherIEzrObjectThe other object in the operation.
resultRuntimeResultRuntime result for carrying the result and any errors.
ComparisonGreaterThan(IEzrObject, RuntimeResult)
Compares the object to another, checks if the current object is greater than the other.
public virtual void ComparisonGreaterThan(IEzrObject other, RuntimeResult result)
Parameters
otherIEzrObjectThe other object in the operation.
resultRuntimeResultRuntime result for carrying the result and any errors.
ComparisonGreaterThanOrEqual(IEzrObject, RuntimeResult)
Compares the object to another, checks if the current object is greater than or equal to the other.
public virtual void ComparisonGreaterThanOrEqual(IEzrObject other, RuntimeResult result)
Parameters
otherIEzrObjectThe other object in the operation.
resultRuntimeResultRuntime result for carrying the result and any errors.
ComparisonLessThan(IEzrObject, RuntimeResult)
Compares the object to another, checks if the current object is less than the other.
public virtual void ComparisonLessThan(IEzrObject other, RuntimeResult result)
Parameters
otherIEzrObjectThe other object in the operation.
resultRuntimeResultRuntime result for carrying the result and any errors.
ComparisonLessThanOrEqual(IEzrObject, RuntimeResult)
Compares the object to another, checks if the current object is less than or equal to the other.
public virtual void ComparisonLessThanOrEqual(IEzrObject other, RuntimeResult result)
Parameters
otherIEzrObjectThe other object in the operation.
resultRuntimeResultRuntime result for carrying the result and any errors.
ComparisonNotEqual(IEzrObject, RuntimeResult)
Compares the object to another, checks unequality.
public virtual void ComparisonNotEqual(IEzrObject other, RuntimeResult result)
Parameters
otherIEzrObjectThe other object in the operation.
resultRuntimeResultRuntime result for carrying the result and any errors.
ComputeHashCode(RuntimeResult)
Evaluates the current object as its hash.
public virtual int ComputeHashCode(RuntimeResult result)
Parameters
resultRuntimeResultRuntime result for carrying any errors.
Returns
- int
The evaluated value.
Division(IEzrObject, RuntimeResult)
Performs the division operation between the current object and another.
public virtual void Division(IEzrObject other, RuntimeResult result)
Parameters
otherIEzrObjectThe other object in the operation.
resultRuntimeResultRuntime result for carrying the result and any errors.
EvaluateBoolean(RuntimeResult)
Evaluates the current object as a boolean value.
public virtual bool EvaluateBoolean(RuntimeResult result)
Parameters
resultRuntimeResultRuntime result for carrying any errors.
Returns
- bool
The evaluated value.
Execute(Reference[], Interpreter, RuntimeResult)
Executes the current object, like a function.
public virtual void Execute(Reference[] arguments, Interpreter interpreter, RuntimeResult result)
Parameters
argumentsReference[]The arguments of the execution.
interpreterInterpreterThe interpreter to be used in execution.
resultRuntimeResultRuntime result for carrying the result and any errors.
~EzrObject()
Destructor.
protected ~EzrObject()
GetMemberInfo<TMemberInfo, TParentType>(string)
Gets cached reflection data about a member of TParentType.
internal static TMemberInfo? GetMemberInfo<TMemberInfo, TParentType>(string name) where TMemberInfo : MemberInfo
Parameters
namestringThe name of the member.
Returns
- TMemberInfo
The cached member data or the first member with the given
name. null if not found.
Type Parameters
TMemberInfoThe System.Reflection.MemberInfo type to return.
TParentTypeThe type which the member is a part of.
Remarks
If there is no cached data, it gets it by reflection and caches the result.
HasValueContained(IEzrObject, RuntimeResult)
Checks if the other object is contained in the current object.
public virtual void HasValueContained(IEzrObject other, RuntimeResult result)
Parameters
otherIEzrObjectThe other object in the operation.
resultRuntimeResultRuntime result for carrying the result and any errors.
IllegalOperation()
Creates an illegal operation error based on the current context and position.
protected internal EzrIllegalOperationError IllegalOperation()
Returns
- EzrIllegalOperationError
The error.
IllegalOperation(IEzrObject, bool)
Creates an illegal operation error based on the current context and position and another object.
protected internal EzrIllegalOperationError IllegalOperation(IEzrObject other, bool isRightHandSide = true)
Parameters
otherIEzrObjectisRightHandSidebool
Returns
- EzrIllegalOperationError
The error.
Interpret(Node, Context, Interpreter, RuntimeResult, bool)
Interprets an AST node in context of the current object.
public virtual void Interpret(Node code, Context callingContext, Interpreter interpreter, RuntimeResult result, bool ignoreUndefinedVariable = false)
Parameters
codeNodeThe node to interpret.
callingContextContextThe context calling on this action.
interpreterInterpreterThe interpreter to use.
resultRuntimeResultRuntime result for carrying the result and any errors.
ignoreUndefinedVariableboolShould the interpretation ignore undefined variables? Useful in getting empty variable references.
Inversion(RuntimeResult)
Inverts the current object, like, for example, true to false.
public virtual void Inversion(RuntimeResult result)
Parameters
resultRuntimeResultRuntime result for carrying the result and any errors.
Modulo(IEzrObject, RuntimeResult)
Performs the modulo operation between the current object and another.
public virtual void Modulo(IEzrObject other, RuntimeResult result)
Parameters
otherIEzrObjectThe other object in the operation.
resultRuntimeResultRuntime result for carrying the result and any errors.
Multiplication(IEzrObject, RuntimeResult)
Performs the multiplication operation between the current object and another.
public virtual void Multiplication(IEzrObject other, RuntimeResult result)
Parameters
otherIEzrObjectThe other object in the operation.
resultRuntimeResultRuntime result for carrying the result and any errors.
Negation(RuntimeResult)
Negates the current object.
public virtual void Negation(RuntimeResult result)
Parameters
resultRuntimeResultRuntime result for carrying the result and any errors.
NewArrayConstant(IEzrObject[])
Creates a new array constant.
protected internal Reference NewArrayConstant(IEzrObject[] elements)
Parameters
elementsIEzrObject[]The raw array value.
Returns
- Reference
The constant.
NewBooleanConstant(bool)
Creates a new boolean constant.
protected internal static Reference NewBooleanConstant(bool value)
Parameters
valueboolThe raw boolean value.
Returns
- Reference
The constant.
NewCharacterConstant(char)
Creates a new character constant.
protected internal Reference NewCharacterConstant(char value)
Parameters
valuecharThe raw character value.
Returns
- Reference
The constant.
NewCharacterListConstant(string)
Creates a new character list constant.
protected internal Reference NewCharacterListConstant(string value)
Parameters
valuestringThe raw float value.
Returns
- Reference
The constant.
NewDictionaryConstant(RuntimeEzrObjectDictionary)
Creates a new dictionary constant.
protected internal Reference NewDictionaryConstant(RuntimeEzrObjectDictionary dictionary)
Parameters
dictionaryRuntimeEzrObjectDictionaryThe raw dictionary value.
Returns
- Reference
The constant.
NewFloatConstant(double)
Creates a new float constant.
protected internal Reference NewFloatConstant(double value)
Parameters
valuedoubleThe raw float value.
Returns
- Reference
The constant.
NewIntegerConstant(BigInteger)
Creates a new integer constant.
protected internal Reference NewIntegerConstant(BigInteger value)
Parameters
valueBigIntegerThe raw integer value.
Returns
- Reference
The constant.
NewListConstant(RuntimeEzrObjectList)
Creates a new list constant.
protected internal Reference NewListConstant(RuntimeEzrObjectList elements)
Parameters
elementsRuntimeEzrObjectListThe raw list value.
Returns
- Reference
The constant.
NewNothingConstant()
Creates a new "nothing" constant.
protected internal static Reference NewNothingConstant()
Returns
- Reference
The constant.
NewStringConstant(string)
Creates a new string constant.
protected internal Reference NewStringConstant(string value)
Parameters
valuestringThe raw string value.
Returns
- Reference
The constant.
NotHasValueContained(IEzrObject, RuntimeResult)
Checks if the other object is NOT contained in the current object.
public virtual void NotHasValueContained(IEzrObject other, RuntimeResult result)
Parameters
otherIEzrObjectThe other object in the operation.
resultRuntimeResultRuntime result for carrying the result and any errors.
Power(IEzrObject, RuntimeResult)
Performs the power or exponent operation between the current object and another.
public virtual void Power(IEzrObject other, RuntimeResult result)
Parameters
otherIEzrObjectThe other object in the operation.
resultRuntimeResultRuntime result for carrying the result and any errors.
StrictEquals(IEzrObject, RuntimeResult)
Strictly compares the current object to another, taking into account inheritance.
public virtual bool StrictEquals(IEzrObject other, RuntimeResult result)
Parameters
otherIEzrObjectThe other object in the operation.
resultRuntimeResultRuntime result for carrying any errors.
Returns
- bool
Subtraction(IEzrObject, RuntimeResult)
Performs the subtraction operation between the current object and another.
public virtual void Subtraction(IEzrObject other, RuntimeResult result)
Parameters
otherIEzrObjectThe other object in the operation.
resultRuntimeResultRuntime result for carrying the result and any errors.
ToPureString(RuntimeResult)
Evaluates the current object as a string value.
public virtual string ToPureString(RuntimeResult result)
Parameters
resultRuntimeResultRuntime result for carrying any errors.
Returns
- string
The evaluated value.
Remarks
This is used to show the 'real' string representation of the object. Like, for example, ToString(RuntimeResult) will
return "example" when called on an EzrString object with value "example", but this function will return example (without quotes).
ToString(RuntimeResult)
Evaluates the current object as a string value.
public virtual string ToString(RuntimeResult result)
Parameters
resultRuntimeResultRuntime result for carrying any errors.
Returns
- string
The evaluated value.
Update(Context, Position, Position)
Updates the context and position of the object.
public void Update(Context context, Position startPosition, Position endPosition)
Parameters
contextContextThe new context of the object.
startPositionPositionThe new starting position of the object.
endPositionPositionThe new ending position of the object.
UpdateCreationContext(Context)
Changes CreationContext and the parent of Context. Be careful when you use this function.
public void UpdateCreationContext(Context newCreationContext)
Parameters
newCreationContextContextThe new creation context.