BadScript 2
Loading...
Searching...
No Matches
BadGreaterOrEqualExpression.cs
Go to the documentation of this file.
6
8
14{
22 left,
23 right,
24 position
25 ) { }
26
36 {
37 if (left is IBadNumber lNum && right is IBadNumber rNum)
38 {
39 return lNum.Value >= rNum.Value ? BadObject.True : BadObject.False;
40 }
41
42 throw new BadRuntimeException($"Can not apply operator '>=' to {left} and {right}", pos);
43 }
44
53 public static IEnumerable<BadObject> GreaterOrEqualWithOverride(
54 BadExecutionContext? context,
55 BadObject left,
56 BadObject right,
57 BadSourcePosition position)
58 {
60 {
62 left,
63 right,
64 context!,
66 position
67 ))
68 {
69 yield return o;
70 }
71 }
73 {
75 right,
76 left,
77 context!,
79 position
80 ))
81 {
82 yield return o;
83 }
84 }
85 else
86 {
87 yield return GreaterOrEqual(left, right, position);
88 }
89 }
90
91 protected override IEnumerable<BadObject> InnerExecute(BadExecutionContext context)
92 {
94
95 foreach (BadObject o in Left.Execute(context))
96 {
97 left = o;
98
99 yield return o;
100 }
101
102 left = left.Dereference();
103 BadObject right = BadObject.Null;
104
105 foreach (BadObject o in Right.Execute(context))
106 {
107 right = o;
108
109 yield return o;
110 }
111
112 right = right.Dereference();
113
114 foreach (BadObject o in GreaterOrEqualWithOverride(context, left, right, Position))
115 {
116 yield return o;
117 }
118 }
119
120 protected override string GetSymbol()
121 {
122 return ">=";
123 }
124}
Describes a specific position inside a source file.
Contains Static Data for the BadScript Language.
Base Implementation for all Expressions used inside the Script.
static IEnumerable< BadObject > ExecuteOperatorOverride(BadObject left, BadObject right, BadExecutionContext context, string name, BadSourcePosition position)
Helper function that executes an operator override function if implemented.
BadSourcePosition Position
The source Position of the Expression.
IEnumerable< BadObject > Execute(BadExecutionContext context)
Evaluates the Expression within the current Execution Context.
Base Implementation of all Binary Expressions.
BadExpression Right
Right side of the Expression.
static IEnumerable< BadObject > GreaterOrEqualWithOverride(BadExecutionContext? context, BadObject left, BadObject right, BadSourcePosition position)
Executes the expression.
static BadObject GreaterOrEqual(BadObject left, BadObject right, BadSourcePosition pos)
Returns true if the left side is greater or equal to the right side.
BadGreaterOrEqualExpression(BadExpression left, BadExpression right, BadSourcePosition position)
Constructor of the Greater or Equal Expression.
override IEnumerable< BadObject > InnerExecute(BadExecutionContext context)
The Execution Context. Every execution of a script needs a context the script is running in....
BadScope Scope
The Root Scope of the Context.
The Base Class for all BadScript Objects.
Definition BadObject.cs:14
static readonly BadObject False
The False Value for the BadScript Language.
Definition BadObject.cs:38
virtual bool HasProperty(string propName, BadScope? caller=null)
Returns true if the object contains a given property or there exists an extension for the current Ins...
Definition BadObject.cs:118
static readonly BadObject Null
The Null Value for the BadScript Language.
Definition BadObject.cs:28
Implements the Interface for Native Numbers.
Definition IBadNumber.cs:7
Contains Shared Data Structures and Functionality.
Contains the Comparison Expressions for the BadScript2 Language.
Contains the Error Objects for the BadScript2 Language.
Contains the Native Runtime Objects.
Definition BadBoolean.cs:6
Contains the Runtime Objects.
Definition BadArray.cs:10
Contains the Runtime Implementation.