Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
PreIncrement.cs
6
8{
13 {
23 {
24 }
25
32 {
33 if (!Variables.TryGetVariable(this.variableName, out Variable v))
35
36 IElement Value = v.ValueElement;
37
38 if (Value.AssociatedObjectValue is double d)
39 Value = new DoubleNumber(d + 1);
40 else
41 Value = Increment(Value, this);
42
43 Variables[this.variableName] = Value;
44
45 return Value;
46 }
47
54 public static IElement Increment(IElement Value, ScriptNode Node)
55 {
57 return Operators.Arithmetics.Add.EvaluateAddition(Value, e.One, Node);
58 else if (Value.IsScalar)
59 throw new ScriptRuntimeException("Unable to increment variable.", Node);
60 else
61 {
63
64 foreach (IElement Element in Value.ChildElements)
65 Elements.Add(Increment(Element, Node));
66
67 return Value.Encapsulate(Elements, Node);
68 }
69 }
70
71 }
72}
A chunked list is a linked list of chunks of objects of type T .
Definition: ChunkedList.cs:54
Base class for all types of elements.
Definition: Element.cs:14
Class managing a script expression.
Definition: Expression.cs:41
readonly string variableName
Name of variable being referenced by the node.
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
static IElement Increment(IElement Value, ScriptNode Node)
Increments a value.
Definition: PreIncrement.cs:54
PreIncrement(string VariableName, int Start, int Length, Expression Expression)
Pre-Increment operator.
Definition: PreIncrement.cs:21
override IElement Evaluate(Variables Variables)
Evaluates the node, using the variables provided in the Variables collection.
Definition: PreIncrement.cs:31
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:56
Basic interface for all types of commutative ring with identity elements.
Basic interface for all types of elements.
Definition: IElement.cs:21
object AssociatedObjectValue
Associated object value.
Definition: IElement.cs:34
ICollection< IElement > ChildElements
An enumeration of child elements. If the element is a scalar, this property will return null.
Definition: IElement.cs:50
IElement Encapsulate(ChunkedList< IElement > Elements, ScriptNode Node)
Encapsulates a set of elements into a similar structure as that provided by the current element.
bool IsScalar
If the element represents a scalar value.
Definition: IElement.cs:42