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 );
225
226#region IDisposable Members
227
231 public void Dispose()
232 {
233 if (m_IsDisposed)
234 {
235 return;
236 }
237
238 m_IsDisposed = true;
239
240 foreach (Action finalizer in m_Finalizers)
241 {
242 finalizer();
243 }
244
245 m_Finalizers.Clear();
246 }
247
248#endregion
249
251 {
252 return new BadArray(m_ScopeVariables.InnerTable.Keys.Select(x => (BadObject)new BadMemberInfo(x, this))
253 .ToList()
254 );
255 }
256
261 internal void SetRegisteredApi(string api)
262 {
263 if (Parent != null)
264 {
265 Parent.SetRegisteredApi(api);
266
267 return;
268 }
269
270 if (!m_RegisteredApis.Contains(api))
271 {
272 m_RegisteredApis.Add(api);
273 }
274 }
275
281 public void AddFinalizer(Action finalizer)
282 {
283 if (m_IsDisposed)
284 {
285 throw BadRuntimeException.Create(this, "Scope is already disposed");
286 }
287
288 m_Finalizers.Add(finalizer);
289 }
290
295 public void SetCaller(BadScope? caller)
296 {
297 m_Caller = caller;
298 }
299
305 {
306 return Parent?.GetRootScope() ?? this;
307 }
308
315 public void AddSingleton<T>(T instance) where T : class
316 {
317 if (instance == null)
318 {
319 throw new BadRuntimeException("Cannot add null as singleton");
320 }
321
322 m_SingletonCache.Add(typeof(T), instance);
323 }
324
330 public T? GetSingleton<T>()
331 {
332 if (Parent != null)
333 {
334 return Parent.GetSingleton<T>();
335 }
336
337 if (m_SingletonCache.TryGetValue(typeof(T), out object? value))
338 {
339 return (T)value;
340 }
341
342 return default;
343 }
344
352 public T GetSingleton<T>(bool createNew) where T : new()
353 {
354 if (Parent != null)
355 {
356 return Parent.GetSingleton<T>(createNew);
357 }
358
359 if (m_SingletonCache.ContainsKey(typeof(T)))
360 {
361 return (T)m_SingletonCache[typeof(T)];
362 }
363
364 if (!createNew)
365 {
366 throw new Exception("Singleton not found");
367 }
368
369 T v = new T();
370 m_SingletonCache[typeof(T)] = v;
371
372 return v;
373 }
374
380 {
381 return Prototype;
382 }
383
391 private static BadScope CreateScope(BadExecutionContext ctx, string name, BadTable? locals = null)
392 {
393 BadScope s = locals != null
394 ? new BadScope(name, ctx.Scope.Provider, locals)
395 : new BadScope(name, ctx.Scope.Provider);
396
397 foreach (KeyValuePair<Type, object> kvp in ctx.Scope.GetRootScope()
398 .m_SingletonCache)
399 {
400 s.m_SingletonCache.Add(kvp.Key, kvp.Value);
401 }
402
403 return s;
404 }
405
410 public void SetFlags(BadScopeFlags flags)
411 {
412 Flags = flags;
413 }
414
419 public string GetStackTrace()
420 {
421 return GetStackTrace(this);
422 }
423
429 private static string GetStackTrace(BadScope scope)
430 {
431 BadScope? current = scope;
432 List<BadScope> stack = new List<BadScope>();
433
434 while (current != null)
435 {
436 if (current.CountInStackTrace)
437 {
438 stack.Add(current);
439 }
440
441 current = current.m_Caller ?? current.Parent;
442 }
443
444 return string.Join("\n", stack.Select(s => s.Name));
445 }
446
447 private static IEnumerable<BadScope> GetStackTraceEnumerable(BadScope scope)
448 {
449 BadScope? current = scope;
450
451 while (current != null)
452 {
453 if (current.CountInStackTrace)
454 {
455 yield return current;
456 }
457
458 current = current.m_Caller ?? current.Parent;
459 }
460 }
461
462 public IEnumerable<BadScope> GetStackTraceEnumerable() => GetStackTraceEnumerable(this);
463
464 public BadScope GetFirstTracableOrRoot() => CountInStackTrace ? this : Parent?.GetFirstTracableOrRoot() ?? this;
465
472 {
473 return flags &
474 ~(BadScopeFlags.CaptureReturn |
475 BadScopeFlags.CaptureBreak |
476 BadScopeFlags.CaptureContinue |
477 BadScopeFlags.CaptureThrow);
478 }
479
484 public void SetBreak()
485 {
486 if ((Flags & BadScopeFlags.AllowBreak) == 0)
487 {
488 throw new BadRuntimeException("Break not allowed in this scope");
489 }
490
491 IsBreak = true;
492
493 if ((Flags & BadScopeFlags.CaptureBreak) == 0)
494 {
495 Parent?.SetBreak();
496 }
497 }
498
503 public void SetContinue()
504 {
505 if ((Flags & BadScopeFlags.AllowContinue) == 0)
506 {
507 throw new BadRuntimeException("Continue not allowed in this scope");
508 }
509
510 IsContinue = true;
511
512 if ((Flags & BadScopeFlags.CaptureContinue) == 0)
513 {
514 Parent?.SetContinue();
515 }
516 }
517
523 {
524 return m_Exports ?? Null;
525 }
526
527 public void SetExports(BadExecutionContext ctx, BadObject exports)
528 {
529 if (m_Exports != null)
530 {
531 throw BadRuntimeException.Create(ctx.Scope, "Exports are already set");
532 }
533
534 m_Exports = exports;
535 }
536
542 public void AddExport(string key, BadObject value)
543 {
544 if (Parent != null)
545 {
546 Parent.AddExport(key, value);
547 }
548 else
549 {
550 if (m_Exports == null)
551 {
552 m_Exports = new BadTable();
553 }
554
555 m_Exports.SetProperty(key, value);
556 }
557 }
558
564 public void SetReturnValue(BadObject? value)
565 {
566 if ((Flags & BadScopeFlags.AllowReturn) == 0)
567 {
568 throw new BadRuntimeException("Return not allowed in this scope");
569 }
570
571 ReturnValue = value;
572
573 if ((Flags & BadScopeFlags.CaptureReturn) == 0)
574 {
575 Parent?.SetReturnValue(value);
576 }
577 }
578
584 {
585 return m_ScopeVariables;
586 }
587
588
597 public BadScope CreateChild(string name,
598 BadScope? caller,
599 bool? useVisibility,
600 BadScopeFlags flags = BadScopeFlags.RootScope)
601 {
602 BadScope sc = new BadScope(this, caller, name, flags, useVisibility ?? m_UseVisibility)
603 {
604 ClassObject = ClassObject, FunctionObject = FunctionObject,
605 };
606
607 return sc;
608 }
609
610 internal void OnChanged(string name, BadObject oldValue, BadObject newValue)
611 {
612 if (ClassObject == null)
613 {
614 return;
615 }
616
617 if (m_Attributes.TryGetValue(name, out BadObject[]? attributes))
618 {
619 BadMemberInfo? member = new BadMemberInfo(name, this);
620
621 foreach (BadClass attribute in attributes.OfType<BadClass>())
622 {
624 {
625 BadFunction? invoke = (BadFunction)attribute.GetProperty("OnChanged")
626 .Dereference(null);
627
628 BadMemberChangedEvent? eventObj =
629 new BadMemberChangedEvent(ClassObject!, member, oldValue, newValue);
630
631 foreach (BadObject o in invoke.Invoke(new BadObject[] { eventObj },
632 new BadExecutionContext(this)
633 ))
634 {
635 //Execute
636 }
637 }
638 }
639 }
640 }
641
642 internal bool OnChange(string name, BadObject oldValue, BadObject newValue)
643 {
644 if (ClassObject == null)
645 {
646 return false;
647 }
648
649 if (m_Attributes.TryGetValue(name, out BadObject[]? attributes))
650 {
651 BadMemberInfo? member = new BadMemberInfo(name, this);
652
653 foreach (BadClass attribute in attributes.OfType<BadClass>())
654 {
656 {
657 BadFunction? invoke = (BadFunction)attribute.GetProperty("OnChange")
658 .Dereference(null);
659
660 BadMemberChangingEvent? eventObj =
661 new BadMemberChangingEvent(ClassObject!, member, oldValue, newValue);
662 BadObject? obj = Null;
663
664 foreach (BadObject o in invoke.Invoke(new BadObject[] { eventObj },
665 new BadExecutionContext(this)
666 ))
667 {
668 //Execute
669 obj = o;
670 }
671
672 if (eventObj.Cancel)
673 {
674 return true;
675 }
676 }
677 }
678 }
679
680 return false;
681 }
682
683 internal IEnumerable<BadObject> InitializeAttributes()
684 {
685 if (ClassObject == null)
686 {
687 throw new BadRuntimeException("Scope is not a class scope");
688 }
689
690 foreach (KeyValuePair<string, BadObject[]> kvp in m_Attributes)
691 {
692 BadMemberInfo? member = new BadMemberInfo(kvp.Key, this);
693
694 foreach (BadClass attribute in kvp.Value.OfType<BadClass>())
695 {
697 {
698 BadFunction? invoke = (BadFunction)attribute.GetProperty("Initialize")
699 .Dereference(null);
700
701 foreach (BadObject o in invoke.Invoke(new BadObject[] { ClassObject!, member },
702 new BadExecutionContext(this)
703 ))
704 {
705 //Execute
706 yield return o;
707 }
708 }
709 }
710 }
711 }
712
713 public void DefineProperty(string name,
715 BadExpression getAccessor,
716 BadExpression? setAccessor,
717 BadExecutionContext caller,
718 BadObject[] attributes)
719 {
720 if (HasLocal(name, caller.Scope, false))
721 {
722 throw new BadRuntimeException($"Property {name} is already defined");
723 }
724
725 Action<BadObject, BadSourcePosition?, BadPropertyInfo?>? setter = null;
726
727 if (setAccessor != null)
728 {
729 setter = (value, p, pi) =>
730 {
731 BadExecutionContext? setCtx =
732 new BadExecutionContext(caller.Scope.CreateChild($"set {name}", caller.Scope, null));
733
734 setCtx.Scope.DefineVariable("value",
735 value,
736 setCtx.Scope,
738 );
739
740 foreach (BadObject o in setCtx.Execute(setAccessor))
741 {
742 //Execute
743 }
744 };
745 }
746
747 m_ScopeVariables.PropertyInfos.Add(name, new BadPropertyInfo(type, setter == null));
748
749 m_ScopeVariables.InnerTable.Add(name,
750 BadObjectReference.Make($"property {name}",
751 (p) =>
752 {
753 BadExecutionContext? getCtx =
754 new BadExecutionContext(caller.Scope
755 .CreateChild($"get {name}",
756 caller.Scope,
757 null
758 )
759 );
760 BadObject? get = Null;
761
762 foreach (BadObject o in getCtx.Execute(getAccessor))
763 {
764 get = o;
765 }
766
767 return get.Dereference(p);
768 },
769 setter
770 )
771 );
772
773 m_Attributes[name] = attributes;
774 }
775
784 public void DefineVariable(string name,
785 BadObject value,
786 BadScope? caller = null,
787 BadPropertyInfo? info = null,
788 BadObject[]? attributes = null)
789 {
790 if (HasLocal(name, caller ?? this, false))
791 {
792 throw new BadRuntimeException($"Variable {name} is already defined");
793 }
794
795 m_Attributes[name] = attributes ?? [];
796
797 m_ScopeVariables.GetProperty(name, false, caller ?? this)
798 .Set(value, null, info, true);
799 }
800
808 {
809 if (HasLocal(name, this))
810 {
811 return m_ScopeVariables.GetPropertyInfo(name);
812 }
813
814 if (Parent == null)
815 {
816 throw new BadRuntimeException($"Variable '{name}' is not defined");
817 }
818
819 return Parent!.GetVariableInfo(name);
820 }
821
827 public static BadPropertyVisibility GetPropertyVisibility(string propName)
828 {
829 char first = propName[0];
830 char second = propName.Length > 1 ? propName[1] : '\0';
831
832 return second switch
833 {
834 '_' => first == '_' ? BadPropertyVisibility.Private : BadPropertyVisibility.Public,
835 _ => first == '_' ? BadPropertyVisibility.Protected : BadPropertyVisibility.Public,
836 };
837 }
838
844 public bool IsVisibleParentOf(BadScope scope)
845 {
846 if (scope == this)
847 {
848 return true;
849 }
850
851 BadScope? current = scope.Parent;
852
853 while (current != null)
854 {
855 if (!current.m_UseVisibility)
856 {
857 return false;
858 }
859
860 if (current == this)
861 {
862 return true;
863 }
864
865 current = current.Parent;
866 }
867
868 return false;
869 }
870
878 public BadObjectReference GetVariable(string name, BadScope caller)
879 {
880 if (m_UseVisibility)
881 {
882 BadPropertyVisibility vis = IsVisibleParentOf(caller)
883 ? BadPropertyVisibility.All
884 : BadPropertyVisibility.Public;
885
886 if ((GetPropertyVisibility(name) & vis) == 0)
887 {
888 throw BadRuntimeException.Create(caller, $"Variable '{name}' is not visible to {caller}");
889 }
890 }
891
892 if (HasLocal(name, caller))
893 {
894 return m_ScopeVariables.GetProperty(name, caller);
895 }
896
897 if (Parent == null)
898 {
899 throw BadRuntimeException.Create(caller, $"Variable '{name}' is not defined");
900 }
901
902 return Parent!.GetVariable(name, caller);
903 }
904
911 public BadObjectReference GetVariable(string name)
912 {
913 return GetVariable(name, this);
914 }
915
923 public bool HasLocal(string name, BadScope caller, bool useExtensions = true)
924 {
925 return !useExtensions
926 ? m_ScopeVariables.InnerTable.ContainsKey(name)
927 : m_ScopeVariables.HasProperty(name, caller);
928 }
929
936 public bool HasVariable(string name, BadScope caller)
937 {
938 return HasLocal(name, caller) || (Parent != null && Parent.HasVariable(name, caller));
939 }
940
941
943 public override BadObjectReference GetProperty(string propName, BadScope? caller = null)
944 {
945 return HasVariable(propName, caller ?? this)
946 ? GetVariable(propName, caller ?? this)
947 : base.GetProperty(propName, caller);
948 }
949
951 public override bool HasProperty(string propName, BadScope? caller = null)
952 {
953 return HasVariable(propName, caller ?? this) || base.HasProperty(propName, caller);
954 }
955
956
958 public override string ToSafeString(List<BadObject> done)
959 {
960 done.Add(this);
961
962 return m_ScopeVariables.ToSafeString(done);
963 }
964}
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:304
BadScope CreateChild(string name, BadScope? caller, bool? useVisibility, BadScopeFlags flags=BadScopeFlags.RootScope)
Creates a subscope of the current scope.
Definition BadScope.cs:597
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:878
BadTable GetTable()
Returns the Variable Table of the current scope.
Definition BadScope.cs:583
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:379
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:936
IEnumerable< BadObject > InitializeAttributes()
Definition BadScope.cs:683
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:713
bool IsVisibleParentOf(BadScope scope)
Returns true if the specified scope is visible to the current scope.
Definition BadScope.cs:844
void SetContinue()
Sets the continue keyword inside this scope.
Definition BadScope.cs:503
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:419
static IEnumerable< BadScope > GetStackTraceEnumerable(BadScope scope)
Definition BadScope.cs:447
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:943
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:951
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:391
BadPropertyInfo GetVariableInfo(string name)
Returns the variable info of the specified variable.
Definition BadScope.cs:807
bool OnChange(string name, BadObject oldValue, BadObject newValue)
Definition BadScope.cs:642
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:429
void Dispose()
Disposes the Scope and calls all finalizers.
Definition BadScope.cs:231
void SetExports(BadExecutionContext ctx, BadObject exports)
Definition BadScope.cs:527
void SetRegisteredApi(string api)
Registers an API.
Definition BadScope.cs:261
bool HasLocal(string name, BadScope caller, bool useExtensions=true)
returns true if the specified variable is defined in the current scope
Definition BadScope.cs:923
void AddExport(string key, BadObject value)
Sets an exported key value pair in the scope.
Definition BadScope.cs:542
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:564
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:958
static BadScopeFlags ClearCaptures(BadScopeFlags flags)
Clears all Capture Flags from the given Flags.
Definition BadScope.cs:471
void SetCaller(BadScope? caller)
Sets the Caller of the Scope.
Definition BadScope.cs:295
void SetBreak()
Sets the break keyword inside this scope.
Definition BadScope.cs:484
BadObjectReference GetVariable(string name)
Returns a variable reference of the specified variable.
Definition BadScope.cs:911
void AddFinalizer(Action finalizer)
Adds a Finalizer to the Scope.
Definition BadScope.cs:281
static BadPropertyVisibility GetPropertyVisibility(string propName)
Returns the visibility of the specified property.
Definition BadScope.cs:827
BadObject GetExports()
Returns the exported key value pairs of the scope.
Definition BadScope.cs:522
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:784
void OnChanged(string name, BadObject oldValue, BadObject newValue)
Definition BadScope.cs:610
void SetFlags(BadScopeFlags flags)
Sets the Scope Flags.
Definition BadScope.cs:410
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.