1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 04:22:20 +02:00

Improved support for boxed structs with emitted interfaces

This commit is contained in:
Brian Fiete 2023-02-14 09:52:20 -05:00
parent e18bf57c87
commit e8c763eb20

View file

@ -3654,6 +3654,19 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
return; return;
auto typeInstance = resolvedTypeRef->ToTypeInstance(); auto typeInstance = resolvedTypeRef->ToTypeInstance();
BfTypeInstance* boxedUnderlyingTypeInstance = NULL;
if (typeInstance->IsBoxed())
{
auto underlyingType = typeInstance->GetUnderlyingType();
if (underlyingType->IsPrimitiveType())
boxedUnderlyingTypeInstance = GetPrimitiveStructType(((BfPrimitiveType*)underlyingType)->mTypeDef->mTypeCode);
else
boxedUnderlyingTypeInstance = underlyingType->ToTypeInstance();
typeInstance->mTypeDef = boxedUnderlyingTypeInstance->mTypeDef;
}
auto typeDef = typeInstance->mTypeDef; auto typeDef = typeInstance->mTypeDef;
BF_ASSERT((typeInstance->mTypeDef->mNextRevision == NULL) || (mCompiler->IsAutocomplete())); BF_ASSERT((typeInstance->mTypeDef->mNextRevision == NULL) || (mCompiler->IsAutocomplete()));
@ -4246,23 +4259,30 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
wantPopulateInterfaces = true; wantPopulateInterfaces = true;
} }
if ((typeInstance->mCeTypeInfo != NULL) && (!typeInstance->mCeTypeInfo->mPendingInterfaces.IsEmpty())) // Handle CE interfaces
{ {
for (auto ifaceTypeId : typeInstance->mCeTypeInfo->mPendingInterfaces) auto checkTypeInst = typeInstance;
{ if (boxedUnderlyingTypeInstance != NULL)
auto ifaceType = mContext->mTypes[ifaceTypeId]; checkTypeInst = boxedUnderlyingTypeInstance;
if ((ifaceType == NULL) || (!ifaceType->IsInterface()))
continue;
auto ifaceInst = ifaceType->ToTypeInstance();
if (ifaceSet.Add(ifaceInst)) if ((checkTypeInst->mCeTypeInfo != NULL) && (!checkTypeInst->mCeTypeInfo->mPendingInterfaces.IsEmpty()))
{
for (auto ifaceTypeId : checkTypeInst->mCeTypeInfo->mPendingInterfaces)
{ {
// Not base type auto ifaceType = mContext->mTypes[ifaceTypeId];
BfInterfaceDecl ifaceDecl; if ((ifaceType == NULL) || (!ifaceType->IsInterface()))
ifaceDecl.mIFaceTypeInst = ifaceInst; continue;
ifaceDecl.mTypeRef = NULL; auto ifaceInst = ifaceType->ToTypeInstance();
ifaceDecl.mDeclaringType = typeDef->GetDefinition();
interfaces.Add(ifaceDecl); if (ifaceSet.Add(ifaceInst))
{
// Not base type
BfInterfaceDecl ifaceDecl;
ifaceDecl.mIFaceTypeInst = ifaceInst;
ifaceDecl.mTypeRef = NULL;
ifaceDecl.mDeclaringType = typeDef->GetDefinition();
interfaces.Add(ifaceDecl);
}
} }
} }
} }