Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
DoWhile.cs
1using System.Threading.Tasks;
6
8{
12 public class DoWhile : BinaryOperator
13 {
22 public DoWhile(ScriptNode Statement, ScriptNode Condition, int Start, int Length, Expression Expression)
23 : base(Statement, Condition, Start, Length, Expression)
24 {
25 }
26
33 {
35 BooleanValue Condition;
36
37 do
38 {
39 try
40 {
41 Last = this.left.Evaluate(Variables);
42 }
44 {
45 if (ex.HasLoopValue)
46 Last = ex.LoopValue;
47
48 //ScriptBreakLoopException.Reuse(ex);
49 break;
50 }
52 {
53 if (ex.HasLoopValue)
54 Last = ex.LoopValue;
55
56 //ScriptContinueLoopException.Reuse(ex);
57 }
58
59 Condition = this.right.Evaluate(Variables) as BooleanValue;
60 if (Condition is null)
62 }
63 while (Condition.Value);
64
65 return Last;
66 }
67
73 public override async Task<IElement> EvaluateAsync(Variables Variables)
74 {
75 if (!this.isAsync)
76 return this.Evaluate(Variables);
77
79 BooleanValue Condition;
80
81 do
82 {
83 try
84 {
85 Last = await this.left.EvaluateAsync(Variables);
86 }
88 {
89 if (ex.HasLoopValue)
90 Last = ex.LoopValue;
91
92 //ScriptBreakLoopException.Reuse(ex);
93 break;
94 }
96 {
97 if (ex.HasLoopValue)
98 Last = ex.LoopValue;
99
100 //ScriptContinueLoopException.Reuse(ex);
101 }
102
103 Condition = await this.right.EvaluateAsync(Variables) as BooleanValue;
104 if (Condition is null)
106 }
107 while (Condition.Value);
108
109 return Last;
110 }
111 }
112}
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 right
Right operand.
ScriptNode left
Left operand.
bool isAsync
If subtree is asynchroneous.
Base class for all nodes in a parsed script tree.
Definition: ScriptNode.cs:69
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 readonly ObjectValue Null
Null value.
Definition: ObjectValue.cs:88
DoWhile(ScriptNode Statement, ScriptNode Condition, int Start, int Length, Expression Expression)
DO-WHILE operator.
Definition: DoWhile.cs:22
override async Task< IElement > EvaluateAsync(Variables Variables)
Evaluates the node, using the variables provided in the Variables collection.
Definition: DoWhile.cs:73
override IElement Evaluate(Variables Variables)
Evaluates the node, using the variables provided in the Variables collection.
Definition: DoWhile.cs:32
Collection of variables.
Definition: Variables.cs:25
Basic interface for all types of elements.
Definition: IElement.cs:21