BadScript 2
Loading...
Searching...
No Matches
BadScript2.Runtime.BadMemberInfo Class Reference
Inheritance diagram for BadScript2.Runtime.BadMemberInfo:
BadScript2.Runtime.Objects.BadObject

Public Member Functions

 BadMemberInfo (string name, BadScope scope)
 
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 Instance.
 
override BadObjectReference GetProperty (string propName, BadScope? caller=null)
 Returns a Reference to the Property with the given Name.
 
override BadClassPrototype GetPrototype ()
 
override string ToSafeString (List< BadObject > done)
 
- Public Member Functions inherited from BadScript2.Runtime.Objects.BadObject
BadClassPrototype GetPrototype ()
 Returns the Prototype of this Object.
 
string ToSafeString (List< BadObject > done)
 Returns a String Representation of this Object. This function is recursion proof and supports circular references.
 
override string ToString ()
 Returns a String Representation of this Object.
 

Properties

static BadClassPrototype Prototype [get]
 

Private Member Functions

BadObject GetAttributes (BadExecutionContext ctx, BadObject[] args)
 
BadObject GetValue (BadExecutionContext ctx, BadObject[] args)
 
BadObject SetValue (BadExecutionContext ctx, BadObject[] args)
 

Private Attributes

readonly Lazy< BadObjectReferencem_GetAttributesReference
 
readonly Lazy< BadObjectReferencem_GetValueReference
 
readonly Lazy< BadObjectReferencem_IsReadonlyReference
 
readonly Lazy< BadObjectReferencem_MemberTypeReference
 
readonly string m_Name
 
readonly Lazy< BadObjectReferencem_NameReference
 
readonly BadScope m_Scope
 
readonly Lazy< BadObjectReferencem_SetValueReference
 

Static Private Attributes

static readonly BadNativeClassPrototype< BadMemberInfos_Prototype
 

Additional Inherited Members

- Static Public Member Functions inherited from BadScript2.Runtime.Objects.BadObject
static bool CanWrap (object? o)
 Returns true if the given object cam be wrapped.
 
static BadObject Wrap< T > (T obj, bool allowNative=true)
 Wraps the given object into a BadObject Instance.
 
static implicit operator BadObject (bool b)
 Implicit Converstion from Boolean to BadObject.
 
static implicit operator BadObject (BadNullable< bool > b)
 Converts the given object to a BadObject Instance.
 
static implicit operator BadObject (DateTimeOffset d)
 
static implicit operator BadObject (TimeSpan t)
 
static implicit operator BadObject (decimal d)
 Implicit Converstion from Number to BadObject.
 
static implicit operator BadObject (BadNullable< decimal > b)
 Converts the given object to a BadObject Instance.
 
static implicit operator BadObject (string s)
 Implicit Converstion from String to BadObject.
 
static implicit operator BadObject (BadNullable< string > b)
 Converts the given object to a BadObject Instance.
 
- Static Public Attributes inherited from BadScript2.Runtime.Objects.BadObject
static readonly BadObject Null = new BadNullObject()
 The Null Value for the BadScript Language.
 
static readonly BadObject True = new BadBoolean(true)
 The True Value for the BadScript Language.
 
static readonly BadObject False = new BadBoolean(false)
 The False Value for the BadScript Language.
 

Detailed Description

Definition at line 10 of file BadMemberInfo.cs.

Constructor & Destructor Documentation

◆ BadMemberInfo()

BadScript2.Runtime.BadMemberInfo.BadMemberInfo ( string  name,
BadScope  scope 
)

Definition at line 30 of file BadMemberInfo.cs.

