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

Appended field type population issue fixed, circular ref handled

This commit is contained in:
Brian Fiete 2022-07-05 13:01:46 -07:00
parent f326df71d9
commit 7278e090a1
2 changed files with 14 additions and 4 deletions

View file

@ -3781,7 +3781,7 @@ void BfIRBuilder::CreateTypeDefinition_Data(BfModule* populateModule, BfTypeInst
{
auto fieldTypeInst = fieldInstance->mResolvedType->ToTypeInstance();
if (fieldInstance->mDataSize != fieldTypeInst->mInstSize)
if (fieldInstance->mDataSize > fieldTypeInst->mInstSize)
{
SizedArray<BfIRType, 2> types;
types.push_back(MapTypeInst(fieldTypeInst));
@ -3789,7 +3789,7 @@ void BfIRBuilder::CreateTypeDefinition_Data(BfModule* populateModule, BfTypeInst
resolvedFieldIRType = CreateStructType(types);
}
else
resolvedFieldIRType = MapTypeInst(fieldTypeInst);
resolvedFieldIRType = MapTypeInst(fieldTypeInst);
}
if (fieldInstance->mDataOffset > dataPos)

View file

@ -5137,9 +5137,18 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
SetAndRestoreValue<BfFieldDef*> prevTypeRef(mContext->mCurTypeState->mCurFieldDef, fieldDef);
SetAndRestoreValue<BfTypeState::ResolveKind> prevResolveKind(mContext->mCurTypeState->mResolveKind, BfTypeState::ResolveKind_FieldType);
PopulateType(resolvedFieldType, BfPopulateType_Data);
auto fieldTypeInst = resolvedFieldType->ToTypeInstance();
dataSize = fieldTypeInst->mInstSize;
alignSize = fieldTypeInst->mInstAlign;
dataSize = BF_MAX(fieldTypeInst->mInstSize, 0);
alignSize = BF_MAX(fieldTypeInst->mInstAlign, 1);
if (fieldTypeInst->mTypeFailed)
{
TypeFailed(fieldTypeInst);
fieldInstance->mResolvedType = GetPrimitiveType(BfTypeCode_Var);
continue;
}
if ((typeInstance != NULL) && (fieldTypeInst->mTypeDef->mIsAbstract))
{
@ -5208,6 +5217,7 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
Fail("Append fields must be classes", nameRefNode, true);
}
BF_ASSERT(dataSize >= 0);
fieldInstance->mDataSize = dataSize;
if (!isUnion)
{