![]() |
BadScript 2
|
Implements the Scope for the Script Engine. More...
Public Member Functions | |||||
| 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. | |||||
| BadArray | GetMemberInfos () | ||||
| 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. | |||||
| IEnumerable< BadScope > | GetStackTraceEnumerable () | ||||
| BadScope | GetFirstTracableOrRoot () | ||||
| 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) | ||||
Public Member Functions inherited from BadScript2.Runtime.Objects.BadObject | |||||
| 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 Public Member Functions inherited from BadScript2.Runtime.Objects.BadObject | |
| 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 (DateTimeOffset d) |
| static implicit | operator BadObject (TimeSpan t) |
| 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 IEnumerable< BadScope > | GetStackTraceEnumerable (BadScope scope) |
| static BadScopeFlags | ClearCaptures (BadScopeFlags flags) |
| Clears all Capture Flags from the given Flags. | |
Private Attributes | |
| readonly Dictionary< string, BadObject[]> | m_Attributes = new Dictionary<string, BadObject[]>() |
| 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< 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 Public Attributes inherited from BadScript2.Runtime.Objects.BadObject | |
| 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 15 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 68 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 89 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 112 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 542 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 281 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 315 of file BadScope.cs.
|
staticprivate |
Clears all Capture Flags from the given Flags.
| flags | The Flags to be cleared |
Definition at line 471 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 597 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 391 of file BadScope.cs.
| void BadScript2.Runtime.BadScope.DefineProperty | ( | string | name, |
| BadClassPrototype | type, | ||
| BadExpression | getAccessor, | ||
| BadExpression? | setAccessor, | ||
| BadExecutionContext | caller, | ||
| BadObject[] | attributes | ||
| ) |
Definition at line 713 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 784 of file BadScope.cs.
| void BadScript2.Runtime.BadScope.Dispose | ( | ) |
Disposes the Scope and calls all finalizers.
Definition at line 231 of file BadScope.cs.
| BadObject BadScript2.Runtime.BadScope.GetExports | ( | ) |
Returns the exported key value pairs of the scope.
Definition at line 522 of file BadScope.cs.
| BadScope BadScript2.Runtime.BadScope.GetFirstTracableOrRoot | ( | ) |
| BadArray BadScript2.Runtime.BadScope.GetMemberInfos | ( | ) |
Definition at line 250 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 943 of file BadScope.cs.
|
static |
Returns the visibility of the specified property.
| propName | The Property Name |
Definition at line 827 of file BadScope.cs.
| override BadClassPrototype BadScript2.Runtime.BadScope.GetPrototype | ( | ) |
Returns the Class Prototype for the Scope.
Definition at line 379 of file BadScope.cs.
| BadScope BadScript2.Runtime.BadScope.GetRootScope | ( | ) |
Returns the Root Scope of the Scope.
Definition at line 304 of file BadScope.cs.
| T? BadScript2.Runtime.BadScope.GetSingleton< T > | ( | ) |
Gets a Singleton from the Scope.
| T | Type of the Singleton |
Definition at line 330 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 352 of file BadScope.cs.
| string BadScript2.Runtime.BadScope.GetStackTrace | ( | ) |
Returns the Stack Trace of the Current scope.
Definition at line 419 of file BadScope.cs.
|
staticprivate |
Returns the Stack Trace of the given Scope.
| scope | The Scope |
Definition at line 429 of file BadScope.cs.
| IEnumerable< BadScope > BadScript2.Runtime.BadScope.GetStackTraceEnumerable | ( | ) |
|
staticprivate |
Definition at line 447 of file BadScope.cs.
| BadTable BadScript2.Runtime.BadScope.GetTable | ( | ) |
Returns the Variable Table of the current scope.
Definition at line 583 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 911 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 878 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 807 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 923 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 951 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 936 of file BadScope.cs.
|
package |
Definition at line 683 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 844 of file BadScope.cs.
|
package |
Definition at line 642 of file BadScope.cs.
|
package |
Definition at line 610 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 484 of file BadScope.cs.
| void BadScript2.Runtime.BadScope.SetCaller | ( | BadScope? | caller | ) |
Sets the Caller of the Scope.
| caller | The Caller |
Definition at line 295 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 503 of file BadScope.cs.
| void BadScript2.Runtime.BadScope.SetExports | ( | BadExecutionContext | ctx, |
| BadObject | exports | ||
| ) |
Definition at line 527 of file BadScope.cs.
| void BadScript2.Runtime.BadScope.SetFlags | ( | BadScopeFlags | flags | ) |
|
package |
Registers an API.
| api |
Definition at line 261 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 564 of file BadScope.cs.
| override string BadScript2.Runtime.BadScope.ToSafeString | ( | List< BadObject > | done | ) |
Definition at line 958 of file BadScope.cs.
|
private |
Definition at line 17 of file BadScope.cs.
|
private |
The Caller of the Current Scope.
Definition at line 52 of file BadScope.cs.
|
private |
Contains the exported variables of the scope.
Definition at line 57 of file BadScope.cs.
|
private |
The Finalizer List of the Scope.
Definition at line 22 of file BadScope.cs.
|
private |
Definition at line 59 of file BadScope.cs.
|
private |
The Extension Provider.
Definition at line 27 of file BadScope.cs.
|
private |
A List of Registered APIs.
Definition at line 32 of file BadScope.cs.
The Scope Variables.
Definition at line 37 of file BadScope.cs.
|
private |
The Singleton Cache.
Definition at line 42 of file BadScope.cs.
|
private |
Indicates if the Scope uses the visibility subsystem.
Definition at line 47 of file BadScope.cs.
|
get |
Definition at line 126 of file BadScope.cs.
|
getset |
The Class Object of the Scope.
Definition at line 141 of file BadScope.cs.
|
getprivate |
Indicates if the Scope should count towards the Stack Trace.
Definition at line 167 of file BadScope.cs.
|
getprivate set |
|
getset |
The Function Object of the Scope.
Definition at line 146 of file BadScope.cs.
|
getprivate set |
Is true if the Break Keyword was set.
Definition at line 172 of file BadScope.cs.
|
getprivate set |
Is true if the Continue Keyword was set.
Definition at line 177 of file BadScope.cs.
|
get |
|
get |
|
staticget |
A Class Prototype for the Scope.
Definition at line 188 of file BadScope.cs.
|
get |
The Extension Provider.
Definition at line 136 of file BadScope.cs.
|
get |
A List of Registered APIs.
Definition at line 131 of file BadScope.cs.
|
getprivate set |