BadScript 2
Loading...
Searching...
No Matches
BadNullCoalescingAssignExpression.cs
Go to the documentation of this file.
6
8
14{
22 BadExpression left,
23 BadExpression right,
24 BadSourcePosition position) : base(
25 left,
26 right,
27 position
28 ) { }
29
30
31 protected override IEnumerable<BadObject> InnerExecute(BadExecutionContext context)
32 {
34
35 foreach (BadObject o in Left.Execute(context))
36 {
37 left = o;
38 }
39
40 if (left is not BadObjectReference leftRef)
41 {
42 throw new BadRuntimeException("Left side of null coalescing assignment must be a reference", Position);
43 }
44
45 left = left.Dereference();
46
47 if (left == BadObject.Null)
48 {
50
51 foreach (BadObject o in Right.Execute(context))
52 {
53 yield return o;
54
55 rVal = o;
56 }
57
58 rVal = rVal.Dereference();
59 leftRef.Set(rVal);
60
61 yield return rVal;
62 }
63 else
64 {
65 yield return left;
66 }
67 }
68
69
70 protected override string GetSymbol()
71 {
72 return "??=";
73 }
74}
Describes a specific position inside a source file.
Implements the Null Coalescing Assign Expression LEFT ??= RIGHT.
override IEnumerable< BadObject > InnerExecute(BadExecutionContext context)
BadNullCoalescingAssignExpression(BadExpression left, BadExpression right, BadSourcePosition position)
Constructor of the Null Coalescing Assign Expression.
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.
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.
Contains Shared Data Structures and Functionality.
Contains the Access Expressions for the BadScript2 Language.
Contains the Binary Expressions for the BadScript2 Language.
Contains the Error Objects for the BadScript2 Language.
Contains the Runtime Objects.
Definition BadArray.cs:10
Contains the Runtime Implementation.