Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
AddToSelf.cs
1using System.Threading.Tasks;
5
7{
11 public class AddToSelf : Assignment
12 {
23 {
24 }
25
32 {
33 if (!Variables.TryGetVariable(this.VariableName, out Variable v))
34 throw new ScriptRuntimeException("Variable not found.", this);
35
36 IElement E = this.op.Evaluate(Variables);
37 E = Arithmetics.Add.EvaluateAddition(v.ValueElement, E, this);
38
39 Variables[this.VariableName] = E;
40
41 return E;
42 }
43
49 public override async Task<IElement> EvaluateAsync(Variables Variables)
50 {
51 if (!this.isAsync)
52 return this.Evaluate(Variables);
53
54 if (!Variables.TryGetVariable(this.VariableName, out Variable v))
55 throw new ScriptRuntimeException("Variable not found.", this);
56
57 IElement E = await this.op.EvaluateAsync(Variables);
58 E = Arithmetics.Add.EvaluateAddition(v.ValueElement, E, this);
59
60 Variables[this.VariableName] = E;
61
62 return E;
63 }
64 }
65}
Class managing a script expression.
Definition: Expression.cs:39
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
bool isAsync
If subtree is asynchroneous.
override async Task< IElement > EvaluateAsync(Variables Variables)
Evaluates the node, using the variables provided in the Variables collection.
Definition: AddToSelf.cs:49
override IElement Evaluate(Variables Variables)
Evaluates the node, using the variables provided in the Variables collection.
Definition: AddToSelf.cs:31
AddToSelf(string VariableName, ScriptNode Operand, int Start, int Length, Expression Expression)
Add to self operator.
Definition: AddToSelf.cs:21
Contains information about a variable.
Definition: Variable.cs:10
Collection of variables.
Definition: Variables.cs:25
virtual bool TryGetVariable(string Name, out Variable Variable)
Tries to get a variable object, given its name.
Definition: Variables.cs:52
Basic interface for all types of elements.
Definition: IElement.cs:20