BadScript 2
Loading...
Searching...
No Matches
BadLogicOrExpression.cs
Go to the documentation of this file.
6
8
13{
21 left,
22 right,
23 position
24 ) { }
25
27 protected override IEnumerable<BadObject> InnerExecute(BadExecutionContext context)
28 {
30
31 foreach (BadObject o in Left.Execute(context))
32 {
33 left = o;
34
35 yield return o;
36 }
37
38 left = left.Dereference();
39
40 if (left is not IBadBoolean lBool)
41 {
42 throw new BadRuntimeException($"Can not apply operator '{GetSymbol()}' to {left}. expected boolean", Position);
43 }
44
45 {
46 if (lBool.Value)
47 {
48 yield return BadObject.True;
49
50 yield break;
51 }
52
53 BadObject right = BadObject.Null;
54
55 foreach (BadObject o in Right.Execute(context))
56 {
57 right = o;
58
59 yield return o;
60 }
61
62 right = right.Dereference();
63
64 if (right is not IBadBoolean rBool)
65 {
66 throw new BadRuntimeException($"Can not apply operator '{GetSymbol()}' to {left} and {right}", Position);
67 }
68
69 if (rBool.Value)
70 {
71 yield return BadObject.True;
72 }
73 else
74 {
75 yield return BadObject.False;
76 }
77 }
78 }
79
81 protected override string GetSymbol()
82 {
83 return "||";
84 }
85}
Describes a specific position inside a source file.
Base Implementation for all Expressions used inside the Script.
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.
BadLogicOrExpression(BadExpression left, BadExpression right, BadSourcePosition position)
Constructor of the Logic Or Expression.
override IEnumerable< BadObject > InnerExecute(BadExecutionContext context)
The Execution Context. Every execution of a script needs a context the script is running in....
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
static readonly BadObject False
The False Value for the BadScript Language.
Definition BadObject.cs:38
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.