![]() |
BadScript 2
|
Implements the Scope for the Script Engine. More...
Public Member Functions | |||||
BadArray | GetMemberInfos () | ||||
BadScope (string name, BadInteropExtensionProvider provider, BadScope? caller=null, BadScopeFlags flags=BadScopeFlags.RootScope) | |||||
Creates a new Scope. | |||||
BadScope (string name, BadInteropExtensionProvider provider, BadTable locals, BadScope? caller=null, BadScopeFlags flags=BadScopeFlags.RootScope) | |||||
Creates a new Scope. | |||||
void | Dispose () | ||||
Disposes the Scope and calls all finalizers. | |||||
void | AddFinalizer (Action finalizer) | ||||
Adds a Finalizer to the Scope. | |||||
void | SetCaller (BadScope? caller) | ||||
Sets the Caller of the Scope. | |||||
BadScope | GetRootScope () | ||||
Returns the Root Scope of the Scope. | |||||
void | AddSingleton< T > (T instance) | ||||
Adds a Singleton to the Scope. | |||||
T? | GetSingleton< T > () | ||||
Gets a Singleton from the Scope. | |||||
T | GetSingleton< T > (bool createNew) | ||||
Gets a Singleton from the Scope. | |||||
override BadClassPrototype | GetPrototype () | ||||
Returns the Class Prototype for the Scope. | |||||
void | SetFlags (BadScopeFlags flags) | ||||
Sets the Scope Flags. | |||||
string | GetStackTrace () | ||||
Returns the Stack Trace of the Current scope. | |||||
void | SetBreak () | ||||
Sets the break keyword inside this scope. | |||||
void | SetContinue () | ||||
Sets the continue keyword inside this scope. | |||||
BadObject | GetExports () | ||||
Returns the exported key value pairs of the scope. | |||||
void | SetExports (BadExecutionContext ctx, BadObject exports) | ||||
void | AddExport (string key, BadObject value) | ||||
Sets an exported key value pair in the scope. | |||||
void | SetReturnValue (BadObject? value) | ||||
Sets the Return value of this scope. | |||||
BadTable | GetTable () | ||||
Returns the Variable Table of the current scope. | |||||
BadScope | CreateChild (string name, BadScope? caller, bool? useVisibility, BadScopeFlags flags=BadScopeFlags.RootScope) | ||||
Creates a subscope of the current scope. | |||||
void | DefineProperty (string name, BadClassPrototype type, BadExpression getAccessor, BadExpression? setAccessor, BadExecutionContext caller, BadObject[] attributes) | ||||
void | DefineVariable (string name, BadObject value, BadScope? caller=null, BadPropertyInfo? info=null, BadObject[]? attributes=null) | ||||
Defines a new Variable in the current scope. | |||||
BadPropertyInfo | GetVariableInfo (string name) | ||||
Returns the variable info of the specified variable. | |||||
bool | IsVisibleParentOf (BadScope scope) | ||||
Returns true if the specified scope is visible to the current scope. | |||||
BadObjectReference | GetVariable (string name, BadScope caller) | ||||
Returns the variable reference of the specified variable. | |||||
BadObjectReference | GetVariable (string name) | ||||
Returns a variable reference of the specified variable. | |||||
bool | HasLocal (string name, BadScope caller, bool useExtensions=true) | ||||
returns true if the specified variable is defined in the current scope | |||||
bool | HasVariable (string name, BadScope caller) | ||||
returns true if the specified variable is defined in the current scope or any parent scope | |||||
override BadObjectReference | GetProperty (string propName, BadScope? caller=null) | ||||
Returns a Reference to the Property with the given Name.
| |||||
override bool | HasProperty (string propName, BadScope? caller=null) | ||||
Returns true if the object contains a given property or there exists an extension for the current Instance.
| |||||
override string | ToSafeString (List< BadObject > done) | ||||
![]() | |||||
BadClassPrototype | GetPrototype () | ||||
Returns the Prototype of this Object. | |||||
string | ToSafeString (List< BadObject > done) | ||||
Returns a String Representation of this Object. This function is recursion proof and supports circular references. | |||||
override string | ToString () | ||||
Returns a String Representation of this Object. | |||||
Static Public Member Functions | |
static BadPropertyVisibility | GetPropertyVisibility (string propName) |
Returns the visibility of the specified property. | |
![]() | |
static bool | CanWrap (object? o) |
Returns true if the given object cam be wrapped. | |
static BadObject | Wrap< T > (T obj, bool allowNative=true) |
Wraps the given object into a BadObject Instance. | |
static implicit | operator BadObject (bool b) |
Implicit Converstion from Boolean to BadObject. | |
static implicit | operator BadObject (BadNullable< bool > b) |
Converts the given object to a BadObject Instance. | |
static implicit | operator BadObject (decimal d) |
Implicit Converstion from Number to BadObject. | |
static implicit | operator BadObject (BadNullable< decimal > b) |
Converts the given object to a BadObject Instance. | |
static implicit | operator BadObject (string s) |
Implicit Converstion from String to BadObject. | |
static implicit | operator BadObject (BadNullable< string > b) |
Converts the given object to a BadObject Instance. | |
Package Functions | |
void | SetRegisteredApi (string api) |
Registers an API. | |
void | OnChanged (string name, BadObject oldValue, BadObject newValue) |
bool | OnChange (string name, BadObject oldValue, BadObject newValue) |
IEnumerable< BadObject > | InitializeAttributes () |
Properties | |
IReadOnlyDictionary< string, BadObject[]> | Attributes [get] |
IReadOnlyCollection< string > | RegisteredApis [get] |
A List of Registered APIs. | |
BadInteropExtensionProvider | Provider [get] |
The Extension Provider. | |
BadClass? | ClassObject [get, set] |
The Class Object of the Scope. | |
BadFunction? | FunctionObject [get, set] |
The Function Object of the Scope. | |
BadScope? | Parent [get] |
The Parent Scope. | |
string | Name [get] |
The Name of the Scope (for Debugging) | |
BadScopeFlags | Flags [get, private set] |
The Scope Flags. | |
bool | CountInStackTrace [get] |
Indicates if the Scope should count towards the Stack Trace. | |
bool | IsBreak [get, private set] |
Is true if the Break Keyword was set. | |
bool | IsContinue [get, private set] |
Is true if the Continue Keyword was set. | |
BadObject? | ReturnValue [get, private set] |
The Return value of the scope. | |
static BadClassPrototype | Prototype [get] |
A Class Prototype for the Scope. | |
Private Member Functions | |
BadScope (BadScope parent, BadScope? caller, string name, BadScopeFlags flags=BadScopeFlags.RootScope, bool useVisibility=false) | |
Creates a new Scope. | |
Static Private Member Functions | |
static BadScope | CreateScope (BadExecutionContext ctx, string name, BadTable? locals=null) |
Creates a Root Scope with the given name. | |
static string | GetStackTrace (BadScope scope) |
Returns the Stack Trace of the given Scope. | |
static BadScopeFlags | ClearCaptures (BadScopeFlags flags) |
Clears all Capture Flags from the given Flags. | |
Private Attributes | |
readonly List< Action > | m_Finalizers = new List<Action>() |
The Finalizer List of the Scope. | |
readonly BadInteropExtensionProvider | m_Provider |
The Extension Provider. | |
readonly List< string > | m_RegisteredApis = new List<string>() |
A List of Registered APIs. | |
readonly BadTable | m_ScopeVariables = new BadTable() |
The Scope Variables. | |
readonly Dictionary< string, BadObject[]> | m_Attributes = new Dictionary<string, BadObject[]>() |
readonly Dictionary< Type, object > | m_SingletonCache = new Dictionary<Type, object>() |
The Singleton Cache. | |
readonly bool | m_UseVisibility |
Indicates if the Scope uses the visibility subsystem. | |
BadScope? | m_Caller |
The Caller of the Current Scope. | |
BadObject? | m_Exports |
Contains the exported variables of the scope. | |
bool | m_IsDisposed |
Additional Inherited Members | |
![]() | |
static readonly BadObject | Null = new BadNullObject() |
The Null Value for the BadScript Language. | |
static readonly BadObject | True = new BadBoolean(true) |
The True Value for the BadScript Language. | |
static readonly BadObject | False = new BadBoolean(false) |
The False Value for the BadScript Language. | |
Implements the Scope for the Script Engine.
Definition at line 237 of file BadScope.cs.
BadScript2.Runtime.BadScope.BadScope | ( | string | name, |
BadInteropExtensionProvider | provider, | ||
BadScope? | caller = null , |
||
BadScopeFlags | flags = BadScopeFlags::RootScope |
||
) |
Creates a new Scope.
name | The Name of the Scope |
provider | The Extension Provider of the Runtime |
caller | The Caller of the Scope |
flags | The Flags of the Scope |
Definition at line 298 of file BadScope.cs.
BadScript2.Runtime.BadScope.BadScope | ( | string | name, |
BadInteropExtensionProvider | provider, | ||
BadTable | locals, | ||
BadScope? | caller = null , |
||
BadScopeFlags | flags = BadScopeFlags::RootScope |
||
) |
Creates a new Scope.
name | The Name of the Scope |
provider | The Extension Provider of the Runtime |
locals | The Local Variables |
caller | The Caller of the Scope |
flags | The Flags of the Scope |
Definition at line 320 of file BadScope.cs.
|
private |
Creates a new Scope.
parent | The Parent Scope |
caller | The Caller of the Scope |
name | The Name of the Scope |
flags | The Flags of the Scope |
useVisibility | Does the Scope use the Visibility Subsystem |
Definition at line 344 of file BadScope.cs.
void BadScript2.Runtime.BadScope.AddExport | ( | string | key, |
BadObject | value | ||
) |
Sets an exported key value pair in the scope.
key | The Key |
value | The Value |
Definition at line 737 of file BadScope.cs.
void BadScript2.Runtime.BadScope.AddFinalizer | ( | Action | finalizer | ) |
Adds a Finalizer to the Scope.
finalizer | The Finalizer |
BadRuntimeException | Gets raised if the Scope is already disposed |
Definition at line 498 of file BadScope.cs.
void BadScript2.Runtime.BadScope.AddSingleton< T > | ( | T | instance | ) |
Adds a Singleton to the Scope.
instance |
T |
BadRuntimeException |
T | : | class |
Definition at line 532 of file BadScope.cs.
|
staticprivate |
Clears all Capture Flags from the given Flags.
flags | The Flags to be cleared |
Definition at line 666 of file BadScope.cs.
BadScope BadScript2.Runtime.BadScope.CreateChild | ( | string | name, |
BadScope? | caller, | ||
bool? | useVisibility, | ||
BadScopeFlags | flags = BadScopeFlags::RootScope |
||
) |
Creates a subscope of the current scope.
name | Scope Name |
caller | The Caller |
useVisibility | Specifies if the scope is part of a class structure(if visibility flags are used) |
flags | Scope Flags |
Definition at line 792 of file BadScope.cs.
|
staticprivate |
Creates a Root Scope with the given name.
ctx | The Calling Context |
name | Scope Name |
locals | The Local Variables of the new Scope |
Definition at line 608 of file BadScope.cs.
void BadScript2.Runtime.BadScope.DefineProperty | ( | string | name, |
BadClassPrototype | type, | ||
BadExpression | getAccessor, | ||
BadExpression? | setAccessor, | ||
BadExecutionContext | caller, | ||
BadObject[] | attributes | ||
) |
Definition at line 885 of file BadScope.cs.
void BadScript2.Runtime.BadScope.DefineVariable | ( | string | name, |
BadObject | value, | ||
BadScope? | caller = null , |
||
BadPropertyInfo? | info = null , |
||
BadObject?[] | attributes = null |
||
) |
Defines a new Variable in the current scope.
name | Variable Name |
value | Variable Value |
caller | The Caller of the Scope |
info | Variable Info |
BadRuntimeException | Gets raised if the specified variable is already defined. |
Definition at line 929 of file BadScope.cs.
void BadScript2.Runtime.BadScope.Dispose | ( | ) |
Disposes the Scope and calls all finalizers.
Definition at line 458 of file BadScope.cs.
BadObject BadScript2.Runtime.BadScope.GetExports | ( | ) |
Returns the exported key value pairs of the scope.
Definition at line 717 of file BadScope.cs.
BadArray BadScript2.Runtime.BadScope.GetMemberInfos | ( | ) |
Definition at line 263 of file BadScope.cs.
|
virtual |
Returns a Reference to the Property with the given Name.
propName | The Property Name |
caller | The caller Scope |
Reimplemented from BadScript2.Runtime.Objects.BadObject.
Definition at line 1079 of file BadScope.cs.
|
static |
Returns the visibility of the specified property.
propName | The Property Name |
Definition at line 966 of file BadScope.cs.
override BadClassPrototype BadScript2.Runtime.BadScope.GetPrototype | ( | ) |
Returns the Class Prototype for the Scope.
Definition at line 596 of file BadScope.cs.
BadScope BadScript2.Runtime.BadScope.GetRootScope | ( | ) |
Returns the Root Scope of the Scope.
Definition at line 521 of file BadScope.cs.
T? BadScript2.Runtime.BadScope.GetSingleton< T > | ( | ) |
Gets a Singleton from the Scope.
T | Type of the Singleton |
Definition at line 547 of file BadScope.cs.
T BadScript2.Runtime.BadScope.GetSingleton< T > | ( | bool | createNew | ) |
Gets a Singleton from the Scope.
createNew | Should a new instance be created if the singleton does not exist |
T | Type of the Singleton |
Exception | Gets raised if the singleton does not exist and createNew is false |
T | : | new() |
Definition at line 569 of file BadScope.cs.
string BadScript2.Runtime.BadScope.GetStackTrace | ( | ) |
Returns the Stack Trace of the Current scope.
Definition at line 633 of file BadScope.cs.
|
staticprivate |
Returns the Stack Trace of the given Scope.
scope | The Scope |
Definition at line 643 of file BadScope.cs.
BadTable BadScript2.Runtime.BadScope.GetTable | ( | ) |
Returns the Variable Table of the current scope.
Definition at line 778 of file BadScope.cs.
BadObjectReference BadScript2.Runtime.BadScope.GetVariable | ( | string | name | ) |
Returns a variable reference of the specified variable.
name | Variable Name |
BadRuntimeException | Gets raised if the variable can not be found |
Definition at line 1049 of file BadScope.cs.
BadObjectReference BadScript2.Runtime.BadScope.GetVariable | ( | string | name, |
BadScope | caller | ||
) |
Returns the variable reference of the specified variable.
name | Variable Name |
caller | The Calling Scope |
BadRuntimeException | Gets raised if the variable can not be found or is not visible |
Definition at line 1018 of file BadScope.cs.
BadPropertyInfo BadScript2.Runtime.BadScope.GetVariableInfo | ( | string | name | ) |
Returns the variable info of the specified variable.
name | Variable Name |
BadRuntimeException | Gets raised if the variable can not be found |
Definition at line 946 of file BadScope.cs.
bool BadScript2.Runtime.BadScope.HasLocal | ( | string | name, |
BadScope | caller, | ||
bool | useExtensions = true |
||
) |
returns true if the specified variable is defined in the current scope
name | The Name |
caller | The Caller of the Scope |
useExtensions | Should the Extension Subsystem be searched for the property |
Definition at line 1061 of file BadScope.cs.
|
virtual |
Returns true if the object contains a given property or there exists an extension for the current Instance.
propName | The Property Name |
caller | The caller Scope |
Reimplemented from BadScript2.Runtime.Objects.BadObject.
Definition at line 1085 of file BadScope.cs.
bool BadScript2.Runtime.BadScope.HasVariable | ( | string | name, |
BadScope | caller | ||
) |
returns true if the specified variable is defined in the current scope or any parent scope
name | The Name |
caller | The Caller of the Scope |
Definition at line 1072 of file BadScope.cs.
|
package |
Definition at line 861 of file BadScope.cs.
bool BadScript2.Runtime.BadScope.IsVisibleParentOf | ( | BadScope | scope | ) |
Returns true if the specified scope is visible to the current scope.
scope | The Scope |
Definition at line 983 of file BadScope.cs.
|
package |
Definition at line 829 of file BadScope.cs.
|
package |
Definition at line 806 of file BadScope.cs.
void BadScript2.Runtime.BadScope.SetBreak | ( | ) |
Sets the break keyword inside this scope.
BadRuntimeException | Gets raised if the current scope does not allow the Break Keyword |
Definition at line 679 of file BadScope.cs.
void BadScript2.Runtime.BadScope.SetCaller | ( | BadScope? | caller | ) |
Sets the Caller of the Scope.
caller | The Caller |
Definition at line 512 of file BadScope.cs.
void BadScript2.Runtime.BadScope.SetContinue | ( | ) |
Sets the continue keyword inside this scope.
BadRuntimeException | Gets raised if the current scope does not allow the continue Keyword |
Definition at line 698 of file BadScope.cs.
void BadScript2.Runtime.BadScope.SetExports | ( | BadExecutionContext | ctx, |
BadObject | exports | ||
) |
Definition at line 722 of file BadScope.cs.
void BadScript2.Runtime.BadScope.SetFlags | ( | BadScopeFlags | flags | ) |
|
package |
Registers an API.
api |
Definition at line 478 of file BadScope.cs.
void BadScript2.Runtime.BadScope.SetReturnValue | ( | BadObject? | value | ) |
Sets the Return value of this scope.
value | The Return Value |
BadRuntimeException | Gets Raised if the Scope does not allow returning |
Definition at line 759 of file BadScope.cs.
override string BadScript2.Runtime.BadScope.ToSafeString | ( | List< BadObject > | done | ) |
Definition at line 1092 of file BadScope.cs.
|
private |
Definition at line 259 of file BadScope.cs.
|
private |
The Caller of the Current Scope.
Definition at line 282 of file BadScope.cs.
|
private |
Contains the exported variables of the scope.
Definition at line 287 of file BadScope.cs.
|
private |
The Finalizer List of the Scope.
Definition at line 242 of file BadScope.cs.
|
private |
Definition at line 289 of file BadScope.cs.
|
private |
The Extension Provider.
Definition at line 247 of file BadScope.cs.
|
private |
A List of Registered APIs.
Definition at line 252 of file BadScope.cs.
The Scope Variables.
Definition at line 257 of file BadScope.cs.
|
private |
The Singleton Cache.
Definition at line 272 of file BadScope.cs.
|
private |
Indicates if the Scope uses the visibility subsystem.
Definition at line 277 of file BadScope.cs.
|
get |
Definition at line 261 of file BadScope.cs.
|
getset |
The Class Object of the Scope.
Definition at line 373 of file BadScope.cs.
|
getprivate |
Indicates if the Scope should count towards the Stack Trace.
Definition at line 399 of file BadScope.cs.
|
getprivate set |
|
getset |
The Function Object of the Scope.
Definition at line 378 of file BadScope.cs.
|
getprivate set |
Is true if the Break Keyword was set.
Definition at line 404 of file BadScope.cs.
|
getprivate set |
Is true if the Continue Keyword was set.
Definition at line 409 of file BadScope.cs.
|
get |
|
get |
|
staticget |
A Class Prototype for the Scope.
Definition at line 420 of file BadScope.cs.
|
get |
The Extension Provider.
Definition at line 368 of file BadScope.cs.
|
get |
A List of Registered APIs.
Definition at line 363 of file BadScope.cs.
|
getprivate set |