1using System.Collections.Generic;
2using System.Threading.Tasks;
17 private readonly
In[] setConditions;
19 private readonly
bool doubleColon;
35 this.doubleColon = DoubleColon;
50 List<In> SetConditionList =
null;
51 List<ScriptNode> OtherConditionList =
null;
52 int i, j, c = Conditions.
Length;
54 for (i = 0; i < c; i++)
58 if (Condition is
In In)
60 if (SetConditionList is
null)
62 SetConditionList =
new List<In>();
66 OtherConditionList =
new List<ScriptNode>();
68 for (j = 0; j < i; j++)
69 OtherConditionList.Add(Conditions[j]);
73 SetConditionList.Add(
In);
75 else if (!(SetConditionList is
null))
77 if (OtherConditionList is
null)
78 OtherConditionList =
new List<ScriptNode>();
80 OtherConditionList.Add(Condition);
84 if (!(SetConditionList is
null))
86 OtherConditions = OtherConditionList?.ToArray();
87 SetConditions = SetConditionList.ToArray();
91 OtherConditions = Conditions;
105 if (this.
right is
null)
111 if (SuperSet is
null)
130 if (this.
right is
null)
136 if (SuperSet is
null)
160 if (!(this.setConditions?.
ForAllChildNodes(Callback, State, Order) ??
true))
163 if (!(this.otherConditions?.
ForAllChildNodes(Callback, State, Order) ??
true))
170 bool RecalcIsAsync =
false;
173 if (!(this.
left is
null))
175 b = !Callback(this.
left, out NewNode, State);
176 if (!(NewNode is
null))
181 RecalcIsAsync =
true;
184 if (b || (Order ==
SearchMethod.TreeOrder && !
this.left.ForAllChildNodes(Callback, State, Order)))
193 if (!(this.
right is
null))
195 b = !Callback(this.
right, out NewNode, State);
196 if (!(NewNode is
null))
198 this.right = NewNode;
201 RecalcIsAsync =
true;
204 if (b || (Order ==
SearchMethod.TreeOrder && !
this.right.ForAllChildNodes(Callback, State, Order)))
213 if (!(this.setConditions is
null))
215 for (i = 0, c = this.setConditions.Length; i < c; i++)
217 Node = this.setConditions[i];
220 b = !Callback(Node, out NewNode, State);
221 if (!(NewNode is
null) && NewNode is
In NewIn)
223 this.setConditions[i] = NewIn;
224 NewIn.SetParent(
this);
227 RecalcIsAsync =
true;
241 if (!(this.otherConditions is
null))
243 for (i = 0, c = this.otherConditions.Length; i < c; i++)
245 Node = this.otherConditions[i];
248 b = !Callback(Node, out NewNode, State);
249 if (!(NewNode is
null))
251 this.otherConditions[i] = NewNode;
252 NewNode.SetParent(
this);
255 RecalcIsAsync =
true;
280 if (!(this.setConditions?.
ForAllChildNodes(Callback, State, Order) ??
true))
283 if (!(this.otherConditions?.
ForAllChildNodes(Callback, State, Order) ??
true))
294 this.doubleColon.
Equals(O.doubleColon) &&
295 AreEqual(this.setConditions, O.setConditions) &&
296 AreEqual(this.otherConditions, O.otherConditions) &&
303 int Result = base.GetHashCode();
304 Result ^= Result << 5 ^ this.doubleColon.GetHashCode();
305 Result ^= Result << 5 ^
GetHashCode(this.setConditions);
306 Result ^= Result << 5 ^
GetHashCode(this.otherConditions);
Base class for all types of sets.
static ISet ToSet(IElement E)
Converts (if necessary) the element E into a set.
Script runtime exception.
Class managing a script expression.
Base class for all binary operators.
virtual void CalcIsAsync()
Recalculates if operator is asynchronous or not.
ScriptNode right
Right operand.
ScriptNode left
Left operand.
bool isAsync
If subtree is asynchroneous.
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 ...
Represents an implicitly defined set
Defines a set, by implicitly limiting its members to members of an optional superset,...
override bool Equals(object obj)
ImplicitSetDefinition(ScriptNode Pattern, ScriptNode SuperSet, ScriptNode[] Conditions, bool DoubleColon, int Start, int Length, Expression Expression)
Defines a set, by implicitly limiting its members to members of an optional superset,...
override IElement Evaluate(Variables Variables)
Evaluates the node, using the variables provided in the Variables collection.
override bool ForAllChildNodes(ScriptNodeEventHandler Callback, object State, SearchMethod Order)
Calls the callback method for all child nodes.
override int GetHashCode()
override async Task< IElement > EvaluateAsync(Variables Variables)
Evaluates the node, using the variables provided in the Variables collection.
static void SeparateConditions(ScriptNode[] Conditions, out In[] SetConditions, out ScriptNode[] OtherConditions)
Separates conditions into set membership conditions and other types of conditions.
Basic interface for all types of elements.
Basic interface for all types of sets.
delegate bool ScriptNodeEventHandler(ScriptNode Node, out ScriptNode NewNode, object State)
Delegate for ScriptNode callback methods.
SearchMethod
Method to traverse the expression structure