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 43 of file BadExecutionContext.cs.

44 {
45 return new BadExecutionContext(new BadScope("<root>", provider));
46 }
BadExecutionContext(BadScope scope)
Creates a new Execution Context.

◆ Dispose()

void BadScript2.Runtime.BadExecutionContext.Dispose ( )

Disposes the context.

Definition at line 34 of file BadExecutionContext.cs.

35 {
36 Scope.Dispose();
37 }
void Dispose()
Disposes the Scope and calls all finalizers.
Definition BadScope.cs:458

◆ 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 114 of file BadExecutionContext.cs.

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 }
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:409
bool IsBreak
Is true if the Break Keyword was set.
Definition BadScope.cs:404
BadObject? ReturnValue
The Return value of the scope.
Definition BadScope.cs:414
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 104 of file BadExecutionContext.cs.

105 {
106 return expressions.SelectMany(Execute);
107 }
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 87 of file BadExecutionContext.cs.

88 {
89 BadObject result = BadObject.Null;
90
91 foreach (BadObject o in Execute(expression))
92 {
93 result = o;
94 }
95
96 return result;
97 }
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 69 of file BadExecutionContext.cs.

70 {
71 BadObject result = BadObject.Null;
72
73 foreach (BadObject o in Execute(expressions))
74 {
75 result = o;
76 }
77
78 return result;
79 }

◆ 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 54 of file BadExecutionContext.cs.

55 {
56 foreach (BadObject _ in Execute(expressions))
57 {
58 //Execute
59 }
60
61 return Scope.ReturnValue ?? null;
62 }

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: