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
34 public void Dispose()
35 {
36 Scope.Dispose();
37 }
38
44 {
45 return new BadExecutionContext(new BadScope("<root>", provider));
46 }
47
48
54 public BadObject? Run(IEnumerable<BadExpression> expressions)
55 {
56 foreach (BadObject _ in Execute(expressions))
57 {
58 //Execute
59 }
60
61 return Scope.ReturnValue ?? null;
62 }
63
69 public BadObject ExecuteScript(IEnumerable<BadExpression> expressions)
70 {
71 BadObject result = BadObject.Null;
72
73 foreach (BadObject o in Execute(expressions))
74 {
75 result = o;
76 }
77
78 return result;
79 }
80
81
88 {
89 BadObject result = BadObject.Null;
90
91 foreach (BadObject o in Execute(expression))
92 {
93 result = o;
94 }
95
96 return result;
97 }
98
104 public IEnumerable<BadObject> Execute(IEnumerable<BadExpression> expressions)
105 {
106 return expressions.SelectMany(Execute);
107 }
108
114 public IEnumerable<BadObject> Execute(BadExpression expression)
115 {
116 foreach (BadObject o in expression.Execute(this))
117 {
118 yield return o;
119
120 if (Scope.ReturnValue != null ||
121 Scope.IsBreak ||
123 {
124 yield break;
125 }
126 }
127 }
128}
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:238
bool IsContinue
Is true if the Continue Keyword was set.
Definition BadScope.cs:409
bool IsBreak
Is true if the Break Keyword was set.
Definition BadScope.cs:404
void Dispose()
Disposes the Scope and calls all finalizers.
Definition BadScope.cs:458
BadObject? ReturnValue
The Return value of the scope.
Definition BadScope.cs:414
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.