Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
And.cs
1using System;
6
8{
13 {
22 public And(ScriptNode Left, ScriptNode Right, int Start, int Length, Expression Expression)
23 : base(Left, Right, Start, Length, Expression)
24 {
25 }
26
33 public override IElement Evaluate(double Left, double Right)
34 {
35 ulong L, R;
36 bool LSigned;
37 bool RSigned;
38
39 if (Left != Math.Floor(Left) || Right != Math.Floor(Right))
40 throw new ScriptRuntimeException("Operands must be integer values.", this);
41
42 if (Left < 0)
43 {
44 LSigned = true;
45 if (Left < long.MinValue)
46 throw new ScriptRuntimeException("Operand out of bounds.", this);
47
48 L = (ulong)((long)Left);
49 }
50 else
51 {
52 LSigned = false;
53 if (Left > ulong.MaxValue)
54 throw new ScriptRuntimeException("Operand out of bounds.", this);
55
56 L = (ulong)Left;
57 }
58
59 if (Right < 0)
60 {
61 RSigned = true;
62 if (Right < long.MinValue)
63 throw new ScriptRuntimeException("Operand out of bounds.", this);
64
65 R = (ulong)((long)Right);
66 }
67 else
68 {
69 RSigned = false;
70 if (Right > ulong.MaxValue)
71 throw new ScriptRuntimeException("Operand out of bounds.", this);
72
73 R = (ulong)Right;
74 }
75
76 L &= R;
77
78 if (LSigned && RSigned)
79 return new DoubleNumber((long)L);
80 else
81 return new DoubleNumber(L);
82 }
83
84 }
85}
Class managing a script expression.
Definition: Expression.cs:39
Base class for binary double operators.
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
And(ScriptNode Left, ScriptNode Right, int Start, int Length, Expression Expression)
Binary And.
Definition: And.cs:22
override IElement Evaluate(double Left, double Right)
Evaluates the double operator.
Definition: And.cs:33
Basic interface for all types of elements.
Definition: IElement.cs:20