1using System.Collections.Generic;
2using System.Threading.Tasks;
16 private readonly
In[] setConditions;
34 Sets.ImplicitSetDefinition.SeparateConditions(Conditions, out this.setConditions, out this.otherConditions);
44 IEnumerable<IElement> VectorElements;
45 bool CanEncapsulateAsMatrix;
47 if (this.
right is
null)
49 VectorElements =
null;
50 CanEncapsulateAsMatrix =
true;
55 CanEncapsulateAsMatrix = (E is
IMatrix);
58 if (VectorElements is
null)
63 this.setConditions, this.otherConditions,
Variables);
65 if (!(Elements is ICollection<IElement> Elements2))
67 Elements2 =
new List<IElement>();
86 IEnumerable<IElement> VectorElements;
87 bool CanEncapsulateAsMatrix;
89 if (this.
right is
null)
91 VectorElements =
null;
92 CanEncapsulateAsMatrix =
true;
97 CanEncapsulateAsMatrix = (E is
IMatrix);
100 if (VectorElements is
null)
105 this.setConditions, this.otherConditions,
Variables);
107 if (!(Elements is ICollection<IElement> Elements2))
109 Elements2 =
new List<IElement>();
135 if (!(this.setConditions?.
ForAllChildNodes(Callback, State, Order) ??
true))
138 if (!(this.otherConditions?.
ForAllChildNodes(Callback, State, Order) ??
true))
145 bool RecalcIsAsync =
false;
148 if (!(this.
left is
null))
150 b = !Callback(this.
left, out NewNode, State);
151 if (!(NewNode is
null))
156 RecalcIsAsync =
true;
159 if (b || (Order ==
SearchMethod.TreeOrder && !
this.left.ForAllChildNodes(Callback, State, Order)))
168 if (!(this.
right is
null))
170 b = !Callback(this.
right, out NewNode, State);
171 if (!(NewNode is
null))
173 this.right = NewNode;
176 RecalcIsAsync =
true;
179 if (b || (Order ==
SearchMethod.TreeOrder && !
this.right.ForAllChildNodes(Callback, State, Order)))
188 if (!(this.setConditions is
null))
190 for (i = 0, c = this.setConditions.Length; i < c; i++)
192 Node = this.setConditions[i];
195 b = !Callback(Node, out NewNode, State);
196 if (!(NewNode is
null) && NewNode is
In NewIn)
198 this.setConditions[i] = NewIn;
199 NewIn.SetParent(
this);
202 RecalcIsAsync =
true;
216 if (!(this.otherConditions is
null))
218 for (i = 0, c = this.otherConditions.Length; i < c; i++)
220 Node = this.otherConditions[i];
223 b = !Callback(Node, out NewNode, State);
224 if (!(NewNode is
null))
226 this.otherConditions[i] = NewNode;
227 NewNode.SetParent(
this);
230 RecalcIsAsync =
true;
255 if (!(this.setConditions?.
ForAllChildNodes(Callback, State, Order) ??
true))
258 if (!(this.otherConditions?.
ForAllChildNodes(Callback, State, Order) ??
true))
269 AreEqual(this.setConditions, O.setConditions) &&
270 AreEqual(this.otherConditions, O.otherConditions) &&
277 int Result = base.GetHashCode();
278 Result ^= Result << 5 ^
GetHashCode(this.setConditions);
279 Result ^= Result << 5 ^
GetHashCode(this.otherConditions);
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
static async Task< IEnumerable< IElement > > CalculateElementsAsync(ScriptNode Pattern, IEnumerable< IElement > SuperSetElements, In[] SetConditions, ScriptNode[] OtherConditions, Variables Variables)
Calculates elements specified using implicit notation.
static IEnumerable< IElement > GetSetMembers(IElement E)
Gets the elements of a (supposed) set.
static IEnumerable< IElement > CalculateElements(ScriptNode Pattern, IEnumerable< IElement > SuperSetElements, In[] SetConditions, ScriptNode[] OtherConditions, Variables Variables)
Calculates elements specified using implicit notation.
Defines a vector, by implicitly limiting its members to members of an optional vector,...
override bool Equals(object obj)
override async Task< IElement > EvaluateAsync(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 IElement Evaluate(Variables Variables)
Evaluates the node, using the variables provided in the Variables collection.
ImplicitVectorDefinition(ScriptNode Pattern, ScriptNode Vector, ScriptNode[] Conditions, int Start, int Length, Expression Expression)
Defines a vector, by implicitly limiting its members to members of an optional vector,...
override int GetHashCode()
static IElement Encapsulate(Array Elements, bool CanEncapsulateAsMatrix, ScriptNode Node)
Encapsulates the elements of a vector.
Basic interface for all types of elements.
Basic interface for matrices.
delegate bool ScriptNodeEventHandler(ScriptNode Node, out ScriptNode NewNode, object State)
Delegate for ScriptNode callback methods.
SearchMethod
Method to traverse the expression structure