BadScript 2
Loading...
Searching...
No Matches
BadLogicXOrExpression.cs
Go to the documentation of this file.
6
8
13{
21 left,
22 right,
23 position
24 ) { }
25
34 public static BadObject XOr(BadObject left, BadObject right, BadSourcePosition pos)
35 {
36 if (left is IBadBoolean lBool && right is IBadBoolean rBool)
37 {
38 return lBool.Value ^ rBool.Value ? BadObject.True : BadObject.False;
39 }
40
41 throw new BadRuntimeException($"Can not apply operator '^' to {left} and {right}", pos);
42 }
43
45 protected override IEnumerable<BadObject> InnerExecute(BadExecutionContext context)
46 {
48
49 foreach (BadObject o in Left.Execute(context))
50 {
51 left = o;
52
53 yield return o;
54 }
55
56 left = left.Dereference();
57 BadObject right = BadObject.Null;
58
59 foreach (BadObject o in Right.Execute(context))
60 {
61 right = o;
62
63 yield return o;
64 }
65
66 right = right.Dereference();
67
68 yield return XOr(left, right, Position);
69 }
70
72 protected override string GetSymbol()
73 {
74 return "^";
75 }
76}
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.
BadLogicXOrExpression(BadExpression left, BadExpression right, BadSourcePosition position)
Constructor of the Logic Exclusive Or Expression.
static BadObject XOr(BadObject left, BadObject right, BadSourcePosition pos)
Returns true if left or right are true. False if both are true.
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 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.