31 {
32 m_Name = name;
33 m_Scope = scope;
34 m_NameReference = new Lazy<BadObjectReference>(() => BadObjectReference.Make("MemberInfo.Name", (p) => m_Name));
35
37 new Lazy<BadObjectReference>(() => BadObjectReference.Make("MemberInfo.GetAttributes",
38 (p) => new BadInteropFunction("GetAttributes",
40 false,
42 )
43 )
44 );
45
46 m_GetValueReference = new Lazy<BadObjectReference>(() => BadObjectReference.Make("MemberInfo.GetValue",
47 (p) => new BadInteropFunction("GetValue",
49 false,
51 )
52 )
53 );
54
55 m_SetValueReference = new Lazy<BadObjectReference>(() => BadObjectReference.Make("MemberInfo.SetValue",
56 (p) => new BadInteropFunction("SetValue",
58 false,
60 new BadFunctionParameter("value",
61 false,
62 false,
63 false,
64 null,
66 ),
67 new BadFunctionParameter("noChangeEvent",
68 true,
69 true,
70 false,
71 null,
73 )
74 )
75 )
76 );
77
79 new Lazy<BadObjectReference>(() =>
80 BadObjectReference.Make("MemberInfo.IsReadonly",
83 )
84 );
85
86 m_MemberTypeReference = new Lazy<BadObjectReference>(() => BadObjectReference.Make("MemberInfo.MemberType",
88 .Type ??
90 )
91 );
92 }
BadObject SetValue(BadExecutionContext ctx, BadObject[] args)
readonly Lazy< BadObjectReference > m_GetValueReference
readonly Lazy< BadObjectReference > m_MemberTypeReference
BadObject GetValue(BadExecutionContext ctx, BadObject[] args)
readonly Lazy< BadObjectReference > m_IsReadonlyReference
readonly Lazy< BadObjectReference > m_NameReference
readonly Lazy< BadObjectReference > m_GetAttributesReference
BadObject GetAttributes(BadExecutionContext ctx, BadObject[] args)
readonly Lazy< BadObjectReference > m_SetValueReference
BadPropertyInfo GetVariableInfo(string name)
Returns the variable info of the specified variable.
Definition BadScope.cs:808
Interop Function taking an array of arguments.
Implements a Dynamic List/Array for the BadScript Language.
Definition BadArray.cs:17
static BadClassPrototype Prototype
The Prototype for the BadScript Array.
Definition BadArray.cs:40
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.
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.
The Any Prototype, Base type for all types.
static readonly BadAnyPrototype Instance
The Instance of the BadAnyPrototype.
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.

Member Function Documentation

◆ GetAttributes()

BadObject BadScript2.Runtime.BadMemberInfo.GetAttributes ( BadExecutionContext  ctx,
BadObject[]  args 
)
private

Definition at line 96 of file BadMemberInfo.cs.

97 {
98 if (m_Scope.Attributes.TryGetValue(m_Name, out BadObject[]? attributes))
99 {
100 return new BadArray(attributes.ToList());
101 }
102
103 return new BadArray();
104 }
IReadOnlyDictionary< string, BadObject[]> Attributes
Definition BadScope.cs:126
The Base Class for all BadScript Objects.
Definition BadObject.cs:14

◆ GetProperty()

override BadObjectReference BadScript2.Runtime.BadMemberInfo.GetProperty ( string  propName,
BadScope caller = null 
)
virtual

Returns a Reference to the Property with the given Name.

Parameters
propNameThe Property Name
callerThe caller Scope
Returns
The Property Reference

Reimplemented from BadScript2.Runtime.Objects.BadObject.

Definition at line 149 of file BadMemberInfo.cs.

150 {
151 switch (propName)
152 {
153 case "Name":
154 return m_NameReference.Value;
155 case "GetAttributes":
156 return m_GetAttributesReference.Value;
157 case "GetValue":
158 return m_GetValueReference.Value;
159 case "SetValue":
160 return m_SetValueReference.Value;
161 case "IsReadonly":
162 return m_IsReadonlyReference.Value;
163 case "MemberType":
164 return m_MemberTypeReference.Value;
165 default:
166 return base.GetProperty(propName, caller);
167 }
168 }

◆ GetPrototype()

override BadClassPrototype BadScript2.Runtime.BadMemberInfo.GetPrototype ( )

Definition at line 171 of file BadMemberInfo.cs.

172 {
173 return s_Prototype;
174 }
static readonly BadNativeClassPrototype< BadMemberInfo > s_Prototype

◆ GetValue()

BadObject BadScript2.Runtime.BadMemberInfo.GetValue ( BadExecutionContext  ctx,
BadObject[]  args 
)
private

Definition at line 106 of file BadMemberInfo.cs.

107 {
109 .Dereference(null);
110 }
BadObjectReference GetVariable(string name, BadScope caller)
Returns the variable reference of the specified variable.
Definition BadScope.cs:879

◆ HasProperty()

override bool BadScript2.Runtime.BadMemberInfo.HasProperty ( string  propName,
BadScope caller = null 
)
virtual

