BadScript 2
Loading...
Searching...
No Matches
BadLogicAssignXOrExpression.cs
Go to the documentation of this file.
6
8
13{
21 right,
22 position
23 ) { }
24
26 protected override IEnumerable<BadObject> InnerExecute(BadExecutionContext context)
27 {
28 bool hasReturn = false;
30
31 foreach (BadObject o in Left.Execute(context))
32 {
33 left = o;
34
35 yield return o;
36 }
37
38 if (left is not BadObjectReference leftRef)
39 {
40 throw new BadRuntimeException($"Left side of {GetSymbol()} must be a reference", Position);
41 }
42
43 left = left.Dereference(Position);
44
45 BadObject right = BadObject.Null;
46
47 foreach (BadObject o in Right.Execute(context))
48 {
49 right = o;
50
51 yield return o;
52 }
53
54 right = right.Dereference(Position);
55
56 if (left is IBadBoolean lBool && right is IBadBoolean rBool)
57 {
58 hasReturn = true;
59
60 BadObject r = BadObject.Wrap(lBool.Value ^ rBool.Value);
61 leftRef.Set(r, Position);
62
63 yield return r;
64 }
65
66 if (!hasReturn)
67 {
68 throw new BadRuntimeException($"Can not apply operator '{GetSymbol()}' to {left} and {right}", Position);
69 }
70 }
71
73 protected override string GetSymbol()
74 {
75 return "^=";
76 }
77}
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.