BadScript 2
Loading...
Searching...
No Matches
BadVoidPrototype.cs
Go to the documentation of this file.
4
6
12{
16 private BadVoidPrototype() : base("void", BadMetaData.Empty) { }
17
21 public static BadVoidPrototype Instance { get; } = new BadVoidPrototype();
22
23 public static BadObject Object { get; } = new BadVoidObject();
24
26 protected override BadClassPrototype? BaseClass { get; } = null;
27
29 public override bool IsAbstract { get; } = true;
30
32 public override IReadOnlyCollection<BadInterfacePrototype> Interfaces { get; } =
33 Array.Empty<BadInterfacePrototype>();
34
36 public override IEnumerable<BadObject> CreateInstance(BadExecutionContext caller, bool setThis = true)
37 {
38 throw BadRuntimeException.Create(caller.Scope, "Cannot create an instance of void");
39 }
40
42 public override bool IsAssignableFrom(BadObject obj)
43 {
44 return obj == Object;
45 }
46
48 public override bool IsSuperClassOf(BadClassPrototype proto)
49 {
50 return proto == Instance;
51 }
52
53#region Nested type: BadVoidObject
54
55 private class BadVoidObject : BadObject
56 {
58 {
59 return Instance;
60 }
61
62 public override string ToSafeString(List<BadObject> done)
63 {
64 return "<void>";
65 }
66
67 public override string ToString()
68 {
69 return "<void>";
70 }
71
72 public override bool HasProperty(string propName, BadScope? caller = null)
73 {
74 return false;
75 }
76
77 public override BadObjectReference GetProperty(string propName, BadScope? caller = null)
78 {
79 throw BadRuntimeException.Create(caller, $"Property '{propName}' does not exist on void");
80 }
81 }
82
83#endregion
84}
Implements a Meta Data container for an expression.
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
static BadRuntimeException Create(BadScope? scope, string message)
Creates a new BadScriptException.
The Base Class for all BadScript Objects.
Definition BadObject.cs:14
Implements the base functionality for a BadScript Reference.
Implements a Class Prototype for the BadScript Language.
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 Void Prototype, can be assigned to nothing, can not be inherited from, can not be instantiated....
override IReadOnlyCollection< BadInterfacePrototype > Interfaces
override IEnumerable< BadObject > CreateInstance(BadExecutionContext caller, bool setThis=true)
override bool IsSuperClassOf(BadClassPrototype proto)
Returns true if the Class is a Subclass of the given Class.true if the Class is a Subclass of the giv...
override bool IsAssignableFrom(BadObject obj)
Returns true if the provided object is an instance of this class or a subclass of this class....
static BadVoidPrototype Instance
The Instance of the BadVoidPrototype.
BadVoidPrototype()
Creates a new BadVoidPrototype.
Contains the Parser for the BadScript2 Language.
Contains the Error Objects for the BadScript2 Language.
Contains Runtime Interface Objects.