Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
VectorDoWhileDefinition.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 do
39 {
40 try
41 {
42 Elements.Add(this.left.Evaluate(Variables));
43 }
45 {
46 if (ex.HasLoopValue)
47 Elements.Add(ex.LoopValue);
48
49 //ScriptBreakLoopException.Reuse(ex);
50 break;
51 }
53 {
54 if (ex.HasLoopValue)
55 Elements.Add(ex.LoopValue);
56
57 //ScriptContinueLoopException.Reuse(ex);
58 }
59
60 Condition = this.right.Evaluate(Variables) as BooleanValue;
61 if (Condition is null)
63 }
64 while (Condition.Value);
65
66 return this.Encapsulate(Elements);
67 }
68
74 public override async Task<IElement> EvaluateAsync(Variables Variables)
75 {
76 if (!this.isAsync)
77 return this.Evaluate(Variables);
78
80 BooleanValue Condition;
81
82 do
83 {
84 try
85 {
86 Elements.Add(await this.left.EvaluateAsync(Variables));
87 }
89 {
90 if (ex.HasLoopValue)
91 Elements.Add(ex.LoopValue);
92
93 //ScriptBreakLoopException.Reuse(ex);
94 break;
95 }
97 {
98 if (ex.HasLoopValue)
99 Elements.Add(ex.LoopValue);
100
101 //ScriptContinueLoopException.Reuse(ex);
102 }
103
104 Condition = await this.right.EvaluateAsync(Variables) as BooleanValue;
105 if (Condition is null)
107 }
108 while (Condition.Value);
109
110 return this.Encapsulate(Elements);
111 }
112
118 protected virtual IElement Encapsulate(ChunkedList<IElement> Elements)
119 {
120 return VectorDefinition.Encapsulate(Elements, true, this);
121 }
122
123 }
124}
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 DO-WHILE 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.
VectorDoWhileDefinition(DoWhile Elements, int Start, int Length, Expression Expression)
Creates a vector using a DO-WHILE statement.
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