mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 12:32:20 +02:00
Fixed circular ref issue in 'using' field data population
This commit is contained in:
parent
32be2ba69c
commit
993053271b
2 changed files with 48 additions and 5 deletions
|
@ -3061,10 +3061,31 @@ void BfModule::PopulateUsingFieldData(BfTypeInstance* typeInstance)
|
|||
if (typeInstance->mTypeInfoEx == NULL)
|
||||
typeInstance->mTypeInfoEx = new BfTypeInfoEx();
|
||||
|
||||
BF_ASSERT(typeInstance->mTypeInfoEx->mUsingFieldData == NULL);
|
||||
BfUsingFieldData* usingFieldData;
|
||||
if (typeInstance->mTypeInfoEx->mUsingFieldData != NULL)
|
||||
{
|
||||
usingFieldData = typeInstance->mTypeInfoEx->mUsingFieldData;
|
||||
Array<BfTypeInstance*> populatedTypes;
|
||||
|
||||
BfUsingFieldData* usingFieldData = new BfUsingFieldData();
|
||||
typeInstance->mTypeInfoEx->mUsingFieldData = usingFieldData;
|
||||
for (auto checkType : usingFieldData->mAwaitingPopulateSet)
|
||||
{
|
||||
if (checkType->mDefineState >= BfTypeDefineState_Defined)
|
||||
populatedTypes.Add(checkType);
|
||||
}
|
||||
|
||||
if (populatedTypes.IsEmpty())
|
||||
return;
|
||||
|
||||
for (auto type : populatedTypes)
|
||||
usingFieldData->mAwaitingPopulateSet.Remove(type);
|
||||
usingFieldData->mEntries.Clear();
|
||||
usingFieldData->mMethods.Clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
usingFieldData = new BfUsingFieldData();
|
||||
typeInstance->mTypeInfoEx->mUsingFieldData = usingFieldData;
|
||||
}
|
||||
|
||||
HashSet<BfTypeInstance*> checkedTypeSet;
|
||||
Array<BfUsingFieldData::MemberRef> memberRefs;
|
||||
|
@ -3103,8 +3124,29 @@ void BfModule::PopulateUsingFieldData(BfTypeInstance* typeInstance)
|
|||
|
||||
if (usingType->mDefineState < BfTypeDefineState_Defined)
|
||||
{
|
||||
// We need to populate this type now
|
||||
PopulateType(usingType);
|
||||
bool isPopulatingType = false;
|
||||
|
||||
auto checkTypeState = mContext->mCurTypeState;
|
||||
while (checkTypeState != NULL)
|
||||
{
|
||||
if ((checkTypeState->mType == usingType) && (checkTypeState->mPopulateType >= BfPopulateType_Data))
|
||||
{
|
||||
isPopulatingType = true;
|
||||
break;
|
||||
}
|
||||
|
||||
checkTypeState = checkTypeState->mPrevState;
|
||||
}
|
||||
|
||||
if (isPopulatingType)
|
||||
{
|
||||
typeInstance->mTypeInfoEx->mUsingFieldData->mAwaitingPopulateSet.Add(usingType);
|
||||
}
|
||||
else
|
||||
{
|
||||
// We need to populate this type now
|
||||
PopulateType(usingType);
|
||||
}
|
||||
}
|
||||
|
||||
auto fieldInstance = &usingType->mFieldInstances[fieldDef->mIdx];
|
||||
|
|
|
@ -1884,6 +1884,7 @@ public:
|
|||
public:
|
||||
Dictionary<String, Entry> mEntries;
|
||||
Dictionary<String, Entry> mMethods;
|
||||
HashSet<BfTypeInstance*> mAwaitingPopulateSet;
|
||||
};
|
||||
|
||||
class BfTypeInfoEx
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue