BadScript 2
Loading...
Searching...
No Matches
BadScript2.Runtime.BadExecutionContext Class Reference

The Execution Context. Every execution of a script needs a context the script is running in. It is responsible for defining the global scope and the global variables. More...

Inheritance diagram for BadScript2.Runtime.BadExecutionContext:

Public Member Functions

 BadExecutionContext (BadScope scope)
 Creates a new Execution Context.
 
void Dispose ()
 Disposes the context.
 
BadObjectRun (IEnumerable< BadExpression > expressions)
 Executes an enumeration of expressions.
 
BadObject ExecuteScript (IEnumerable< BadExpression > expressions)
 Executes an enumeration of expressions and returns the last value.
 
BadObject ExecuteScript (BadExpression expression)
 Executes an expression and returns the last value.
 
IEnumerable< BadObjectExecute (IEnumerable< BadExpression > expressions)
 Executes an enumeration of expressions.
 
IEnumerable< BadObjectExecute (BadExpression expression)
 Executes an expression.
 

Static Public Member Functions

static BadExecutionContext Create (BadInteropExtensionProvider provider)
 Creates a new Execution Context with an empty scope.
 

Properties

BadScope Scope [get]
 The Root Scope of the Context.
 

Detailed Description

The Execution Context. Every execution of a script needs a context the script is running in. It is responsible for defining the global scope and the global variables.

Definition at line 15 of file BadExecutionContext.cs.

Constructor & Destructor Documentation

◆ BadExecutionContext()

BadScript2.Runtime.BadExecutionContext.BadExecutionContext ( BadScope  scope)

Creates a new Execution Context.

Parameters
scopeThe Root Scope

Definition at line 21 of file BadExecutionContext.cs.

22 {
23 Scope = scope;
24 }
BadScope Scope
The Root Scope of the Context.

Member Function Documentation

◆ Create()

static BadExecutionContext BadScript2.Runtime.BadExecutionContext.Create ( BadInteropExtensionProvider  provider)
static

Creates a new Execution Context with an empty scope.

Returns
New (empty) instance.

Definition at line 47 of file BadExecutionContext.cs.

48 {
49 return new BadExecutionContext(new BadScope("<root>", provider));
50 }
BadExecutionContext(BadScope scope)
Creates a new Execution Context.

◆ Dispose()

void BadScript2.Runtime.BadExecutionContext.Dispose ( )

Disposes the context.

Definition at line 36 of file BadExecutionContext.cs.

37 {
38 Scope.Dispose();
39 }
void Dispose()
Disposes the Scope and calls all finalizers.
Definition BadScope.cs:231

◆ Execute() [1/2]

IEnumerable< BadObject > BadScript2.Runtime.BadExecutionContext.Execute ( BadExpression  expression)

Executes an expression.

Parameters
expressionThe expression to execute.
Returns
Enumeration of the resulting objects

Definition at line 118 of file BadExecutionContext.cs.

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 }
IEnumerable< BadObject > Execute(BadExecutionContext context)
Evaluates the Expression within the current Execution Context.
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
BadObject? ReturnValue
The Return value of the scope.
Definition BadScope.cs:182
The Base Class for all BadScript Objects.
Definition BadObject.cs:14

◆ Execute() [2/2]

IEnumerable< BadObject > BadScript2.Runtime.BadExecutionContext.Execute ( IEnumerable< BadExpression expressions)

Executes an enumeration of expressions.

Parameters
expressionsExpression Enumeration
Returns
Enumeration of the resulting objects

Definition at line 108 of file BadExecutionContext.cs.

109 {
110 return expressions.SelectMany(Execute);
111 }
IEnumerable< BadObject > Execute(IEnumerable< BadExpression > expressions)
Executes an enumeration of expressions.

◆ ExecuteScript() [1/2]

BadObject BadScript2.Runtime.BadExecutionContext.ExecuteScript ( BadExpression  expression)

Executes an expression and returns the last value.

Parameters
expressionThe expression to execute.
Returns
The last value of the enumeration.

Definition at line 91 of file BadExecutionContext.cs.

92 {
93 BadObject result = BadObject.Null;
94
95 foreach (BadObject o in Execute(expression))
96 {
97 result = o;
98 }
99
100 return result;
101 }
static readonly BadObject Null
The Null Value for the BadScript Language.
Definition BadObject.cs:28

◆ ExecuteScript() [2/2]

BadObject BadScript2.Runtime.BadExecutionContext.ExecuteScript ( IEnumerable< BadExpression expressions)

Executes an enumeration of expressions and returns the last value.

Parameters
expressionsExpression Enumeration
Returns
The last value of the enumeration.

Definition at line 73 of file BadExecutionContext.cs.

74 {
75 BadObject result = BadObject.Null;
76
77 foreach (BadObject o in Execute(expressions))
78 {
79 result = o;
80 }
81
82 return result;
83 }

◆ Run()

BadObject? BadScript2.Runtime.BadExecutionContext.Run ( IEnumerable< BadExpression expressions)

Executes an enumeration of expressions.

Parameters
expressionsExpression Enumeration
Returns
The Return Value. Null if no return value was set.

Definition at line 58 of file BadExecutionContext.cs.

59 {
60 foreach (BadObject _ in Execute(expressions))
61 {
62 //Execute
63 }
64
65 return Scope.ReturnValue ?? null;
66 }

Property Documentation

◆ Scope

BadScope BadScript2.Runtime.BadExecutionContext.Scope
get

The Root Scope of the Context.

Definition at line 29 of file BadExecutionContext.cs.

29{ get; }

The documentation for this class was generated from the following file: