Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
UnaryScalarOperator.cs
1using System;
2using System.Collections.Generic;
3using System.Threading.Tasks;
5
6namespace Waher.Script.Model
7{
11 public abstract class UnaryScalarOperator : UnaryOperator
12 {
22 {
23 }
24
32 {
33 if (Operand.IsScalar)
34 return this.EvaluateScalar(Operand, Variables);
35 else
36 {
37 LinkedList<IElement> Result = new LinkedList<IElement>();
38
39 foreach (IElement Child in Operand.ChildElements)
40 Result.AddLast(this.Evaluate(Child, Variables));
41
42 return Operand.Encapsulate(Result, this);
43 }
44 }
45
52 public override async Task<IElement> EvaluateAsync(IElement Operand, Variables Variables)
53 {
54 if (Operand.IsScalar)
55 return await this.EvaluateScalarAsync(Operand, Variables);
56 else
57 {
58 LinkedList<IElement> Result = new LinkedList<IElement>();
59
60 foreach (IElement Child in Operand.ChildElements)
61 Result.AddLast(await this.EvaluateAsync(Child, Variables));
62
63 return Operand.Encapsulate(Result, this);
64 }
65 }
66
74
81 public virtual Task<IElement> EvaluateScalarAsync(IElement Operand, Variables Variables)
82 {
83 return Task.FromResult<IElement>(this.EvaluateScalar(Operand, Variables));
84 }
85 }
86}
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
Base class for all unary operators.
Base class for unary scalar operators.
virtual Task< IElement > EvaluateScalarAsync(IElement Operand, Variables Variables)
Evaluates the operator on scalar operands.
abstract IElement EvaluateScalar(IElement Operand, Variables Variables)
Evaluates the operator on scalar operands.
override IElement Evaluate(IElement Operand, Variables Variables)
Evaluates the operator.
override async Task< IElement > EvaluateAsync(IElement Operand, Variables Variables)
Evaluates the operator.
UnaryScalarOperator(ScriptNode Operand, int Start, int Length, Expression Expression)
Base class for unary scalar operators.
Collection of variables.
Definition: Variables.cs:25
Basic interface for all types of elements.
Definition: IElement.cs:20