1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-12 13:24:09 +02:00

More 'if (Compiler.IsComptime)' protections

This commit is contained in:
Brian Fiete 2025-02-18 08:49:20 -08:00
parent 49a22f1c87
commit 575e6b439c

View file

@ -36,15 +36,21 @@ namespace System
{ {
get get
{ {
int32 baseTypeId = Type.[Friend]Comptime_Type_GetBaseType((.)mTypeId); if (Compiler.IsComptime)
return Type.[Friend]Comptime_GetTypeDeclarationById(baseTypeId); {
int32 baseTypeId = Type.[Friend]Comptime_Type_GetBaseType((.)mTypeId);
return Type.[Friend]Comptime_GetTypeDeclarationById(baseTypeId);
}
return null;
} }
} }
public TypeDeclaration OuterType public TypeDeclaration OuterType
{ {
get get
{ {
return Type.[Friend]Comptime_GetTypeDeclarationById((.)mOuterTypeId); if (Compiler.IsComptime)
return Type.[Friend]Comptime_GetTypeDeclarationById((.)mOuterTypeId);
return null;
} }
} }
@ -54,21 +60,24 @@ namespace System
public bool AlwaysVisible => mFlags.HasFlag(.AlwaysVisible); public bool AlwaysVisible => mFlags.HasFlag(.AlwaysVisible);
public bool SometimesVisible => mFlags.HasFlag(.SometimesVisible); public bool SometimesVisible => mFlags.HasFlag(.SometimesVisible);
public Type ResolvedType => Type.[Friend]Comptime_GetTypeById((.)mTypeId); public Type ResolvedType => Compiler.IsComptime ? Type.[Friend]Comptime_GetTypeById((.)mTypeId) : null;
public void GetFullName(String strBuffer) public void GetFullName(String strBuffer)
{ {
strBuffer.Append(Type.[Friend]Comptime_Type_ToString((.)mTypeId)); if (Compiler.IsComptime)
strBuffer.Append(Type.[Friend]Comptime_Type_ToString((.)mTypeId));
} }
public void GetName(String strBuffer) public void GetName(String strBuffer)
{ {
strBuffer.Append(Type.[Friend]Comptime_TypeName_ToString((.)mTypeId)); if (Compiler.IsComptime)
strBuffer.Append(Type.[Friend]Comptime_TypeName_ToString((.)mTypeId));
} }
public void GetNamespace(String strBuffer) public void GetNamespace(String strBuffer)
{ {
strBuffer.Append(Type.[Friend]Comptime_Namespace_ToString((.)mTypeId)); if (Compiler.IsComptime)
strBuffer.Append(Type.[Friend]Comptime_Namespace_ToString((.)mTypeId));
} }
public bool HasCustomAttribute<T>() where T : Attribute public bool HasCustomAttribute<T>() where T : Attribute
@ -165,17 +174,23 @@ namespace System
public bool HasDeclaredField(StringView fieldName) public bool HasDeclaredField(StringView fieldName)
{ {
return Type.[Friend]Comptime_Type_HasDeclaredMember((.)mTypeId, 0, fieldName); if (Compiler.IsComptime)
return Type.[Friend]Comptime_Type_HasDeclaredMember((.)mTypeId, 0, fieldName);
return false;
} }
public bool HasDeclaredMethod(StringView fieldName) public bool HasDeclaredMethod(StringView fieldName)
{ {
return Type.[Friend]Comptime_Type_HasDeclaredMember((.)mTypeId, 1, fieldName); if (Compiler.IsComptime)
return Type.[Friend]Comptime_Type_HasDeclaredMember((.)mTypeId, 1, fieldName);
return false;
} }
public bool HasDeclaredProperty(StringView fieldName) public bool HasDeclaredProperty(StringView fieldName)
{ {
return Type.[Friend]Comptime_Type_HasDeclaredMember((.)mTypeId, 2, fieldName); if (Compiler.IsComptime)
return Type.[Friend]Comptime_Type_HasDeclaredMember((.)mTypeId, 2, fieldName);
return false;
} }
} }