mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 04:22: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
|
@ -3060,12 +3060,33 @@ void BfModule::PopulateUsingFieldData(BfTypeInstance* typeInstance)
|
||||||
{
|
{
|
||||||
if (typeInstance->mTypeInfoEx == NULL)
|
if (typeInstance->mTypeInfoEx == NULL)
|
||||||
typeInstance->mTypeInfoEx = new BfTypeInfoEx();
|
typeInstance->mTypeInfoEx = new BfTypeInfoEx();
|
||||||
|
|
||||||
|
BfUsingFieldData* usingFieldData;
|
||||||
|
if (typeInstance->mTypeInfoEx->mUsingFieldData != NULL)
|
||||||
|
{
|
||||||
|
usingFieldData = typeInstance->mTypeInfoEx->mUsingFieldData;
|
||||||
|
Array<BfTypeInstance*> populatedTypes;
|
||||||
|
|
||||||
BF_ASSERT(typeInstance->mTypeInfoEx->mUsingFieldData == NULL);
|
for (auto checkType : usingFieldData->mAwaitingPopulateSet)
|
||||||
|
{
|
||||||
|
if (checkType->mDefineState >= BfTypeDefineState_Defined)
|
||||||
|
populatedTypes.Add(checkType);
|
||||||
|
}
|
||||||
|
|
||||||
BfUsingFieldData* usingFieldData = new BfUsingFieldData();
|
if (populatedTypes.IsEmpty())
|
||||||
typeInstance->mTypeInfoEx->mUsingFieldData = usingFieldData;
|
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;
|
HashSet<BfTypeInstance*> checkedTypeSet;
|
||||||
Array<BfUsingFieldData::MemberRef> memberRefs;
|
Array<BfUsingFieldData::MemberRef> memberRefs;
|
||||||
std::function<void(BfTypeInstance*, bool)> _CheckType = [&](BfTypeInstance* usingType, bool staticOnly)
|
std::function<void(BfTypeInstance*, bool)> _CheckType = [&](BfTypeInstance* usingType, bool staticOnly)
|
||||||
|
@ -3103,8 +3124,29 @@ void BfModule::PopulateUsingFieldData(BfTypeInstance* typeInstance)
|
||||||
|
|
||||||
if (usingType->mDefineState < BfTypeDefineState_Defined)
|
if (usingType->mDefineState < BfTypeDefineState_Defined)
|
||||||
{
|
{
|
||||||
// We need to populate this type now
|
bool isPopulatingType = false;
|
||||||
PopulateType(usingType);
|
|
||||||
|
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];
|
auto fieldInstance = &usingType->mFieldInstances[fieldDef->mIdx];
|
||||||
|
|
|
@ -1884,6 +1884,7 @@ public:
|
||||||
public:
|
public:
|
||||||
Dictionary<String, Entry> mEntries;
|
Dictionary<String, Entry> mEntries;
|
||||||
Dictionary<String, Entry> mMethods;
|
Dictionary<String, Entry> mMethods;
|
||||||
|
HashSet<BfTypeInstance*> mAwaitingPopulateSet;
|
||||||
};
|
};
|
||||||
|
|
||||||
class BfTypeInfoEx
|
class BfTypeInfoEx
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue