mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 04:22:20 +02:00
Fixed payload enum alignment calculation
This commit is contained in:
parent
fa8b9eca28
commit
d1d3af1cc0
1 changed files with 7 additions and 1 deletions
|
@ -4605,14 +4605,20 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
|
||||||
|
|
||||||
if ((typeInstance->IsPayloadEnum()) && (!typeInstance->IsBoxed()))
|
if ((typeInstance->IsPayloadEnum()) && (!typeInstance->IsBoxed()))
|
||||||
{
|
{
|
||||||
|
typeInstance->mAlign = unionInnerType->mAlign;
|
||||||
|
|
||||||
int lastTagId = -1;
|
int lastTagId = -1;
|
||||||
for (auto& fieldInstanceRef : typeInstance->mFieldInstances)
|
for (auto& fieldInstanceRef : typeInstance->mFieldInstances)
|
||||||
{
|
{
|
||||||
auto fieldInstance = &fieldInstanceRef;
|
auto fieldInstance = &fieldInstanceRef;
|
||||||
auto fieldDef = fieldInstance->GetFieldDef();
|
auto fieldDef = fieldInstance->GetFieldDef();
|
||||||
if ((fieldDef != NULL) && (fieldInstance->mDataIdx < 0))
|
if ((fieldDef != NULL) && (fieldInstance->mDataIdx < 0))
|
||||||
|
{
|
||||||
|
BF_ASSERT(fieldInstance->mResolvedType->mAlign >= 1);
|
||||||
|
typeInstance->mAlign = BF_MAX(typeInstance->mAlign, fieldInstance->mResolvedType->mAlign);
|
||||||
lastTagId = -fieldInstance->mDataIdx - 1;
|
lastTagId = -fieldInstance->mDataIdx - 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
auto fieldInstance = &typeInstance->mFieldInstances.back();
|
auto fieldInstance = &typeInstance->mFieldInstances.back();
|
||||||
BF_ASSERT(fieldInstance->mResolvedType == NULL);
|
BF_ASSERT(fieldInstance->mResolvedType == NULL);
|
||||||
|
@ -4638,7 +4644,7 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
typeInstance->mAlign = BF_MAX(unionInnerType->mAlign, discriminatorType->mAlign);
|
typeInstance->mAlign = BF_MAX(typeInstance->mAlign, discriminatorType->mAlign);
|
||||||
typeInstance->mSize = fieldInstance->mDataOffset + discriminatorType->mSize;
|
typeInstance->mSize = fieldInstance->mDataOffset + discriminatorType->mSize;
|
||||||
|
|
||||||
typeInstance->mInstSize = typeInstance->mSize;
|
typeInstance->mInstSize = typeInstance->mSize;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue