1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 19:48:20 +02:00

Improved comptime TypeDeclaration support, reworked base type population

This commit is contained in:
Brian Fiete 2025-01-14 12:54:24 -08:00
parent 16371ab07c
commit 062170d9e0
5 changed files with 22 additions and 9 deletions

View file

@ -6099,7 +6099,7 @@ BfIRValue BfModule::GetTypeTypeData(BfType* type, BfCreateTypeDataContext& ctx,
if (type->IsObject())
{
typeFlags |= BfTypeFlags_Object;
if (typeInstance->mDefineState >= BfTypeDefineState_DefinedAndMethodsSlotted)
if ((!wantsTypeDecl) && (typeInstance->mDefineState >= BfTypeDefineState_DefinedAndMethodsSlotted))
{
BfMethodInstance* methodInstance = typeInstance->mVirtualMethodTable[mCompiler->GetVTableMethodOffset() + 0].mImplementingMethod;
if ((methodInstance != NULL) && (methodInstance->GetOwner() != mContext->mBfObjectType))
@ -22016,10 +22016,14 @@ void BfModule::ProcessMethod(BfMethodInstance* methodInstance, bool isInlineDup,
mBfIRBuilder->ClearDebugLocation();
BfIRValue fromBool;
mBfIRBuilder->RestoreDebugLocation();
if (!mCompiler->mIsResolveOnly)
{
if (!mCurTypeInstance->IsValuelessType())
ret = mBfIRBuilder->CreateRet(GetThis().mValue);
else
mBfIRBuilder->CreateRetVoid();
}
//ExtendLocalLifetimes(0);
EmitLifetimeEnds(&mCurMethodState->mHeadScope);

View file

@ -44,6 +44,7 @@ enum BfPopulateType
BfPopulateType_IdentityNoRemapAlias,
BfPopulateType_Declaration,
BfPopulateType_BaseType,
BfPopulateType_CustomAttributes,
BfPopulateType_Interfaces_Direct,
BfPopulateType_AllowStaticMethods,
BfPopulateType_Interfaces_All,

View file

@ -4240,7 +4240,7 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
if ((checkType != NULL) && (!checkType->IsInterface()) && (populateBase))
{
SetAndRestoreValue<BfTypeInstance*> prevBaseType(mContext->mCurTypeState->mCurBaseType, checkType->ToTypeInstance());
PopulateType(checkType, (populateType <= BfPopulateType_BaseType) ? BfPopulateType_BaseType : BfPopulateType_Data);
PopulateType(checkType, BfPopulateType_Declaration);
}
if (typeInstance->mDefineState >= BfTypeDefineState_Defined)
@ -4466,6 +4466,8 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
baseTypeInst = ResolveTypeDef(mCompiler->mBfObjectTypeDef)->ToTypeInstance();
}
}
if (populateType > BfPopulateType_CustomAttributes)
PopulateType(baseTypeInst, BfPopulateType_Data);
typeInstance->mBaseTypeMayBeIncomplete = false;
@ -4746,6 +4748,9 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
}
}
if (typeInstance->mDefineState < BfTypeDefineState_HasCustomAttributes)
typeInstance->mDefineState = BfTypeDefineState_HasCustomAttributes;
if (typeInstance->mTypeOptionsIdx == -2)
{
SetTypeOptions(typeInstance);

View file

@ -459,6 +459,7 @@ enum BfTypeDefineState : uint8
BfTypeDefineState_Declaring,
BfTypeDefineState_Declared,
BfTypeDefineState_ResolvingBaseType,
BfTypeDefineState_HasCustomAttributes,
BfTypeDefineState_HasInterfaces_Direct,
BfTypeDefineState_CETypeInit,
BfTypeDefineState_CEPostTypeInit,

View file

@ -3899,6 +3899,8 @@ addr_ce CeContext::GetReflectTypeDecl(int typeId)
if (bfType->mDefineState < BfTypeDefineState_HasInterfaces_Direct)
ceModule->PopulateType(bfType, BfPopulateType_Interfaces_Direct);
if (bfType->mDefineState < BfTypeDefineState_HasCustomAttributes)
ceModule->PopulateType(bfType, BfPopulateType_CustomAttributes);
BfCreateTypeDataContext createTypeDataCtx;
auto irData = ceModule->CreateTypeDeclData(bfType);