BadScript 2
Loading...
Searching...
No Matches
BadUnaryUnpackExpression.cs
Go to the documentation of this file.
5
7
12{
16 public readonly BadExpression Right;
17
22 public BadUnaryUnpackExpression(BadExpression right) : base(right.IsConstant, right.Position)
23 {
24 Right = right;
25 }
26
27
29 public override IEnumerable<BadExpression> GetDescendants()
30 {
32 }
33
41 public static void Unpack(BadTable table, BadObject right, BadSourcePosition position)
42 {
43 if (right is not BadTable rightT)
44 {
45 throw new BadRuntimeException("Unpack operator requires 1 table", position);
46 }
47
48 foreach (KeyValuePair<string, BadObject> o in rightT.InnerTable)
49 {
50 table.InnerTable[o.Key] = o.Value;
51 table.PropertyInfos[o.Key] = rightT.PropertyInfos[o.Key];
52 }
53 }
54
56 protected override IEnumerable<BadObject> InnerExecute(BadExecutionContext context)
57 {
58 BadTable result = context.Scope.GetTable();
59 BadObject right = BadObject.Null;
60
61 foreach (BadObject o in Right.Execute(context))
62 {
63 right = o;
64
65 yield return o;
66 }
67
68 right = right.Dereference();
69
70 Unpack(result, right, Position);
71
72 yield return result;
73 }
74}
Describes a specific position inside a source file.
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.
bool IsConstant
Indicates if the expression stays constant at all times.
Implements the unary ... operator. This operator is used to unpack a table into the current execution...
override IEnumerable< BadObject > InnerExecute(BadExecutionContext context)
readonly BadExpression Right
The Right Side of the Expression.
static void Unpack(BadTable table, BadObject right, BadSourcePosition position)
Implements the logic of the unary ... operator.
BadUnaryUnpackExpression(BadExpression right)
Constructor for the unary ... operator.
The Execution Context. Every execution of a script needs a context the script is running in....
BadScope Scope
The Root Scope of the Context.
BadTable GetTable()
Returns the Variable Table of the current scope.
Definition BadScope.cs:778
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 a Table Structure for the BadScript Language.
Definition BadTable.cs:14
Contains Shared Data Structures and Functionality.
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.