BadScript 2
Loading...
Searching...
No Matches
BadLogicNotExpression.cs
Go to the documentation of this file.
6
8
13{
20 right.IsConstant,
21 position
22 )
23 {
24 Right = right;
25 }
26
30 public BadExpression Right { get; }
31
33 public override IEnumerable<BadExpression> GetDescendants()
34 {
36 }
37
46 public static BadObject Not(BadObject left, BadSourcePosition pos)
47 {
48 if (left is IBadBoolean rBool)
49 {
50 return rBool.Value ? BadObject.False : BadObject.True;
51 }
52
53 throw new BadRuntimeException(
54 $"Cannot apply '!' to object '{left}'",
55 pos
56 );
57 }
58
66 public static IEnumerable<BadObject> NotWithOverride(
67 BadExecutionContext? context,
68 BadObject left,
69 BadSourcePosition position)
70 {
72 {
73 foreach (BadObject o in ExecuteOperatorOverride(left, context!, BadStaticKeys.NOT_OPERATOR_NAME, position))
74 {
75 yield return o;
76 }
77 }
78 else
79 {
80 yield return Not(left, position);
81 }
82 }
83
85 protected override IEnumerable<BadObject> InnerExecute(BadExecutionContext context)
86 {
88
89 foreach (BadObject o in Right.Execute(context))
90 {
91 r = o;
92 yield return o;
93 }
94
95 r = r.Dereference();
96
97 foreach (BadObject? o in NotWithOverride(context!, r, Position))
98 {
99 yield return o;
100 }
101 }
102
107 public override string ToString()
108 {
109 return $"!{Right}";
110 }
111}
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.
IEnumerable< BadExpression > GetDescendantsAndSelf()
Returns all Descendants of the Expression and the Expression itself.
BadSourcePosition Position
The source Position of the Expression.
IEnumerable< BadObject > Execute(BadExecutionContext context)
Evaluates the Expression within the current Execution Context.
bool IsConstant
Indicates if the expression stays constant at all times.
override string ToString()
Returns the string representation of the Expression.
static IEnumerable< BadObject > NotWithOverride(BadExecutionContext? context, BadObject left, BadSourcePosition position)
Executes the expression.
static BadObject Not(BadObject left, BadSourcePosition pos)
Returns true if the Input is false Returns false if the Input is true.
override IEnumerable< BadObject > InnerExecute(BadExecutionContext context)
BadLogicNotExpression(BadExpression right, BadSourcePosition position)
Constructor for the Logic Not 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 True
The True Value for the BadScript Language.
Definition BadObject.cs:33
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 Boolean.
Definition IBadBoolean.cs:7
Contains Shared Data Structures and Functionality.
Contains the Logic 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.