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 string m_Name
 
readonly BadScope m_Scope
 
readonly BadObjectReference m_NameReference
 
readonly BadObjectReference m_GetAttributesReference
 
readonly BadObjectReference m_GetValueReference
 
readonly BadObjectReference m_SetValueReference
 
readonly BadObjectReference m_IsReadonlyReference
 
readonly BadObjectReference m_MemberTypeReference
 

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 (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 115 of file BadScope.cs.

Constructor & Destructor Documentation

◆ BadMemberInfo()

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

Definition at line 134 of file BadScope.cs.

135 {
136 m_Name = name;
137 m_Scope = scope;
138 m_NameReference = BadObjectReference.Make("MemberInfo.Name", () => m_Name);
139 m_GetAttributesReference = BadObjectReference.Make("MemberInfo.GetAttributes",
140 () => new BadInteropFunction("GetAttributes", GetAttributes, false, BadArray.Prototype));
141 m_GetValueReference = BadObjectReference.Make("MemberInfo.GetValue",
142 () => new BadInteropFunction("GetValue", GetValue, false, BadAnyPrototype.Instance));
143 m_SetValueReference = BadObjectReference.Make("MemberInfo.SetValue",
144 () => new BadInteropFunction("SetValue", SetValue, false, BadAnyPrototype.Instance,
145 new BadFunctionParameter("value", false, false, false, null, BadAnyPrototype.Instance),
146 new BadFunctionParameter("noChangeEvent", true, true, false, null, BadNativeClassBuilder.GetNative("bool"))));
148 BadObjectReference.Make("MemberInfo.IsReadonly", () => m_Scope.GetVariableInfo(m_Name).IsReadOnly);
149 m_MemberTypeReference = BadObjectReference.Make("MemberInfo.MemberType",
151 }
BadObject SetValue(BadExecutionContext ctx, BadObject[] args)
Definition BadScope.cs:168
readonly BadObjectReference m_MemberTypeReference
Definition BadScope.cs:132
readonly BadObjectReference m_NameReference
Definition BadScope.cs:127
readonly BadObjectReference m_GetValueReference
Definition BadScope.cs:129
BadObject GetValue(BadExecutionContext ctx, BadObject[] args)
Definition BadScope.cs:163
readonly BadObjectReference m_GetAttributesReference
Definition BadScope.cs:128
readonly BadObjectReference m_SetValueReference
Definition BadScope.cs:130
BadObject GetAttributes(BadExecutionContext ctx, BadObject[] args)
Definition BadScope.cs:153
readonly BadObjectReference m_IsReadonlyReference
Definition BadScope.cs:131
BadPropertyInfo GetVariableInfo(string name)
Returns the variable info of the specified variable.
Definition BadScope.cs:946
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< BadObject > getter, Action< BadObject, BadPropertyInfo?>? setter=null, Action? 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 153 of file BadScope.cs.

154 {
155 if(m_Scope.Attributes.TryGetValue(m_Name, out var attributes))
156 {
157 return new BadArray(attributes.ToList());
158 }
159
160 return new BadArray();
161 }
IReadOnlyDictionary< string, BadObject[]> Attributes
Definition BadScope.cs:261

◆ 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 202 of file BadScope.cs.

203 {
204 switch (propName)
205 {
206 case "Name":
207 return m_NameReference;
208 case "GetAttributes":
210 case "GetValue":
211 return m_GetValueReference;
212 case "SetValue":
213 return m_SetValueReference;
214 case "IsReadonly":
216 case "MemberType":
218 default:
219 return base.GetProperty(propName, caller);
220 }
221 }
virtual BadObjectReference GetProperty(string propName, BadScope? caller=null)
Returns a Reference to the Property with the given Name.
Definition BadObject.cs:129

◆ GetPrototype()

override BadClassPrototype BadScript2.Runtime.BadMemberInfo.GetPrototype ( )

Definition at line 224 of file BadScope.cs.

225 {
226 return s_Prototype;
227 }
static readonly BadNativeClassPrototype< BadMemberInfo > s_Prototype
Definition BadScope.cs:119

◆ GetValue()

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

Definition at line 163 of file BadScope.cs.

164 {
165 return m_Scope.GetVariable(m_Name).Dereference();
166 }
BadObjectReference GetVariable(string name, BadScope caller)
Returns the variable reference of the specified variable.
Definition BadScope.cs:1018

◆ 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 186 of file BadScope.cs.

187 {
188 switch (propName)
189 {
190 case "Name":
191 case "GetAttributes":
192 case "GetValue":
193 case "SetValue":
194 case "IsReadonly":
195 case "MemberType":
196 return true;
197 default:
198 return base.HasProperty(propName, caller);
199 }
200 }

◆ SetValue()

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

Definition at line 168 of file BadScope.cs.

169 {
170 if(args.Length == 1)
171 {
172 m_Scope.GetVariable(m_Name, ctx.Scope).Set(args[0]);
173 }
174 else if(args.Length == 2)
175 {
176 if (args[1] is not IBadBoolean noEvents)
177 {
178 throw new BadRuntimeException("Second Argument must be a boolean");
179 }
180
181 m_Scope.GetVariable(m_Name, ctx.Scope).Set(args[0], null, noEvents.Value);
182 }
183 return Null;
184 }
static readonly BadObject Null
The Null Value for the BadScript Language.
Definition BadObject.cs:28
void Set(BadObject obj, 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 229 of file BadScope.cs.

230 {
231 return "MemberInfo: " + m_Name;
232 }

Member Data Documentation

◆ m_GetAttributesReference

readonly BadObjectReference BadScript2.Runtime.BadMemberInfo.m_GetAttributesReference
private

Definition at line 128 of file BadScope.cs.

◆ m_GetValueReference

readonly BadObjectReference BadScript2.Runtime.BadMemberInfo.m_GetValueReference
private

Definition at line 129 of file BadScope.cs.

◆ m_IsReadonlyReference

readonly BadObjectReference BadScript2.Runtime.BadMemberInfo.m_IsReadonlyReference
private

Definition at line 131 of file BadScope.cs.

◆ m_MemberTypeReference

readonly BadObjectReference BadScript2.Runtime.BadMemberInfo.m_MemberTypeReference
private

Definition at line 132 of file BadScope.cs.

◆ m_Name

readonly string BadScript2.Runtime.BadMemberInfo.m_Name
private

Definition at line 117 of file BadScope.cs.

◆ m_NameReference

readonly BadObjectReference BadScript2.Runtime.BadMemberInfo.m_NameReference
private

Definition at line 127 of file BadScope.cs.

◆ m_Scope

readonly BadScope BadScript2.Runtime.BadMemberInfo.m_Scope
private

Definition at line 118 of file BadScope.cs.

◆ m_SetValueReference

readonly BadObjectReference BadScript2.Runtime.BadMemberInfo.m_SetValueReference
private

Definition at line 130 of file BadScope.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")
)

Definition at line 119 of file BadScope.cs.

Property Documentation

◆ Prototype

BadClassPrototype BadScript2.Runtime.BadMemberInfo.Prototype
staticget

Definition at line 125 of file BadScope.cs.


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