BadScript 2
Loading...
Searching...
No Matches
BadArrayExpression.cs
Go to the documentation of this file.
5
10
15{
19 private readonly BadExpression[] m_InitExpressions;
20
26 public BadArrayExpression(BadExpression[] initExpressions, BadSourcePosition position) : base(
27 false,
28 position
29 )
30 {
31 m_InitExpressions = initExpressions;
32 }
33
37 public int Length => m_InitExpressions.Length;
38
42 public IEnumerable<BadExpression> InitExpressions => m_InitExpressions;
43
45 public override void Optimize()
46 {
47 for (int i = 0; i < m_InitExpressions.Length; i++)
48 {
50 }
51 }
52
54 protected override IEnumerable<BadObject> InnerExecute(BadExecutionContext context)
55 {
56 List<BadObject> array = new List<BadObject>();
57
58 foreach (BadExpression expression in m_InitExpressions)
59 {
61
62 foreach (BadObject obj in expression.Execute(context))
63 {
64 o = obj;
65
66 yield return o;
67 }
68
69 array.Add(o.Dereference());
70 }
71
72 yield return new BadArray(array);
73 }
74
76 public override IEnumerable<BadExpression> GetDescendants()
77 {
78 return m_InitExpressions.SelectMany(expression => expression.GetDescendantsAndSelf());
79 }
80}
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.
IEnumerable< BadObject > Execute(BadExecutionContext context)
Evaluates the Expression within the current Execution Context.
BadArrayExpression(BadExpression[] initExpressions, BadSourcePosition position)
Constructor of the Array Expression.
IEnumerable< BadExpression > InitExpressions
The Initializer List.
readonly BadExpression[] m_InitExpressions
The Initializer List.
override IEnumerable< BadExpression > GetDescendants()
override IEnumerable< BadObject > InnerExecute(BadExecutionContext context)
override void Optimize()
Uses the Constant Folding Optimizer to optimize the expression.
The Execution Context. Every execution of a script needs a context the script is running in....
Implements a Dynamic List/Array for the BadScript Language.
Definition BadArray.cs:17
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
Contains Shared Data Structures and Functionality.
Contains the BadScript2 Constant Folding Optimizations.
Contains the Constant Expressions for the BadScript2 Language.
Contains the Runtime Objects.
Definition BadArray.cs:10
Contains the Runtime Implementation.