1using System.Collections;
21 new Dictionary<string, BadObjectReference>();
30 InnerTable =
new Dictionary<string, BadObject>();
38 public BadTable(Dictionary<string, BadObject> table)
43 foreach (KeyValuePair<string, BadObject> kvp
in InnerTable)
61#region IBadEnumerable Members
70 .Select(kvp =>
new BadTable(
new Dictionary<string, BadObject>
72 {
"Key", kvp.Key }, {
"Value", kvp.Value },
84 IEnumerator IEnumerable.GetEnumerator()
130 return InnerTable.ContainsKey(propName) || (caller !=
null && caller.Provider.HasObject<
BadTable>(propName));
171 if (
InnerTable.TryGetValue(propName, out var result))
177 (o, p, t, noChange) =>
193 throw BadRuntimeException.
Create(
null,$
"Cannot assign object {o.GetType().Name} to property '{propName}' of type '{info.Type.Name}'", p);
198 BadObject? oldValueRef = propRef.Dereference(p);
208 propRef.Set(o, p, t);
223 if (t?.Type !=
null && !t.Type.IsAssignableFrom(o))
225 throw BadRuntimeException.
Create(
null,$
"Cannot assign object {o.GetType().Name} to property '{propName}' of type '{t.Type.Name}'", p);
252 if (!
InnerTable.ContainsKey(propName) && caller !=
null && caller.Provider.HasObject<
BadTable>(propName))
254 return caller.Provider.GetObjectReference(GetType(), propName,
this, caller);
265 StringBuilder sb =
new StringBuilder();
269 foreach (KeyValuePair<string, BadObject> kvp
in InnerTable)
273 sb.AppendLine(
"RECURSION_PROTECT");
278 string kStr = kvp.Key;
280 string vStr =
"{...}";
282 if (!done.Contains(kvp.Value))
284 vStr = kvp.Value.ToSafeString(done)
288 if (kStr.Contains(
"\n"))
290 kStr = kStr.Replace(
"\n",
"\n\t");
293 if (vStr.Contains(
"\n"))
295 vStr = vStr.Replace(
"\n",
"\n\t");
298 sb.AppendLine($
"\t{kStr}: {vStr}");
303 return sb.ToString();
Implements the Scope for the Script Engine.
Gets thrown by the runtime.
static BadRuntimeException Create(BadScope? scope, string message)
Creates a new BadScriptException.
The Base Class for all BadScript Objects.
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< BadSourcePosition?, BadObject > getter, Action< BadObject, BadSourcePosition?, BadPropertyInfo?>? setter=null, Action< BadSourcePosition?>? delete=null)
Creates a new Reference Object.
Stores Meta Information about a Property.
bool IsReadOnly
Indicates if this property is read only.
BadClassPrototype? Type
The (optional) Type used for typechecking if a value gets assigned to this property.
Implements a Table Structure for the BadScript Language.
BadObjectReference GetProperty(string propName, bool useExtensions, BadScope? caller=null)
Returns a Reference to the Property with the given Name.
override BadClassPrototype GetPrototype()
bool OnChangePropertyInternal(string propName, BadObject oldValue, BadObject newValue)
Func< string, BadObject, BadObject, bool >? m_OnChangeProperty
static ? BadClassPrototype s_Prototype
The Prototype for the BadScript Table.
Action< string, BadObject, BadObject > OnChangedProperty
readonly Dictionary< string, BadObjectReference > m_ReferenceCache
BadTable(Dictionary< string, BadObject > table)
Creates a new Table Object.
override string ToSafeString(List< BadObject > done)
void SetChangeInterceptor(Func< string, BadObject, BadObject, bool >? interceptor)
Dictionary< string, BadPropertyInfo > PropertyInfos
A Table of additional property information.
BadTable()
Creates a new Table Object.
BadObjectReference GetLocalReference(string propName)
Returns a Reference to a Local Property with the given Name.
static BadClassPrototype Prototype
IEnumerator< BadObject > GetEnumerator()
Returns the Enumerator for this Table.
Dictionary< string, BadObject > InnerTable
The Inner Table for this Object.
bool RemoveKey(string key)
Removes a Property from the Table.
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...
BadPropertyInfo GetPropertyInfo(string propName)
Returns Property Information for a given Key.
override BadObjectReference GetProperty(string propName, BadScope? caller=null)
Returns a Reference to the Property with the given Name.The Property Reference
The Any Prototype, Base type for all types.
static readonly BadAnyPrototype Instance
The Instance of the BadAnyPrototype.
Implements a Class Prototype for the BadScript Language.
virtual bool IsAssignableFrom(BadObject obj)
Returns true if the provided object is an instance of this class or a subclass of this class.
Helper Class that Builds a Native Class from a Prototype.
static BadClassPrototype GetNative(string name)
Returns a Native Class Prototype for the given Native Type.
Defines a BadScript Enumerable.
Contains the Error Objects for the BadScript2 Language.
Contains the Interop Abstractions and Implementations for the BadScript2 Language.
Contains Runtime Type Objects.
Contains the Runtime Objects.