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

Fixed reentrancy issue while assigning enum case indices

This commit is contained in:
Brian Fiete 2024-06-30 08:21:27 +02:00
parent 3ff7fd86af
commit d1ce5f0415
2 changed files with 18 additions and 15 deletions

View file

@ -6130,18 +6130,6 @@ void BfExprEvaluator::ResolveArgValues(BfResolvedArgs& resolvedArgs, BfResolveAr
handled = true;
}
/*else if (auto castExpr = BfNodeDynCast<BfCastExpression>(argExpr))
{
if (auto namedTypeRef = BfNodeDynCastExact<BfNamedTypeReference>(castExpr->mTypeRef))
{
if (namedTypeRef->ToString() == "ExpectedType")
{
resolvedArg.mArgFlags = (BfArgFlags)(resolvedArg.mArgFlags | BfArgFlag_ExpectedTypeCast);
handled = true;
}
}
}*/
if (!handled)
{
BfAstNode* checkArgExpr = argExpr;

View file

@ -4859,7 +4859,6 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
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