Returns true if the object contains a given property or there exists an extension for the current Instance.

Parameters
propNameThe Property Name
callerThe caller Scope
Returns
True if the Property or an Extension with that name exists

Reimplemented from BadScript2.Runtime.Objects.BadObject.

Definition at line 133 of file BadMemberInfo.cs.

134 {
135 switch (propName)
136 {
137 case "Name":
138 case "GetAttributes":
139 case "GetValue":
140 case "SetValue":
141 case "IsReadonly":
142 case "MemberType":
143 return true;
144 default:
145 return base.HasProperty(propName, caller);
146 }
147 }

◆ SetValue()

BadObject BadScript2.Runtime.BadMemberInfo.SetValue ( BadExecutionContext  ctx,
BadObject[]  args 
)
private

Definition at line 112 of file BadMemberInfo.cs.

113 {
114 if (args.Length == 1)
115 {
116 m_Scope.GetVariable(m_Name, ctx.Scope)
117 .Set(args[0], null);
118 }
119 else if (args.Length == 2)
120 {
121 if (args[1] is not IBadBoolean noEvents)
122 {
123 throw new BadRuntimeException("Second Argument must be a boolean");
124 }
125
126 m_Scope.GetVariable(m_Name, ctx.Scope)
127 .Set(args[0], null, null, noEvents.Value);
128 }
129
130 return Null;
131 }
static readonly BadObject Null
The Null Value for the BadScript Language.
Definition BadObject.cs:28
void Set(BadObject obj, BadSourcePosition? position, BadPropertyInfo? info=null, bool noChangeEvent=false)
Sets the Referenced Object to a new Value.
Implements the Interface for Native Boolean.
Definition IBadBoolean.cs:7

◆ ToSafeString()

override string BadScript2.Runtime.BadMemberInfo.ToSafeString ( List< BadObject done)

Definition at line 176 of file BadMemberInfo.cs.

177 {
178 return "MemberInfo: " + m_Name;
179 }

Member Data Documentation

◆ m_GetAttributesReference

readonly Lazy<BadObjectReference> BadScript2.Runtime.BadMemberInfo.m_GetAttributesReference
private

Definition at line 20 of file BadMemberInfo.cs.

◆ m_GetValueReference

readonly Lazy<BadObjectReference> BadScript2.Runtime.BadMemberInfo.m_GetValueReference
private

Definition at line 21 of file BadMemberInfo.cs.

◆ m_IsReadonlyReference

readonly Lazy<BadObjectReference> BadScript2.Runtime.BadMemberInfo.m_IsReadonlyReference
private

Definition at line 22 of file BadMemberInfo.cs.

◆ m_MemberTypeReference

readonly Lazy<BadObjectReference> BadScript2.Runtime.BadMemberInfo.m_MemberTypeReference
private

Definition at line 23 of file BadMemberInfo.cs.

◆ m_Name

readonly string BadScript2.Runtime.BadMemberInfo.m_Name
private

Definition at line 24 of file BadMemberInfo.cs.

◆ m_NameReference

readonly Lazy<BadObjectReference> BadScript2.Runtime.BadMemberInfo.m_NameReference
private

Definition at line 26 of file BadMemberInfo.cs.

◆ m_Scope

readonly BadScope BadScript2.Runtime.BadMemberInfo.m_Scope
private

Definition at line 27 of file BadMemberInfo.cs.

◆ m_SetValueReference

readonly Lazy<BadObjectReference> BadScript2.Runtime.BadMemberInfo.m_SetValueReference
private

Definition at line 28 of file BadMemberInfo.cs.

◆ s_Prototype

readonly BadNativeClassPrototype<BadMemberInfo> BadScript2.Runtime.BadMemberInfo.s_Prototype
staticprivate
Initial value:
=
new BadNativeClassPrototype<BadMemberInfo>("MemberInfo",
(c, a) => throw BadRuntimeException.Create(c.Scope,
"MemberInfo is a read only object"
),
null
)

Definition at line 12 of file BadMemberInfo.cs.

Property Documentation

◆ Prototype

BadClassPrototype BadScript2.Runtime.BadMemberInfo.Prototype
staticget

Definition at line 94 of file BadMemberInfo.cs.


The documentation for this class was generated from the following file: