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 29 of file BadMemberInfo.cs.

30 {
31 m_Name = name;
32 m_Scope = scope;
33 m_NameReference = new Lazy<BadObjectReference>(() => BadObjectReference.Make("MemberInfo.Name", (p) => m_Name));
34
36 new Lazy<BadObjectReference>(() => BadObjectReference.Make("MemberInfo.GetAttributes",
37 (p) => new BadInteropFunction("GetAttributes",
39 false,
41 )
42 )
43 );
44
45 m_GetValueReference = new Lazy<BadObjectReference>(() => BadObjectReference.Make("MemberInfo.GetValue",
46 (p) => new BadInteropFunction("GetValue",
48 false,
50 )
51 )
52 );
53
54 m_SetValueReference = new Lazy<BadObjectReference>(() => BadObjectReference.Make("MemberInfo.SetValue",
55 (p) => new BadInteropFunction("SetValue",
57 false,
59 new BadFunctionParameter("value",
60 false,
61 false,
62 false,
63 null,
65 ),
66 new BadFunctionParameter("noChangeEvent",
67 true,
68 true,
69 false,
70 null,
72 )
73 )
74 )
75 );
76
78 new Lazy<BadObjectReference>(() =>
79 BadObjectReference.Make("MemberInfo.IsReadonly",
82 )
83 );
84
85 m_MemberTypeReference = new Lazy<BadObjectReference>(() => BadObjectReference.Make("MemberInfo.MemberType",
87 .Type ??
89 )
90 );
91 }
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:807
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 95 of file BadMemberInfo.cs.

96 {
97 if (m_Scope.Attributes.TryGetValue(m_Name, out BadObject[]? attributes))
98 {
99 return new BadArray(attributes.ToList());
100 }
101
102 return new BadArray();
103 }
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 148 of file BadMemberInfo.cs.

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

◆ GetPrototype()

override BadClassPrototype BadScript2.Runtime.BadMemberInfo.GetPrototype ( )

Definition at line 170 of file BadMemberInfo.cs.

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

◆ GetValue()

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

Definition at line 105 of file BadMemberInfo.cs.

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

◆ 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 132 of file BadMemberInfo.cs.

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

◆ SetValue()

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

Definition at line 111 of file BadMemberInfo.cs.

112 {
113 if (args.Length == 1)
114 {
115 m_Scope.GetVariable(m_Name, ctx.Scope)
116 .Set(args[0], null);
117 }
118 else if (args.Length == 2)
119 {
120 if (args[1] is not IBadBoolean noEvents)
121 {
122 throw new BadRuntimeException("Second Argument must be a boolean");
123 }
124
125 m_Scope.GetVariable(m_Name, ctx.Scope)
126 .Set(args[0], null, null, noEvents.Value);
127 }
128
129 return Null;
130 }
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 175 of file BadMemberInfo.cs.

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

Member Data Documentation

◆ m_GetAttributesReference

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

Definition at line 19 of file BadMemberInfo.cs.

◆ m_GetValueReference

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

Definition at line 20 of file BadMemberInfo.cs.

◆ m_IsReadonlyReference

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

Definition at line 21 of file BadMemberInfo.cs.

◆ m_MemberTypeReference

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

Definition at line 22 of file BadMemberInfo.cs.

◆ m_Name

readonly string BadScript2.Runtime.BadMemberInfo.m_Name
private

Definition at line 23 of file BadMemberInfo.cs.

◆ m_NameReference

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

Definition at line 25 of file BadMemberInfo.cs.

◆ m_Scope

readonly BadScope BadScript2.Runtime.BadMemberInfo.m_Scope
private

Definition at line 26 of file BadMemberInfo.cs.

◆ m_SetValueReference

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

Definition at line 27 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"
)
)

Definition at line 12 of file BadMemberInfo.cs.

Property Documentation

◆ Prototype

BadClassPrototype BadScript2.Runtime.BadMemberInfo.Prototype
staticget

Definition at line 93 of file BadMemberInfo.cs.


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