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