2using System.Collections.Generic;
3using System.Threading.Tasks;
16 private readonly LinkedList<KeyValuePair<string, ScriptNode>> members;
17 private Dictionary<string, ScriptNode> quick =
null;
32 foreach (KeyValuePair<string, ScriptNode> P
in Members)
33 P.Value?.SetParent(
this);
38 private void CalcIsAsync()
42 foreach (KeyValuePair<string, ScriptNode> P
in this.members)
44 if (P.Value?.IsAsynchronous ??
false)
55 public LinkedList<KeyValuePair<string, ScriptNode>>
Members => this.members;
70 Dictionary<string, IElement> Result =
new Dictionary<string, IElement>();
72 foreach (KeyValuePair<string, ScriptNode> P
in this.members)
73 Result[P.Key] = P.Value.Evaluate(
Variables);
88 Dictionary<string, IElement> Result =
new Dictionary<string, IElement>();
90 foreach (KeyValuePair<string, ScriptNode> P
in this.members)
91 Result[P.Key] = await P.Value.EvaluateAsync(
Variables);
105 LinkedListNode<KeyValuePair<string, ScriptNode>> Loop;
109 Loop = this.members.First;
111 while (!(Loop is
null))
113 if (!(Loop.Value.Value?.ForAllChildNodes(Callback, State, Order) ??
true))
120 Loop = this.members.First;
123 bool RecalcIsAsync =
false;
125 while (!(Loop is
null))
127 Node = Loop.Value.Value;
130 bool Result = Callback(Node, out
ScriptNode NewNode, State);
131 if (!(NewNode is
null))
133 Loop.Value =
new KeyValuePair<string, ScriptNode>(Loop.Value.Key, NewNode);
134 NewNode.SetParent(
this);
137 RecalcIsAsync =
true;
157 Loop = this.members.First;
159 while (!(Loop is
null))
161 if (!(Loop.Value.Value?.ForAllChildNodes(Callback, State, Order) ??
true))
177 LinkedList<KeyValuePair<string, ScriptNode>>.Enumerator e1 = this.members.GetEnumerator();
178 LinkedList<KeyValuePair<string, ScriptNode>>.Enumerator e2 = O.members.GetEnumerator();
182 bool b1 = e1.MoveNext();
183 bool b2 = e2.MoveNext();
191 KeyValuePair<string, ScriptNode> Item1 = e1.Current;
192 KeyValuePair<string, ScriptNode> Item2 = e2.Current;
194 if (!Item1.Key.Equals(Item2.Key) ||
195 !Item1.Value.Equals(Item2.Value))
205 int Result = base.GetHashCode();
207 foreach (KeyValuePair<string, ScriptNode> P
in this.members)
209 Result ^= Result << 5 ^ P.Key.GetHashCode();
210 Result ^= Result << 5 ^ P.Value.GetHashCode();
230 foreach (KeyValuePair<string, IElement> P
in Object)
232 if (!this.quick.ContainsKey(P.Key))
236 foreach (KeyValuePair<string, ScriptNode> P
in this.members)
238 if (Object.TryGetValue(P.Key, out
IElement E))
239 Result = P.Value.PatternMatch(E, AlreadyFound);
251 foreach (KeyValuePair<string, object> P
in Object2)
253 if (!this.quick.ContainsKey(P.Key))
257 foreach (KeyValuePair<string, ScriptNode> P
in this.members)
259 if (Object2.TryGetValue(P.Key, out
object E))
277 foreach (KeyValuePair<string, string> P
in Object3)
279 if (!this.quick.ContainsKey(P.Key))
283 foreach (KeyValuePair<string, ScriptNode> P
in this.members)
285 if (Object3.TryGetValue(P.Key, out
string s))
286 Result = P.Value.PatternMatch(
new StringValue(s), AlreadyFound);
300 private void CheckQuick()
302 if (this.quick is
null)
304 Dictionary<string, ScriptNode> Quick =
new Dictionary<string, ScriptNode>();
306 foreach (KeyValuePair<string, ScriptNode> N
in this.members)
307 Quick[N.Key] = N.Value;
Class managing a script expression.
static IElement Encapsulate(object Value)
Encapsulates an object.
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.
int Start
Start position in script expression.
static readonly ObjectValue Null
Null value.
Creates an object from nothing.
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 bool Equals(object obj)
override async Task< IElement > EvaluateAsync(Variables Variables)
Evaluates the node, using the variables provided in the Variables collection.
ObjectExNihilo(LinkedList< KeyValuePair< string, ScriptNode > > Members, int Start, int Length, Expression Expression)
Creates an object from nothing.
override IElement Evaluate(Variables Variables)
Evaluates the node, using the variables provided in the Variables collection.
override int GetHashCode()
override PatternMatchResult PatternMatch(IElement CheckAgainst, Dictionary< string, IElement > AlreadyFound)
Performs a pattern match operation.
LinkedList< KeyValuePair< string, ScriptNode > > Members
Members, in order of definition.
static IElement Encapsulate(Array Elements, bool CanEncapsulateAsMatrix, ScriptNode Node)
Encapsulates the elements of a vector.
Basic interface for all types of elements.
object AssociatedObjectValue
Associated object value.
delegate bool ScriptNodeEventHandler(ScriptNode Node, out ScriptNode NewNode, object State)
Delegate for ScriptNode callback methods.
PatternMatchResult
Status result of a pattern matching operation.
SearchMethod
Method to traverse the expression structure