1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-18 16:10:26 +02:00

Comptime method reflection fixes

This commit is contained in:
Brian Fiete 2021-10-28 08:26:12 -07:00
parent db839035c0
commit 9de99cd422
2 changed files with 23 additions and 3 deletions

View file

@ -29,8 +29,8 @@ namespace System.Reflection
get get
{ {
if (Compiler.IsComptime) if (Compiler.IsComptime)
Type.[Friend]Comptime_Method_GetName(mNativeMethodInstance); return Type.[Friend]Comptime_Method_GetName(mNativeMethodInstance);
return ""; return "?";
} }
} }
public int ParamCount public int ParamCount

View file

@ -32,7 +32,7 @@ namespace System
if (matched.[Friend]mMethodData != null) if (matched.[Friend]mMethodData != null)
return .Err(.MultipleResults); return .Err(.MultipleResults);
else else
matched = methodInfo; matched = methodInfo;
} }
} }
@ -41,6 +41,26 @@ namespace System
return .Ok(matched); return .Ok(matched);
} }
[Comptime]
public virtual Result<ComptimeMethodInfo, MethodError> GetMethod(StringView methodName, BindingFlags bindingFlags = cDefaultLookup)
{
ComptimeMethodInfo matched = default;
for (let methodInfo in ComptimeMethodInfo.Enumerator(this as TypeInstance, bindingFlags))
{
if (methodInfo.Name == methodName)
{
if (matched.mNativeMethodInstance != 0)
return .Err(.MultipleResults);
else
matched = methodInfo;
}
}
if (matched.mNativeMethodInstance == 0)
return .Err(.NoResults);
return .Ok(matched);
}
public virtual Result<MethodInfo, MethodError> GetMethod(int methodIdx) public virtual Result<MethodInfo, MethodError> GetMethod(int methodIdx)
{ {
return .Err(.NoResults); return .Err(.NoResults);