BadScript 2
Loading...
Searching...
No Matches
BadExecutionContext.cs
Go to the documentation of this file.
4
9
15public class BadExecutionContext : IDisposable
16{
22 {
23 Scope = scope;
24 }
25
29 public BadScope Scope { get; }
30
31#region IDisposable Members
32
36 public void Dispose()
37 {
38 Scope.Dispose();
39 }
40
41#endregion
42
48 {
49 return new BadExecutionContext(new BadScope("<root>", provider));
50 }
51
52
58 public BadObject? Run(IEnumerable<BadExpression> expressions)
59 {
60 foreach (BadObject _ in Execute(expressions))
61 {
62 //Execute
63 }
64
65 return Scope.ReturnValue ?? null;
66 }
67
73 public BadObject ExecuteScript(IEnumerable<BadExpression> expressions)
74 {
75 BadObject result = BadObject.Null;
76
77 foreach (BadObject o in Execute(expressions))
78 {
79 result = o;
80 }
81
82 return result;
83 }
84
85
92 {
93 BadObject result = BadObject.Null;
94
95 foreach (BadObject o in Execute(expression))
96 {
97 result = o;
98 }
99
100 return result;
101 }
102
108 public IEnumerable<BadObject> Execute(IEnumerable<BadExpression> expressions)
109 {
110 return expressions.SelectMany(Execute);
111 }
112
118 public IEnumerable<BadObject> Execute(BadExpression expression)
119 {
120 foreach (BadObject o in expression.Execute(this))
121 {
122 yield return o;
123
124 if (Scope.ReturnValue != null ||
125 Scope.IsBreak ||
127 {
128 yield break;
129 }
130 }
131 }
132}
Base Implementation for all Expressions used inside the Script.
The Execution Context. Every execution of a script needs a context the script is running in....
BadObject ExecuteScript(IEnumerable< BadExpression > expressions)
Executes an enumeration of expressions and returns the last value.
IEnumerable< BadObject > Execute(IEnumerable< BadExpression > expressions)
Executes an enumeration of expressions.
static BadExecutionContext Create(BadInteropExtensionProvider provider)
Creates a new Execution Context with an empty scope.
BadExecutionContext(BadScope scope)
Creates a new Execution Context.
BadScope Scope
The Root Scope of the Context.
IEnumerable< BadObject > Execute(BadExpression expression)
Executes an expression.
BadObject? Run(IEnumerable< BadExpression > expressions)
Executes an enumeration of expressions.
BadObject ExecuteScript(BadExpression expression)
Executes an expression and returns the last value.
Implements the Scope for the Script Engine.
Definition BadScope.cs:16
bool IsContinue
Is true if the Continue Keyword was set.
Definition BadScope.cs:177
bool IsBreak
Is true if the Break Keyword was set.
Definition BadScope.cs:172
void Dispose()
Disposes the Scope and calls all finalizers.
Definition BadScope.cs:231
BadObject? ReturnValue
The Return value of the scope.
Definition BadScope.cs:182
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 the Expressions for the BadScript2 Language.
Contains the Interop Abstractions and Implementations for the BadScript2 Language.
Contains the Runtime Objects.
Definition BadArray.cs:10
Contains the Runtime Implementation.