BadScript 2
Loading...
Searching...
No Matches
BadAssignExpression.cs
Go to the documentation of this file.
6
11
17{
25 false,
26 position
27 )
28 {
29 Left = left;
30 Right = right;
31 }
32
36 public BadExpression Left { get; set; }
37
41 public BadExpression Right { get; set; }
42
44 public override IEnumerable<BadExpression> GetDescendants()
45 {
46 foreach (BadExpression expression in Left.GetDescendantsAndSelf())
47 {
48 yield return expression;
49 }
50
51 foreach (BadExpression? expression in Right.GetDescendantsAndSelf())
52 {
53 yield return expression;
54 }
55 }
56
63
65 public override string ToString()
66 {
67 return $"({Left} = {Right})";
68 }
69
71 protected override IEnumerable<BadObject> InnerExecute(BadExecutionContext context)
72 {
74
75 foreach (BadObject o in Left.Execute(context))
76 {
77 left = o;
78
79 yield return o;
80 }
81
82 BadObject right = BadObject.Null;
83
84 foreach (BadObject o in Right.Execute(context))
85 {
86 right = o;
87
88 yield return o;
89 }
90
91
92 right = right.Dereference();
93
94 if (left is BadObjectReference reference)
95 {
96 reference.Set(right);
97 }
98 else
99 {
100 throw new BadRuntimeException($"Left handside of {this} is not a reference", Position);
101 }
102
103 yield return left;
104 }
105}
Describes a specific position inside a source file.
static BadExpression Optimize(BadExpression expr)
Optimizes the given expression.
Base Implementation for all Expressions used inside the Script.
IEnumerable< BadExpression > GetDescendantsAndSelf()
Returns all Descendants of the Expression and the Expression itself.
BadSourcePosition Position
The source Position of the Expression.
IEnumerable< BadObject > Execute(BadExecutionContext context)
Evaluates the Expression within the current Execution Context.
Implements the Assign Expression LEFT = RIGHT.
override void Optimize()
Uses the Constant Folding Optimizer to optimize the expression.
override IEnumerable< BadExpression > GetDescendants()
BadExpression Left
Left side that the right side will be assigned to.
override IEnumerable< BadObject > InnerExecute(BadExecutionContext context)
BadExpression Right
Right side of the Expression.
BadAssignExpression(BadExpression left, BadExpression right, BadSourcePosition position)
Constructor of the Assign 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 BadScript2 Constant Folding Optimizations.
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.