Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
VectorWhileDoDefinition.cs
1using System.Threading.Tasks;
8
10{
15 {
24 : base(Elements.LeftOperand, Elements.RightOperand, Start, Length, Expression)
25 {
26 }
27
34 {
36 BooleanValue Condition;
37
38 Condition = this.left.Evaluate(Variables) as BooleanValue;
39 if (Condition is null)
41
42 while (Condition.Value)
43 {
44 try
45 {
46 Elements.Add(this.right.Evaluate(Variables));
47 }
49 {
50 if (ex.HasLoopValue)
51 Elements.Add(ex.LoopValue);
52
53 //ScriptBreakLoopException.Reuse(ex);
54 break;
55 }
57 {
58 if (ex.HasLoopValue)
59 Elements.Add(ex.LoopValue);
60
61 //ScriptContinueLoopException.Reuse(ex);
62 }
63
64 Condition = this.left.Evaluate(Variables) as BooleanValue;
65 if (Condition is null)
67 }
68
69 return this.Encapsulate(Elements);
70 }
71
77 public override async Task<IElement> EvaluateAsync(Variables Variables)
78 {
79 if (!this.isAsync)
80 return this.Evaluate(Variables);
81
83 BooleanValue Condition;
84
85 Condition = await this.left.EvaluateAsync(Variables) as BooleanValue;
86 if (Condition is null)
88
89 while (Condition.Value)
90 {
91 try
92 {
93 Elements.Add(await this.right.EvaluateAsync(Variables));
94 }
96 {
97 if (ex.HasLoopValue)
98 Elements.Add(ex.LoopValue);
99
100 //ScriptBreakLoopException.Reuse(ex);
101 break;
102 }
104 {
105 if (ex.HasLoopValue)
106 Elements.Add(ex.LoopValue);
107
108 //ScriptContinueLoopException.Reuse(ex);
109 }
110
111 Condition = await this.left.EvaluateAsync(Variables) as BooleanValue;
112 if (Condition is null)
114 }
115
116 return this.Encapsulate(Elements);
117 }
123 protected virtual IElement Encapsulate(ChunkedList<IElement> Elements)
124 {
125 return VectorDefinition.Encapsulate(Elements, true, this);
126 }
127
128 }
129}
A chunked list is a linked list of chunks of objects of type T .
Definition: ChunkedList.cs:54
void Add(T Item)
Adds an item to the collection.
Definition: ChunkedList.cs:272
Exception thrown if condition does not evaluate to a Boolean value.
IElement LoopValue
Value to include in the loop's result.
bool HasLoopValue
If LoopValue contains a value that should be included in the loop's result.
Class managing a script expression.
Definition: Expression.cs:41
Base class for all binary operators.
ScriptNode RightOperand
Right operand.
ScriptNode LeftOperand
Left operand.
ScriptNode right
Right operand.
ScriptNode left
Left operand.
bool isAsync
If subtree is asynchroneous.
int Length
Length of expression covered by node.
Definition: ScriptNode.cs:101
int Start
Start position in script expression.
Definition: ScriptNode.cs:92
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 ...
Definition: ScriptNode.cs:158
Boolean-valued number.
Definition: BooleanValue.cs:12
static IElement Encapsulate(Array Elements, bool CanEncapsulateAsMatrix, ScriptNode Node)
Encapsulates the elements of a vector.
Creates a vector using a WHILE-DO statement.
VectorWhileDoDefinition(WhileDo Elements, int Start, int Length, Expression Expression)
Creates a vector using a WHILE-DO statement.
override async Task< IElement > EvaluateAsync(Variables Variables)
Evaluates the node, using the variables provided in the Variables collection.
override IElement Evaluate(Variables Variables)
Evaluates the node, using the variables provided in the Variables collection.
virtual IElement Encapsulate(ChunkedList< IElement > Elements)
Encapsulates the calculated elements.
Collection of variables.
Definition: Variables.cs:25
Basic interface for all types of elements.
Definition: IElement.cs:21