BadScript 2
Loading...
Searching...
No Matches
BadScope.cs
Go to the documentation of this file.
9
10namespace BadScript2.Runtime;
11
15public class BadScope : BadObject, IDisposable
16{
17 private readonly Dictionary<string, BadObject[]> m_Attributes = new Dictionary<string, BadObject[]>();
18
22 private readonly List<Action> m_Finalizers = new List<Action>();
23
28
32 private readonly List<string> m_RegisteredApis = new List<string>();
33
37 private readonly BadTable m_ScopeVariables = new BadTable();
38
42 private readonly Dictionary<Type, object> m_SingletonCache = new Dictionary<Type, object>();
43
47 private readonly bool m_UseVisibility;
48
53
58
59 private bool m_IsDisposed;
60
68 public BadScope(string name,
70 BadScope? caller = null,
71 BadScopeFlags flags = BadScopeFlags.RootScope)
72 {
73 Name = name;
74 Flags = flags;
75 m_Caller = caller;
76 m_Provider = provider;
78 m_ScopeVariables.OnChangedProperty += OnChanged;
79 }
80
89 public BadScope(string name,
91 BadTable locals,
92 BadScope? caller = null,
93 BadScopeFlags flags = BadScopeFlags.RootScope)
94 {
95 Name = name;
96 Flags = flags;
97 m_Caller = caller;
98 m_ScopeVariables = locals;
99 m_Provider = provider;
101 m_ScopeVariables.OnChangedProperty += OnChanged;
102 }
103
112 private BadScope(BadScope parent,
113 BadScope? caller,
114 string name,
115 BadScopeFlags flags = BadScopeFlags.RootScope,
116 bool useVisibility = false) : this(name,
117 parent.Provider,
118 caller,
119 ClearCaptures(parent.Flags) | flags
120 )
121 {
122 m_UseVisibility = useVisibility;
123 Parent = parent;
124 }
125
126 public IReadOnlyDictionary<string, BadObject[]> Attributes => m_Attributes;
127
131 public IReadOnlyCollection<string> RegisteredApis => Parent?.RegisteredApis ?? m_RegisteredApis;
132
136 public BadInteropExtensionProvider Provider => Parent != null ? Parent.Provider : m_Provider;
137
141 public BadClass? ClassObject { get; internal set; }
142
146 public BadFunction? FunctionObject { get; internal set; }
147
148
152 public BadScope? Parent { get; }
153
157 public string Name { get; }
158
162 public BadScopeFlags Flags { get; private set; }
163
167 private bool CountInStackTrace => (Flags & BadScopeFlags.CaptureReturn) != 0;
168
172 public bool IsBreak { get; private set; }
173
177 public bool IsContinue { get; private set; }
178
182 public BadObject? ReturnValue { get; private set; }
183
184
189 (c, args) =>
190 {
191 switch (args.Length)
192 {
193 case 0:
194 {
195 return CreateScope(c, "SCOPE");
196 }
197 case 1:
198 {
199 if (args[0] is not IBadString name)
200 {
201 throw new BadRuntimeException("Expected Name in Scope Constructor");
202 }
203
204 return CreateScope(c, name.Value);
205 }
206 case 2:
207 {
208 if (args[0] is not IBadString name)
209 {
210 throw new BadRuntimeException("Expected Name in Scope Constructor");
211 }
212
213 if (args[1] is not BadTable locals)
214 {
215 throw new BadRuntimeException("Expected Locals Table in Scope Constructor");
216 }
217
218 return CreateScope(c, name.Value, locals);
219 }
220 default:
221 throw new BadRuntimeException("Expected 1 or 2 Arguments in Scope Constructor");
222 }
223 },
224 null
225 );
226
227#region IDisposable Members
228
232 public void Dispose()
233 {
234 if (m_IsDisposed)
235 {
236 return;
237 }
238
239 m_IsDisposed = true;
240
241 foreach (Action finalizer in m_Finalizers)
242 {
243 finalizer();
244 }
245
246 m_Finalizers.Clear();
247 }
248
249#endregion
250
252 {
253 return new BadArray(m_ScopeVariables.InnerTable.Keys.Select(x => (BadObject)new BadMemberInfo(x, this))
254 .ToList()
255 );
256 }
257
262 internal void SetRegisteredApi(string api)
263 {
264 if (Parent != null)
265 {
266 Parent.SetRegisteredApi(api);
267
268 return;
269 }
270
271 if (!m_RegisteredApis.Contains(api))
272 {
273 m_RegisteredApis.Add(api);
274 }
275 }
276
282 public void AddFinalizer(Action finalizer)
283 {
284 if (m_IsDisposed)
285 {
286 throw BadRuntimeException.Create(this, "Scope is already disposed");
287 }
288
289 m_Finalizers.Add(finalizer);
290 }
291
296 public void SetCaller(BadScope? caller)
297 {
298 m_Caller = caller;
299 }
300
306 {
307 return Parent?.GetRootScope() ?? this;
308 }
309
316 public void AddSingleton<T>(T instance) where T : class
317 {
318 if (instance == null)
319 {
320 throw new BadRuntimeException("Cannot add null as singleton");
321 }
322
323 m_SingletonCache.Add(typeof(T), instance);
324 }
325
331 public T? GetSingleton<T>()
332 {
333 if (Parent != null)
334 {
335 return Parent.GetSingleton<T>();
336 }
337
338 if (m_SingletonCache.TryGetValue(typeof(T), out object? value))
339 {
340 return (T)value;
341 }
342
343 return default;
344 }
345
353 public T GetSingleton<T>(bool createNew) where T : new()
354 {
355 if (Parent != null)
356 {
357 return Parent.GetSingleton<T>(createNew);
358 }
359
360 if (m_SingletonCache.ContainsKey(typeof(T)))
361 {
362 return (T)m_SingletonCache[typeof(T)];
363 }
364
365 if (!createNew)
366 {
367 throw new Exception("Singleton not found");
368 }
369
370 T v = new T();
371 m_SingletonCache[typeof(T)] = v;
372
373 return v;
374 }
375
381 {
382 return Prototype;
383 }
384
392 private static BadScope CreateScope(BadExecutionContext ctx, string name, BadTable? locals = null)
393 {
394 BadScope s = locals != null
395 ? new BadScope(name, ctx.Scope.Provider, locals)
396 : new BadScope(name, ctx.Scope.Provider);
397
398 foreach (KeyValuePair<Type, object> kvp in ctx.Scope.GetRootScope()
399 .m_SingletonCache)
400 {
401 s.m_SingletonCache.Add(kvp.Key, kvp.Value);
402 }
403
404 return s;
405 }
406
411 public void SetFlags(BadScopeFlags flags)
412 {
413 Flags = flags;
414 }
415
420 public string GetStackTrace()
421 {
422 return GetStackTrace(this);
423 }
424
430 private static string GetStackTrace(BadScope scope)
431 {
432 BadScope? current = scope;
433 List<BadScope> stack = new List<BadScope>();
434
435 while (current != null)
436 {
437 if (current.CountInStackTrace)
438 {
439 stack.Add(current);
440 }
441
442 current = current.m_Caller ?? current.Parent;
443 }
444
445 return string.Join("\n", stack.Select(s => s.Name));
446 }
447
448 private static IEnumerable<BadScope> GetStackTraceEnumerable(BadScope scope)
449 {
450 BadScope? current = scope;
451
452 while (current != null)
453 {
454 if (current.CountInStackTrace)
455 {
456 yield return current;
457 }
458
459 current = current.m_Caller ?? current.Parent;
460 }
461 }
462
463 public IEnumerable<BadScope> GetStackTraceEnumerable() => GetStackTraceEnumerable(this);
464
465 public BadScope GetFirstTracableOrRoot() => CountInStackTrace ? this : Parent?.GetFirstTracableOrRoot() ?? this;
466
473 {
474 return flags &
475 ~(BadScopeFlags.CaptureReturn |
476 BadScopeFlags.CaptureBreak |
477 BadScopeFlags.CaptureContinue |
478 BadScopeFlags.CaptureThrow);
479 }
480
485 public void SetBreak()
486 {
487 if ((Flags & BadScopeFlags.AllowBreak) == 0)
488 {
489 throw new BadRuntimeException("Break not allowed in this scope");
490 }
491
492 IsBreak = true;
493
494 if ((Flags & BadScopeFlags.CaptureBreak) == 0)
495 {
496 Parent?.SetBreak();
497 }
498 }
499
504 public void SetContinue()
505 {
506 if ((Flags & BadScopeFlags.AllowContinue) == 0)
507 {
508 throw new BadRuntimeException("Continue not allowed in this scope");
509 }
510
511 IsContinue = true;
512
513 if ((Flags & BadScopeFlags.CaptureContinue) == 0)
514 {
515 Parent?.SetContinue();
516 }
517 }
518
524 {
525 return m_Exports ?? Null;
526 }
527
528 public void SetExports(BadExecutionContext ctx, BadObject exports)
529 {
530 if (m_Exports != null)
531 {
532 throw BadRuntimeException.Create(ctx.Scope, "Exports are already set");
533 }
534
535 m_Exports = exports;
536 }
537
543 public void AddExport(string key, BadObject value)
544 {
545 if (Parent != null)
546 {
547 Parent.AddExport(key, value);
548 }
549 else
550 {
551 if (m_Exports == null)
552 {
553 m_Exports = new BadTable();
554 }
555
556 m_Exports.SetProperty(key, value);
557 }
558 }
559
565 public void SetReturnValue(BadObject? value)
566 {
567 if ((Flags & BadScopeFlags.AllowReturn) == 0)
568 {
569 throw new BadRuntimeException("Return not allowed in this scope");
570 }
571
572 ReturnValue = value;
573
574 if ((Flags & BadScopeFlags.CaptureReturn) == 0)
575 {
576 Parent?.SetReturnValue(value);
577 }
578 }
579
585 {
586 return m_ScopeVariables;
587 }
588
589
598 public BadScope CreateChild(string name,
599 BadScope? caller,
600 bool? useVisibility,
601 BadScopeFlags flags = BadScopeFlags.RootScope)
602 {
603 BadScope sc = new BadScope(this, caller, name, flags, useVisibility ?? m_UseVisibility)
604 {
605 ClassObject = ClassObject, FunctionObject = FunctionObject,
606 };
607
608 return sc;
609 }
610
611 internal void OnChanged(string name, BadObject oldValue, BadObject newValue)
612 {
613 if (ClassObject == null)
614 {
615 return;
616 }
617
618 if (m_Attributes.TryGetValue(name, out BadObject[]? attributes))
619 {
620 BadMemberInfo? member = new BadMemberInfo(name, this);
621
622 foreach (BadClass attribute in attributes.OfType<BadClass>())
623 {
625 {
626 BadFunction? invoke = (BadFunction)attribute.GetProperty("OnChanged")
627 .Dereference(null);
628
629 BadMemberChangedEvent? eventObj =
630 new BadMemberChangedEvent(ClassObject!, member, oldValue, newValue);
631
632 foreach (BadObject o in invoke.Invoke(new BadObject[] { eventObj },
633 new BadExecutionContext(this)
634 ))
635 {
636 //Execute
637 }
638 }
639 }
640 }
641 }
642
643 internal bool OnChange(string name, BadObject oldValue, BadObject newValue)
644 {
645 if (ClassObject == null)
646 {
647 return false;
648 }
649
650 if (m_Attributes.TryGetValue(name, out BadObject[]? attributes))
651 {
652 BadMemberInfo? member = new BadMemberInfo(name, this);
653
654 foreach (BadClass attribute in attributes.OfType<BadClass>())
655 {
657 {
658 BadFunction? invoke = (BadFunction)attribute.GetProperty("OnChange")
659 .Dereference(null);
660
661 BadMemberChangingEvent? eventObj =
662 new BadMemberChangingEvent(ClassObject!, member, oldValue, newValue);
663 BadObject? obj = Null;
664
665 foreach (BadObject o in invoke.Invoke(new BadObject[] { eventObj },
666 new BadExecutionContext(this)
667 ))
668 {
669 //Execute
670 obj = o;
671 }
672
673 if (eventObj.Cancel)
674 {
675 return true;
676 }
677 }
678 }
679 }
680
681 return false;
682 }
683
684 internal IEnumerable<BadObject> InitializeAttributes()
685 {
686 if (ClassObject == null)
687 {
688 throw new BadRuntimeException("Scope is not a class scope");
689 }
690
691 foreach (KeyValuePair<string, BadObject[]> kvp in m_Attributes)
692 {
693 BadMemberInfo? member = new BadMemberInfo(kvp.Key, this);
694
695 foreach (BadClass attribute in kvp.Value.OfType<BadClass>())
696 {
698 {
699 BadFunction? invoke = (BadFunction)attribute.GetProperty("Initialize")
700 .Dereference(null);
701
702 foreach (BadObject o in invoke.Invoke(new BadObject[] { ClassObject!, member },
703 new BadExecutionContext(this)
704 ))
705 {
706 //Execute
707 yield return o;
708 }
709 }
710 }
711 }
712 }
713
714 public void DefineProperty(string name,
716 BadExpression getAccessor,
717 BadExpression? setAccessor,
718 BadExecutionContext caller,
719 BadObject[] attributes)
720 {
721 if (HasLocal(name, caller.Scope, false))
722 {
723 throw new BadRuntimeException($"Property {name} is already defined");
724 }
725
726 Action<BadObject, BadSourcePosition?, BadPropertyInfo?>? setter = null;
727
728 if (setAccessor != null)
729 {
730 setter = (value, p, pi) =>
731 {
732 BadExecutionContext? setCtx =
733 new BadExecutionContext(caller.Scope.CreateChild($"set {name}", caller.Scope, null));
734
735 setCtx.Scope.DefineVariable("value",
736 value,
737 setCtx.Scope,
739 );
740
741 foreach (BadObject o in setCtx.Execute(setAccessor))
742 {
743 //Execute
744 }
745 };
746 }
747
748 m_ScopeVariables.PropertyInfos.Add(name, new BadPropertyInfo(type, setter == null));
749
750 m_ScopeVariables.InnerTable.Add(name,
751 BadObjectReference.Make($"property {name}",
752 (p) =>
753 {
754 BadExecutionContext? getCtx =
755 new BadExecutionContext(caller.Scope
756 .CreateChild($"get {name}",
757 caller.Scope,
758 null
759 )
760 );
761 BadObject? get = Null;
762
763 foreach (BadObject o in getCtx.Execute(getAccessor))
764 {
765 get = o;
766 }
767
768 return get.Dereference(p);
769 },
770 setter
771 )
772 );
773
774 m_Attributes[name] = attributes;
775 }
776
785 public void DefineVariable(string name,
786 BadObject value,
787 BadScope? caller = null,
788 BadPropertyInfo? info = null,
789 BadObject[]? attributes = null)
790 {
791 if (HasLocal(name, caller ?? this, false))
792 {
793 throw new BadRuntimeException($"Variable {name} is already defined");
794 }
795
796 m_Attributes[name] = attributes ?? [];
797
798 m_ScopeVariables.GetProperty(name, false, caller ?? this)
799 .Set(value, null, info, true);
800 }
801
809 {
810 if (HasLocal(name, this))
811 {
812 return m_ScopeVariables.GetPropertyInfo(name);
813 }
814
815 if (Parent == null)
816 {
817 throw new BadRuntimeException($"Variable '{name}' is not defined");
818 }
819
820 return Parent!.GetVariableInfo(name);
821 }
822
828 public static BadPropertyVisibility GetPropertyVisibility(string propName)
829 {
830 char first = propName[0];
831 char second = propName.Length > 1 ? propName[1] : '\0';
832
833 return second switch
834 {
835 '_' => first == '_' ? BadPropertyVisibility.Private : BadPropertyVisibility.Public,
836 _ => first == '_' ? BadPropertyVisibility.Protected : BadPropertyVisibility.Public,
837 };
838 }
839
845 public bool IsVisibleParentOf(BadScope scope)
846 {
847 if (scope == this)
848 {
849 return true;
850 }
851
852 BadScope? current = scope.Parent;
853
854 while (current != null)
855 {
856 if (!current.m_UseVisibility)
857 {
858 return false;
859 }
860
861 if (current == this)
862 {
863 return true;
864 }
865
866 current = current.Parent;
867 }
868
869 return false;
870 }
871
879 public BadObjectReference GetVariable(string name, BadScope caller)
880 {
881 if (m_UseVisibility)
882 {
883 BadPropertyVisibility vis = IsVisibleParentOf(caller)
884 ? BadPropertyVisibility.All
885 : BadPropertyVisibility.Public;
886
887 if ((GetPropertyVisibility(name) & vis) == 0)
888 {
889 throw BadRuntimeException.Create(caller, $"Variable '{name}' is not visible to {caller}");
890 }
891 }
892
893 if (HasLocal(name, caller))
894 {
895 return m_ScopeVariables.GetProperty(name, caller);
896 }
897
898 if (Parent == null)
899 {
900 throw BadRuntimeException.Create(caller, $"Variable '{name}' is not defined");
901 }
902
903 return Parent!.GetVariable(name, caller);
904 }
905
912 public BadObjectReference GetVariable(string name)
913 {
914 return GetVariable(name, this);
915 }
916
924 public bool HasLocal(string name, BadScope caller, bool useExtensions = true)
925 {
926 return !useExtensions
927 ? m_ScopeVariables.InnerTable.ContainsKey(name)
928 : m_ScopeVariables.HasProperty(name, caller);
929 }
930
937 public bool HasVariable(string name, BadScope caller)
938 {
939 return HasLocal(name, caller) || (Parent != null && Parent.HasVariable(name, caller));
940 }
941
942
944 public override BadObjectReference GetProperty(string propName, BadScope? caller = null)
945 {
946 return HasVariable(propName, caller ?? this)
947 ? GetVariable(propName, caller ?? this)
948 : base.GetProperty(propName, caller);
949 }
950
952 public override bool HasProperty(string propName, BadScope? caller = null)
953 {
954 return HasVariable(propName, caller ?? this) || base.HasProperty(propName, caller);
955 }
956
957
959 public override string ToSafeString(List<BadObject> done)
960 {
961 done.Add(this);
962
963 return m_ScopeVariables.ToSafeString(done);
964 }
965}
Base Implementation for all Expressions used inside the Script.
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.
Definition BadScope.cs:16
BadScope(string name, BadInteropExtensionProvider provider, BadTable locals, BadScope? caller=null, BadScopeFlags flags=BadScopeFlags.RootScope)
Creates a new Scope.
Definition BadScope.cs:89
readonly BadTable m_ScopeVariables
The Scope Variables.
Definition BadScope.cs:37
BadScope GetRootScope()
Returns the Root Scope of the Scope.
Definition BadScope.cs:305
BadScope CreateChild(string name, BadScope? caller, bool? useVisibility, BadScopeFlags flags=BadScopeFlags.RootScope)
Creates a subscope of the current scope.
Definition BadScope.cs:598
BadScopeFlags Flags
The Scope Flags.
Definition BadScope.cs:162
BadInteropExtensionProvider Provider
The Extension Provider.
Definition BadScope.cs:136
BadScope? m_Caller
The Caller of the Current Scope.
Definition BadScope.cs:52
readonly Dictionary< string, BadObject[]> m_Attributes
Definition BadScope.cs:17
bool IsContinue
Is true if the Continue Keyword was set.
Definition BadScope.cs:177
readonly Dictionary< Type, object > m_SingletonCache
The Singleton Cache.
Definition BadScope.cs:42
BadObjectReference GetVariable(string name, BadScope caller)
Returns the variable reference of the specified variable.
Definition BadScope.cs:879
BadTable GetTable()
Returns the Variable Table of the current scope.
Definition BadScope.cs:584
readonly List< string > m_RegisteredApis
A List of Registered APIs.
Definition BadScope.cs:32
override BadClassPrototype GetPrototype()
Returns the Class Prototype for the Scope.
Definition BadScope.cs:380
bool HasVariable(string name, BadScope caller)
returns true if the specified variable is defined in the current scope or any parent scope
Definition BadScope.cs:937
IEnumerable< BadObject > InitializeAttributes()
Definition BadScope.cs:684
readonly bool m_UseVisibility
Indicates if the Scope uses the visibility subsystem.
Definition BadScope.cs:47
void DefineProperty(string name, BadClassPrototype type, BadExpression getAccessor, BadExpression? setAccessor, BadExecutionContext caller, BadObject[] attributes)
Definition BadScope.cs:714
bool IsVisibleParentOf(BadScope scope)
Returns true if the specified scope is visible to the current scope.
Definition BadScope.cs:845
void SetContinue()
Sets the continue keyword inside this scope.
Definition BadScope.cs:504
bool IsBreak
Is true if the Break Keyword was set.
Definition BadScope.cs:172
string GetStackTrace()
Returns the Stack Trace of the Current scope.
Definition BadScope.cs:420
static IEnumerable< BadScope > GetStackTraceEnumerable(BadScope scope)
Definition BadScope.cs:448
BadScope? Parent
The Parent Scope.
Definition BadScope.cs:152
override BadObjectReference GetProperty(string propName, BadScope? caller=null)
Returns a Reference to the Property with the given Name.The Property Reference
Definition BadScope.cs:944
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...
Definition BadScope.cs:952
readonly BadInteropExtensionProvider m_Provider
The Extension Provider.
Definition BadScope.cs:27
string Name
The Name of the Scope (for Debugging)
Definition BadScope.cs:157
IReadOnlyCollection< string > RegisteredApis
A List of Registered APIs.
Definition BadScope.cs:131
BadScope(string name, BadInteropExtensionProvider provider, BadScope? caller=null, BadScopeFlags flags=BadScopeFlags.RootScope)
Creates a new Scope.
Definition BadScope.cs:68
IReadOnlyDictionary< string, BadObject[]> Attributes
Definition BadScope.cs:126
static BadScope CreateScope(BadExecutionContext ctx, string name, BadTable? locals=null)
Creates a Root Scope with the given name.
Definition BadScope.cs:392
BadPropertyInfo GetVariableInfo(string name)
Returns the variable info of the specified variable.
Definition BadScope.cs:808
bool OnChange(string name, BadObject oldValue, BadObject newValue)
Definition BadScope.cs:643
BadClass? ClassObject
The Class Object of the Scope.
Definition BadScope.cs:141
static BadClassPrototype Prototype
A Class Prototype for the Scope.
Definition BadScope.cs:188
static string GetStackTrace(BadScope scope)
Returns the Stack Trace of the given Scope.
Definition BadScope.cs:430
void Dispose()
Disposes the Scope and calls all finalizers.
Definition BadScope.cs:232
void SetExports(BadExecutionContext ctx, BadObject exports)
Definition BadScope.cs:528
void SetRegisteredApi(string api)
Registers an API.
Definition BadScope.cs:262
bool HasLocal(string name, BadScope caller, bool useExtensions=true)
returns true if the specified variable is defined in the current scope
Definition BadScope.cs:924
void AddExport(string key, BadObject value)
Sets an exported key value pair in the scope.
Definition BadScope.cs:543
readonly List< Action > m_Finalizers
The Finalizer List of the Scope.
Definition BadScope.cs:22
BadObject? ReturnValue
The Return value of the scope.
Definition BadScope.cs:182
void SetReturnValue(BadObject? value)
Sets the Return value of this scope.
Definition BadScope.cs:565
BadObject? m_Exports
Contains the exported variables of the scope.
Definition BadScope.cs:57
bool CountInStackTrace
Indicates if the Scope should count towards the Stack Trace.
Definition BadScope.cs:167
override string ToSafeString(List< BadObject > done)
Definition BadScope.cs:959
static BadScopeFlags ClearCaptures(BadScopeFlags flags)
Clears all Capture Flags from the given Flags.
Definition BadScope.cs:472
void SetCaller(BadScope? caller)
Sets the Caller of the Scope.
Definition BadScope.cs:296
void SetBreak()
Sets the break keyword inside this scope.
Definition BadScope.cs:485
BadObjectReference GetVariable(string name)
Returns a variable reference of the specified variable.
Definition BadScope.cs:912
void AddFinalizer(Action finalizer)
Adds a Finalizer to the Scope.
Definition BadScope.cs:282
static BadPropertyVisibility GetPropertyVisibility(string propName)
Returns the visibility of the specified property.
Definition BadScope.cs:828
BadObject GetExports()
Returns the exported key value pairs of the scope.
Definition BadScope.cs:523
IEnumerable< BadScope > GetStackTraceEnumerable()
void DefineVariable(string name, BadObject value, BadScope? caller=null, BadPropertyInfo? info=null, BadObject[]? attributes=null)
Defines a new Variable in the current scope.
Definition BadScope.cs:785
void OnChanged(string name, BadObject oldValue, BadObject newValue)
Definition BadScope.cs:611
void SetFlags(BadScopeFlags flags)
Sets the Scope Flags.
Definition BadScope.cs:411
BadScope(BadScope parent, BadScope? caller, string name, BadScopeFlags flags=BadScopeFlags.RootScope, bool useVisibility=false)
Creates a new Scope.
Definition BadScope.cs:112
BadFunction? FunctionObject
The Function Object of the Scope.
Definition BadScope.cs:146
static BadRuntimeException Create(BadScope? scope, string message)
Creates a new BadScriptException.
Implements a Dynamic List/Array for the BadScript Language.
Definition BadArray.cs:17
The Base Class for all BadScript Objects.
Definition BadObject.cs:14
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.
Implements a Table Structure for the BadScript Language.
Definition BadTable.cs:14
void SetChangeInterceptor(Func< string, BadObject, BadObject, bool >? interceptor)
Definition BadTable.cs:93
Implements a function that can be called from the script.
The Any Prototype, Base type for all types.
static readonly BadAnyPrototype Instance
The Instance of the BadAnyPrototype.
Implements a Type Instance in the BadScript Language.
Definition BadClass.cs:11
BadObjectReference GetProperty(string propName, BadPropertyVisibility visibility, BadScope? caller=null)
Gets a property from this class or any of its base classes.
Definition BadClass.cs:120
bool InheritsFrom(BadClassPrototype proto)
Returns true if the given object is an instance of the specified prototype.
Definition BadClass.cs:60
Implements a Class Prototype for the BadScript Language.
Helper Class that Builds a Native Class from a Prototype.
static readonly BadInterfacePrototype InitializeAttribute
Implements the Interface for Native Strings.
Definition IBadString.cs:7
Contains Shared Data Structures and Functionality.
Contains the Expressions for the BadScript2 Language.
Contains the Error Objects for the BadScript2 Language.
Contains the Interop Abstractions and Implementations for the BadScript2 Language.
Contains Runtime Function Objects.
Contains the Native Runtime Objects.
Definition BadBoolean.cs:6
BadPropertyVisibility
The Visibility of a Property.
Contains the Runtime Objects.
Definition BadArray.cs:10
Contains the Runtime Implementation.
BadScopeFlags
Defines Different Behaviours for the Current Scope.