1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-17 07:44:09 +02:00

Improved generic param reflection in comptime

This commit is contained in:
Brian Fiete 2022-01-31 15:41:05 -05:00
parent 157d3f90e5
commit 26506efc1e
9 changed files with 143 additions and 19 deletions

View file

@ -482,6 +482,7 @@ namespace System
static extern Type Comptime_GetTypeById(int32 typeId);
static extern Type Comptime_GetTypeByName(StringView name);
static extern String Comptime_Type_ToString(int32 typeId);
static extern Type Comptime_GetSpecializedType(Type unspecializedType, Span<Type> typeArgs);
static extern bool Comptime_Type_GetCustomAttribute(int32 typeId, int32 attributeId, void* dataPtr);
static extern int32 Comptime_GetMethodCount(int32 typeId);
@ -548,6 +549,12 @@ namespace System
}
}
void ComptimeToString(String strBuffer)
{
if (Compiler.IsComptime)
strBuffer.Append(Comptime_Type_ToString((.)mTypeId));
}
public virtual void GetFullName(String strBuffer)
{
GetBasicName(strBuffer);
@ -1261,6 +1268,23 @@ namespace System.Reflection
}
}
[Ordered, AlwaysInclude(AssumeInstantiated=true)]
class GenericParamType : Type
{
public override void GetName(String strBuffer)
{
if (Compiler.IsComptime)
this.[Friend]ComptimeToString(strBuffer);
else
strBuffer.Append("$GenericParam");
}
public override void GetFullName(String strBuffer)
{
GetName(strBuffer);
}
}
public enum TypeFlags : uint32
{
UnspecializedGeneric = 0x0001,