1using System.Collections.Generic;
3using System.Threading.Tasks;
17 private readonly
int nrElements;
42 private void CalcIsAsync()
46 for (
int i = 0; i < this.nrElements; i++)
74 LinkedList<IElement> List =
new LinkedList<IElement>();
93 return List.First.
Value;
96 if (List.First.Value.AssociatedObjectValue is
double Re &&
97 List.First.Next.Value.AssociatedObjectValue is
double Im)
117 LinkedList<IElement> List =
new LinkedList<IElement>();
136 return List.First.
Value;
139 if (List.First.Value.AssociatedObjectValue is
double Re &&
140 List.First.Next.Value.AssociatedObjectValue is
double Im)
161 if (!this.elements.ForAllChildNodes(Callback, State, Order))
166 bool RecalcIsAsync =
false;
169 for (i = 0; i < this.nrElements; i++)
171 Node = this.elements[i];
174 bool b = !Callback(Node, out
ScriptNode NewNode, State);
175 if (!(NewNode is
null))
177 this.elements[i] = Node = NewNode;
180 RecalcIsAsync =
true;
198 for (i = 0; i < this.nrElements; i++)
200 if (!this.elements.ForAllChildNodes(Callback, State, Order))
212 AreEqual(this.elements, O.elements) &&
219 int Result = base.GetHashCode();
220 Result ^= Result << 5 ^
GetHashCode(this.elements);
Class managing a script expression.
Base class for all nodes in a parsed script tree.
bool ForAllChildNodes(ScriptNodeEventHandler Callback, object State, bool DepthFirst)
Calls the callback method for all child nodes.
int Length
Length of expression covered by node.
static bool AreEqual(ScriptNode S1, ScriptNode S2)
Compares if two script nodes are equal.
int Start
Start position in script expression.
void SetParent(ScriptNode Parent)
Sets the parent node. Can only be used when expression is being parsed.
abstract IElement Evaluate(Variables Variables)
Evaluates the node, using the variables provided in the Variables collection. This method should be ...
virtual Task< IElement > EvaluateAsync(Variables Variables)
Evaluates the node, using the variables provided in the Variables collection. This method should be ...
static readonly ObjectValue Null
Null value.
object Value
Object value.
Represents a list of elements.
override int GetHashCode()
override bool Equals(object obj)
override bool IsAsynchronous
If the node (or its decendants) include asynchronous evaluation. Asynchronous nodes should be evaluat...
override bool ForAllChildNodes(ScriptNodeEventHandler Callback, object State, SearchMethod Order)
Calls the callback method for all child nodes.
override IElement Evaluate(Variables Variables)
Evaluates the node, using the variables provided in the Variables collection.
bool isAsync
If any of the elements are asynchronous
ElementList(ScriptNode[] Elements, int Start, int Length, Expression Expression)
Represents a list of elements.
override async Task< IElement > EvaluateAsync(Variables Variables)
Evaluates the node, using the variables provided in the Variables collection.
ScriptNode[] Elements
Elements.
static IElement Encapsulate(Array Elements, bool CanEncapsulateAsMatrix, ScriptNode Node)
Encapsulates the elements of a vector.
Basic interface for all types of elements.
delegate bool ScriptNodeEventHandler(ScriptNode Node, out ScriptNode NewNode, object State)
Delegate for ScriptNode callback methods.
SearchMethod
Method to traverse the expression structure