| 2595 | } |
| 2596 | |
| 2597 | BfProjectSet* BfModule::GetVisibleProjectSet() |
| 2598 | { |
| 2599 | if (mCurMethodState == NULL) |
| 2600 | return NULL; |
| 2601 | |
| 2602 | if (mCurMethodState->mVisibleProjectSet.IsEmpty()) |
| 2603 | { |
| 2604 | HashSet<BfType*> seenTypes; |
| 2605 | |
| 2606 | std::function<void(BfProject* project)> _AddProject = [&](BfProject* project) |
| 2607 | { |
| 2608 | if (mCurMethodState->mVisibleProjectSet.Add(project)) |
| 2609 | { |
| 2610 | for (auto dep : project->mDependencies) |
| 2611 | _AddProject(dep); |
| 2612 | } |
| 2613 | }; |
| 2614 | |
| 2615 | std::function<void(BfType* type)> _AddType = [&](BfType* type) |
| 2616 | { |
| 2617 | auto typeInstance = type->ToTypeInstance(); |
| 2618 | if (typeInstance == NULL) |
| 2619 | { |
| 2620 | if (type->IsSizedArray()) |
| 2621 | _AddType(type->GetUnderlyingType()); |
| 2622 | return; |
| 2623 | } |
| 2624 | if (typeInstance->IsTuple()) |
| 2625 | { |
| 2626 | for (auto& fieldInst : typeInstance->mFieldInstances) |
| 2627 | { |
| 2628 | if (fieldInst.mDataIdx != -1) |
| 2629 | _AddType(fieldInst.mResolvedType); |
| 2630 | } |
| 2631 | } |
| 2632 | _AddProject(typeInstance->mTypeDef->mProject); |
| 2633 | if (typeInstance->mGenericTypeInfo == NULL) |
| 2634 | return; |
| 2635 | for (auto type : typeInstance->mGenericTypeInfo->mTypeGenericArguments) |
| 2636 | { |
| 2637 | if (seenTypes.Add(type)) |
| 2638 | _AddType(type); |
| 2639 | } |
| 2640 | }; |
| 2641 | |
| 2642 | if (mCurTypeInstance != NULL) |
| 2643 | { |
| 2644 | _AddType(mCurTypeInstance); |
| 2645 | if ((mContext->mCurTypeState != NULL) && (mContext->mCurTypeState->mType == mCurTypeInstance)) |
| 2646 | { |
| 2647 | if (mContext->mCurTypeState->mCurTypeDef != NULL) |
| 2648 | _AddProject(mContext->mCurTypeState->mCurTypeDef->mProject); |
| 2649 | } |
| 2650 | } |
| 2651 | |
| 2652 | auto methodState = mCurMethodState; |
| 2653 | while (methodState != NULL) |
| 2654 | { |
no test coverage detected