BadScript 2
Loading...
Searching...
No Matches
BadBinaryUnpackExpression.cs
Go to the documentation of this file.
5
7
13{
21 left,
22 right,
23 position
24 ) { }
25
26
35 public static BadTable Unpack(BadObject left, BadObject right, BadSourcePosition position)
36 {
37 BadTable result = new BadTable();
38
39 if (left is not BadTable leftT || right is not BadTable rightT)
40 {
41 throw new BadRuntimeException("Unpack operator requires 2 tables", position);
42 }
43
44 foreach (KeyValuePair<string, BadObject> o in leftT.InnerTable)
45 {
46 result.InnerTable[o.Key] = o.Value;
47 result.PropertyInfos[o.Key] = leftT.PropertyInfos[o.Key];
48 }
49
50 foreach (KeyValuePair<string, BadObject> o in rightT.InnerTable)
51 {
52 result.InnerTable[o.Key] = o.Value;
53 result.PropertyInfos[o.Key] = rightT.PropertyInfos[o.Key];
54 }
55
56 return result;
57 }
58
60 protected override IEnumerable<BadObject> InnerExecute(BadExecutionContext context)
61 {
63 BadObject right = BadObject.Null;
64
65 foreach (BadObject o in Left.Execute(context))
66 {
67 left = o;
68
69 yield return o;
70 }
71
72 foreach (BadObject o in Right.Execute(context))
73 {
74 right = o;
75
76 yield return o;
77 }
78
79 left = left.Dereference();
80 right = right.Dereference();
81
82 yield return Unpack(left, right, Position);
83 }
84
86 protected override string GetSymbol()
87 {
88 return "...";
89 }
90}
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.
Implements the binary ... operator. This operator is used to unpack the right side into the left side...
static BadTable Unpack(BadObject left, BadObject right, BadSourcePosition position)
Executes the binary ... operator.
BadBinaryUnpackExpression(BadExpression left, BadExpression right, BadSourcePosition position)
Constructor for the binary ... operator.
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 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.