This method clears out unused generic types AFTER compilation of reified types has occurred
| 2351 | |
| 2352 | // This method clears out unused generic types AFTER compilation of reified types has occurred |
| 2353 | void BfCompiler::UpdateDependencyMap(bool deleteUnusued, bool& didWork) |
| 2354 | { |
| 2355 | BP_ZONE("BfCompiler::UpdateDependencyMap"); |
| 2356 | BfLogSysM("Compiler::UpdateDependencyMap %d\n", deleteUnusued); |
| 2357 | |
| 2358 | bool madeFullPass = true; |
| 2359 | if (mCanceling) |
| 2360 | madeFullPass = false; |
| 2361 | if ((mResolvePassData != NULL) && (!mResolvePassData->mParsers.IsEmpty())) |
| 2362 | madeFullPass = false; |
| 2363 | |
| 2364 | SetAndRestoreValue<bool> prevAssertOnPopulateType(mContext->mAssertOnPopulateType, deleteUnusued && madeFullPass); |
| 2365 | |
| 2366 | if ((deleteUnusued) && (madeFullPass)) |
| 2367 | { |
| 2368 | // Work queues should be empty if we're not canceling |
| 2369 | BF_ASSERT(mContext->mPopulateTypeWorkList.size() == 0); |
| 2370 | BF_ASSERT(mContext->mMethodWorkList.size() == 0); |
| 2371 | } |
| 2372 | |
| 2373 | // Remove old data in dependency maps, and find types which don't have any references (direct or indirect) |
| 2374 | // to a non-generic type and remove them |
| 2375 | for (int pass = 0; true; pass++) |
| 2376 | { |
| 2377 | // This assert can fail if we have a dependency error, where deleting a type causes a dependent type |
| 2378 | // to be rebuilt |
| 2379 | BF_ASSERT(pass < 100); |
| 2380 | |
| 2381 | bool foundNew = false; |
| 2382 | |
| 2383 | for (auto type : mContext->mResolvedTypes) |
| 2384 | { |
| 2385 | if (type != NULL) |
| 2386 | { |
| 2387 | auto depType = type->ToDependedType(); |
| 2388 | auto typeInst = type->ToTypeInstance(); |
| 2389 | |
| 2390 | if (depType != NULL) |
| 2391 | { |
| 2392 | extern BfModule* gLastCreatedModule; |
| 2393 | |
| 2394 | #ifdef _DEBUG |
| 2395 | for (auto itr = depType->mDependencyMap.begin(); itr != depType->mDependencyMap.end(); ++itr) |
| 2396 | { |
| 2397 | auto dependentType = itr->mKey; |
| 2398 | if (dependentType->IsIncomplete()) |
| 2399 | { |
| 2400 | BF_ASSERT(dependentType->IsDeleting() || dependentType->IsOnDemand() || !dependentType->HasBeenReferenced() || mCanceling || !madeFullPass || dependentType->IsSpecializedByAutoCompleteMethod()); |
| 2401 | } |
| 2402 | } |
| 2403 | #endif |
| 2404 | |
| 2405 | depType->mDependencyMap.mFlagsUnion = BfDependencyMap::DependencyFlag_None; |
| 2406 | |
| 2407 | // Not combined with previous loop because PopulateType could modify typeInst->mDependencyMap |
| 2408 | for (auto itr = depType->mDependencyMap.begin(); itr != depType->mDependencyMap.end();) |
| 2409 | { |
| 2410 | auto dependentType = itr->mKey; |
nothing calls this directly
no test coverage detected