BadScript 2
Loading...
Searching...
No Matches
BadLogicAssignXOrExpression.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 {
29 bool hasReturn = false;
31
32 foreach (BadObject o in Left.Execute(context))
33 {
34 left = o;
35
36 yield return o;
37 }
38
39 if (left is not BadObjectReference leftRef)
40 {
41 throw new BadRuntimeException($"Left side of {GetSymbol()} must be a reference", Position);
42 }
43
44 left = left.Dereference();
45
46 BadObject right = BadObject.Null;
47
48 foreach (BadObject o in Right.Execute(context))
49 {
50 right = o;
51
52 yield return o;
53 }
54
55 right = right.Dereference();
56
57 if (left is IBadBoolean lBool && right is IBadBoolean rBool)
58 {
59 hasReturn = true;
60
61 BadObject r = BadObject.Wrap(lBool.Value ^ rBool.Value);
62 leftRef.Set(r);
63
64 yield return r;
65 }
66
67 if (!hasReturn)
68 {
69 throw new BadRuntimeException($"Can not apply operator '{GetSymbol()}' to {left} and {right}", Position);
70 }
71 }
72
74 protected override string GetSymbol()
75 {
76 return "^=";
77 }
78}
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.
override IEnumerable< BadObject > InnerExecute(BadExecutionContext context)
BadLogicAssignXOrExpression(BadExpression left, BadExpression right, BadSourcePosition position)
Constructor of the Assign Logic Exclusive Or Expression.
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 Null
The Null Value for the BadScript Language.
Definition BadObject.cs:28
Implements the base functionality for a BadScript Reference.
Implements the Interface for Native Boolean.
Definition IBadBoolean.cs:7
Contains Shared Data Structures and Functionality.
Contains the Self-Assigning 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.