mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-09 20:12:21 +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
|
@ -6130,18 +6130,6 @@ void BfExprEvaluator::ResolveArgValues(BfResolvedArgs& resolvedArgs, BfResolveAr
|
||||||
handled = true;
|
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)
|
if (!handled)
|
||||||
{
|
{
|
||||||
BfAstNode* checkArgExpr = argExpr;
|
BfAstNode* checkArgExpr = argExpr;
|
||||||
|
|
|
@ -4858,8 +4858,7 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
|
||||||
if (typeInstance->IsInterface())
|
if (typeInstance->IsInterface())
|
||||||
Fail("Interfaces cannot include fields. Consider making this a property", field->GetRefNode());
|
Fail("Interfaces cannot include fields. Consider making this a property", field->GetRefNode());
|
||||||
}
|
}
|
||||||
|
|
||||||
int enumCaseEntryIdx = 0;
|
|
||||||
for (int pass = 0; pass < 2; pass++)
|
for (int pass = 0; pass < 2; pass++)
|
||||||
{
|
{
|
||||||
for (auto field : typeDef->mFields)
|
for (auto field : typeDef->mFields)
|
||||||
|
@ -4889,7 +4888,6 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
|
||||||
{
|
{
|
||||||
if (typeInstance->IsEnum())
|
if (typeInstance->IsEnum())
|
||||||
{
|
{
|
||||||
fieldInstance->mDataIdx = -(enumCaseEntryIdx++) - 1;
|
|
||||||
resolvedFieldType = typeInstance;
|
resolvedFieldType = typeInstance;
|
||||||
|
|
||||||
BfType* payloadType = NULL;
|
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())
|
if (!resolvedTypeRef->IsIncomplete())
|
||||||
{
|
{
|
||||||
// We finished resolving ourselves through a re-entry, so we're actually done here
|
// 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