mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-09 03:52:19 +02:00
Fixed reentrancy issue while assigning enum case indices
This commit is contained in:
parent
3ff7fd86af
commit
d1ce5f0415
2 changed files with 18 additions and 15 deletions
|
@ -4858,8 +4858,7 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
|
|||
if (typeInstance->IsInterface())
|
||||
Fail("Interfaces cannot include fields. Consider making this a property", field->GetRefNode());
|
||||
}
|
||||
|
||||
int enumCaseEntryIdx = 0;
|
||||
|
||||
for (int pass = 0; pass < 2; pass++)
|
||||
{
|
||||
for (auto field : typeDef->mFields)
|
||||
|
@ -4889,7 +4888,6 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
|
|||
{
|
||||
if (typeInstance->IsEnum())
|
||||
{
|
||||
fieldInstance->mDataIdx = -(enumCaseEntryIdx++) - 1;
|
||||
resolvedFieldType = typeInstance;
|
||||
|
||||
BfType* payloadType = NULL;
|
||||
|
@ -4983,6 +4981,23 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
|
|||
}
|
||||
}
|
||||
|
||||
// Assign enum indices
|
||||
int enumCaseEntryIdx = 0;
|
||||
for (auto field : typeDef->mFields)
|
||||
{
|
||||
auto fieldInstance = &typeInstance->mFieldInstances[field->mIdx];
|
||||
if (!fieldInstance->mFieldIncluded)
|
||||
continue;
|
||||
|
||||
if (field->IsEnumCaseEntry())
|
||||
{
|
||||
if (typeInstance->IsEnum())
|
||||
{
|
||||
fieldInstance->mDataIdx = -(enumCaseEntryIdx++) - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!resolvedTypeRef->IsIncomplete())
|
||||
{
|
||||
// We finished resolving ourselves through a re-entry, so we're actually done here
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue