42 public string Name {
get; }
104 return caller !=
null && caller.Provider.HasObject(GetType(), propName);
122 if (caller.ClassObject ==
null)
126 else if (caller.ClassObject ==
this)
130 else if (caller.ClassObject.InheritsFrom(
Prototype))
144 $
"Property {propName} not found in class {Name} or any of its base classes"
148 if ((vis & visibility) == 0)
152 $
"Property {Name}.{propName} is not visible from {caller?.Name ?? "global
"}"
159 $
"{Name}.{propName}",
163 BadPropertyInfo info = Scope.GetTable().GetPropertyInfo(propName);
165 BadObject? existing = Scope.GetTable().InnerTable[propName];
167 if (existing != Null && info.IsReadOnly)
169 throw BadRuntimeException.Create(caller, $
"{Name}.{propName} is read-only");
172 if (info.Type !=
null && !info.Type.IsAssignableFrom(o))
174 throw BadRuntimeException.Create(
176 $
"Cannot assign object {o.GetType().Name} to property '{propName}' of type '{info.Type.Name}'"
209 return caller.Provider.GetObjectReference(GetType(), propName,
SuperClass ??
this, caller);
232 result = result.Dereference();
238 $
"class {Name}\n{Scope.ToSafeString(done)}";
Contains Static Data for the BadScript Language.
The Execution Context. Every execution of a script needs a context the script is running in....
BadScope Scope
The Root Scope of the Context.
Implements the Scope for the Script Engine.
BadTable GetTable()
Returns the Variable Table of the current scope.
override BadObjectReference GetProperty(string propName, BadScope? caller=null)
Returns a Reference to the Property with the given Name.The Property Reference
bool OnChange(string name, BadObject oldValue, BadObject newValue)
bool HasLocal(string name, BadScope caller, bool useExtensions=true)
returns true if the specified variable is defined in the current scope
static BadPropertyVisibility GetPropertyVisibility(string propName)
Returns the visibility of the specified property.
void OnChanged(string name, BadObject oldValue, BadObject newValue)
Gets thrown by the runtime.
static BadRuntimeException Create(BadScope? scope, string message)
Creates a new BadScriptException.
The Base Class for all BadScript Objects.
string ToSafeString(List< BadObject > done)
Returns a String Representation of this Object. This function is recursion proof and supports circula...
static readonly BadObject Null
The Null Value for the BadScript Language.
Implements the base functionality for a BadScript Reference.
static BadObjectReference Make(string refText, Func< BadObject > getter, Action< BadObject, BadPropertyInfo?>? setter=null, Action? delete=null)
Creates a new Reference Object.
Stores Meta Information about a Property.
Implements a function that can be called from the script.
Implements a Type Instance in the BadScript Language.
void SetThis()
Sets the 'this' parameter of the class scope to be this instance.
override string ToSafeString(List< BadObject > done)
BadClassPrototype Prototype
The Class Prototype used to create this instance.
BadClass(string name, BadExecutionContext context, BadClass? baseClass, BadClassPrototype prototype)
Creates a new BadScript Class Instance.
BadClass? SuperClass
The Super Class of this Class(if this class is not at the end of the inheritance chain)
void SetThis(BadClass thisInstance)
Sets the 'this' parameter of the class scope to be the specified instance.
readonly? BadClass m_BaseClass
Base Class Instance.
override BadClassPrototype GetPrototype()
BadObjectReference GetProperty(string propName, BadPropertyVisibility visibility, BadScope? caller=null)
Gets a property from this class or any of its base classes.
BadScope Scope
Table of all members of this type(excluding base class members)
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 Ins...
override BadObjectReference GetProperty(string propName, BadScope? caller=null)
Returns a Reference to the Property with the given Name.The Property Reference
string Name
The Type Name.
bool InheritsFrom(BadClassPrototype proto)
Returns true if the given object is an instance of the specified prototype.
BadExecutionContext Context
Implements a Class Prototype for the BadScript Language.
virtual bool IsSuperClassOf(BadClassPrototype proto)
Returns true if the Class is a Subclass of the given Class.
Contains Shared Data Structures and Functionality.
Contains the Error Objects for the BadScript2 Language.
Contains Runtime Function Objects.
Contains Runtime Type Objects.
BadPropertyVisibility
The Visibility of a Property.