1using System.Reflection;
19 private readonly List<MethodInfo>
m_Methods =
new List<MethodInfo>();
50 bool isStatic = instance ==
null;
54 args =>
Invoke(instance, args),
71 object? obj = o.Unwrap();
76 return !t.IsValueType;
79 return t.IsInstanceOfType(obj) || t.IsNumericType() && obj.GetType().IsNumericType();
88 object obj = ro.Instance;
90 return t.IsInstanceOfType(obj);
124 if (t.IsInstanceOfType(obj))
129 if (t.IsNumericType())
131 return Convert.ChangeType(obj, t);
145 private object?[]
FindImplementation(
object? instance, IReadOnlyList<BadObject> args, out MethodInfo info)
149 if (instance ==
null && !method.IsStatic || instance !=
null && method.IsStatic)
154 ParameterInfo[] parameters = method.GetParameters();
156 if (parameters.Length != args.Count)
161 object?[] converted =
new object?[args.Count];
162 bool skipThis =
false;
164 for (
int i = 0; i < parameters.Length; i++)
166 ParameterInfo parameter = parameters[i];
169 if (!
CanConvert(argument, parameter.ParameterType))
176 converted[i] =
ConvertObject(argument, parameter.ParameterType);
202 return Wrap(info.Invoke(instance, implArgs));
Gets thrown by the runtime.
Interop Function taking an array of arguments.
Implements a Reflected Object.
Implements a Reflected Member.
string Name
The Name of the Member.
static BadObject Wrap(object? o)
Wraps an Object into a BadObject.
Implements a Reflected Method Member.
static ? object ConvertObject(BadObject o, Type t)
Converts the given Object to the given Type.
override BadObject Get(object? instance)
void AddMethod(MethodInfo method)
Adds a Method to the Reflected Method.
BadReflectedMethod(MethodInfo method)
Creates a new BadReflectedMethod.
static bool CanConvert(BadObject o, Type t)
Indicates if the given Object can be converted to the given Type.
BadFunction CreateFunction(object? instance)
Creates a new Function for the Reflected Method.
readonly List< MethodInfo > m_Methods
The Reflected Methods.
BadObject Invoke(object? instance, BadObject[] args)
Invokes the Method with the given Arguments.
object?[] FindImplementation(object? instance, IReadOnlyList< BadObject > args, out MethodInfo info)
Finds the Implementation of the Method that matches the given Arguments.
override void Set(object? instance, BadObject o)
The Base Class for all BadScript Objects.
Implements a function that can be called from the script.
Provides function parameter info.
The Any Prototype, Base type for all types.
static readonly BadAnyPrototype Instance
The Instance of the BadAnyPrototype.
Contains the Error Objects for the BadScript2 Language.
Contains the Interop Function Classes for the BadScript2 Language.
Contains the Member Classes for Reflection Objects.
Contains Runtime Function Objects.
Contains Runtime Type Objects.
Contains the Runtime Objects.