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(false,
27 position
28 )
29 {
30 m_InitExpressions = initExpressions;
31 }
32
36 public int Length => m_InitExpressions.Length;
37
41 public IEnumerable<BadExpression> InitExpressions => m_InitExpressions;
42
44 public override void Optimize()
45 {
46 for (int i = 0; i < m_InitExpressions.Length; i++)
47 {
49 }
50 }
51
53 protected override IEnumerable<BadObject> InnerExecute(BadExecutionContext context)
54 {
55 List<BadObject> array = new List<BadObject>();
56
57 foreach (BadExpression expression in m_InitExpressions)
58 {
60
61 foreach (BadObject obj in expression.Execute(context))
62 {
63 o = obj;
64
65 yield return o;
66 }
67
68 array.Add(o.Dereference(Position));
69 }
70
71 yield return new BadArray(array);
72 }
73
75 public override IEnumerable<BadExpression> GetDescendants()
76 {
77 return m_InitExpressions.SelectMany(expression => expression.GetDescendantsAndSelf());
78 }
79}
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.
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.