From 2131d97756f07600e7c315e1e6f91779f0fa270e Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Thu, 16 Jan 2025 07:48:31 -0800 Subject: [PATCH] Updated type - with base type dynamically handled --- BeefLibs/corlib/src/Type.bf | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/BeefLibs/corlib/src/Type.bf b/BeefLibs/corlib/src/Type.bf index e5587b67..42015f89 100644 --- a/BeefLibs/corlib/src/Type.bf +++ b/BeefLibs/corlib/src/Type.bf @@ -7,10 +7,19 @@ namespace System { public class TypeDeclaration { + protected enum Flags : uint8 + { + DeclaredInDependency = 1, + DeclaredInDependent = 2, + DeclaredInCurrent = 4, + AlwaysVisible = 8, + SometimesVisible = 0x10 + } + protected TypeId mTypeId; - protected TypeId mBaseTypeId; protected TypeId mOuterTypeId; protected TypeFlags mTypeFlags; + protected Flags mFlags; protected TypeCode mTypeCode; public static TypeDeclaration.Enumerator TypeDeclarations @@ -27,7 +36,8 @@ namespace System { get { - return Type.[Friend]Comptime_GetTypeDeclarationById((.)mBaseTypeId); + int32 baseTypeId = Type.[Friend]Comptime_Type_GetBaseType((.)mTypeId); + return Type.[Friend]Comptime_GetTypeDeclarationById(baseTypeId); } } public TypeDeclaration OuterType @@ -38,6 +48,12 @@ namespace System } } + public bool DeclaredInDependency => mFlags.HasFlag(.DeclaredInDependency); + public bool DeclaredInDependent => mFlags.HasFlag(.DeclaredInDependent); + public bool DeclaredInCurrent => mFlags.HasFlag(.DeclaredInCurrent); + public bool AlwaysVisible => mFlags.HasFlag(.AlwaysVisible); + public bool SometimesVisible => mFlags.HasFlag(.SometimesVisible); + public Type ResolvedType => Type.[Friend]Comptime_GetTypeById((.)mTypeId); public void GetFullName(String strBuffer) @@ -735,6 +751,7 @@ namespace System static extern TypeDeclaration Comptime_GetTypeDeclarationById(int32 typeId); static extern TypeDeclaration Comptime_GetTypeDeclarationByName(StringView name); static extern TypeDeclaration Comptime_GetNextTypeDeclaration(int32 lastTypeId); + static extern int32 Comptime_Type_GetBaseType(int32 typeId); static extern bool Comptime_Type_HasDeclaredMember(int32 typeId, int32 kind, StringView name); static extern Type Comptime_GetTypeById(int32 typeId); static extern Type Comptime_GetTypeByName(StringView name);