BadScript 2
Loading...
Searching...
No Matches
BadEqualityExpression.cs
Go to the documentation of this file.
4
9
15{
23 left,
24 right,
25 position
26 ) { }
27
34 public static BadObject Equal(BadObject left, BadObject right)
35 {
36 return left.Equals(right) ? BadObject.True : BadObject.False;
37 }
38
47 public static IEnumerable<BadObject> EqualWithOverride(
48 BadExecutionContext? caller,
49 BadObject left,
50 BadObject right,
51 BadSourcePosition position)
52 {
54 {
56 left,
57 right,
58 caller!,
60 position
61 ))
62 {
63 yield return o;
64 }
65 }
66 else if (right.HasProperty(BadStaticKeys.EQUAL_OPERATOR_NAME, caller?.Scope))
67 {
69 right,
70 left,
71 caller!,
73 position
74 ))
75 {
76 yield return o;
77 }
78 }
79 else
80 {
81 yield return Equal(left, right);
82 }
83 }
84
85
87 protected override IEnumerable<BadObject> InnerExecute(BadExecutionContext context)
88 {
90
91 foreach (BadObject o in Left.Execute(context))
92 {
93 left = o;
94
95 yield return o;
96 }
97
98 left = left.Dereference();
99 BadObject right = BadObject.Null;
100
101 foreach (BadObject o in Right.Execute(context))
102 {
103 right = o;
104
105 yield return o;
106 }
107
108 right = right.Dereference();
109
110 foreach (BadObject o in EqualWithOverride(context, left, right, Position))
111 {
112 yield return o;
113 }
114 }
115
116
118 protected override string GetSymbol()
119 {
120 return "==";
121 }
122}
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.
override IEnumerable< BadObject > InnerExecute(BadExecutionContext context)
static BadObject Equal(BadObject left, BadObject right)
Returns true if the left side is equal to the right side.
static IEnumerable< BadObject > EqualWithOverride(BadExecutionContext? caller, BadObject left, BadObject right, BadSourcePosition position)
Executes the operator override for the given operator name.
BadEqualityExpression(BadExpression left, BadExpression right, BadSourcePosition position)
Constructor of the Equality Expression.
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
Contains Shared Data Structures and Functionality.
Contains the Comparison Expressions for the BadScript2 Language.
Contains the Runtime Objects.
Definition BadArray.cs:10
Contains the Runtime Implementation.