| 3992 | } |
| 3993 | |
| 3994 | void BfModule::PopulateGlobalContainersList(const BfGlobalLookup& globalLookup) |
| 3995 | { |
| 3996 | if (mContext->mCurTypeState == NULL) |
| 3997 | return; |
| 3998 | |
| 3999 | BP_ZONE("PopulateGlobalContainersList"); |
| 4000 | |
| 4001 | BfTypeDef* userTypeDef = GetActiveTypeDef(); |
| 4002 | |
| 4003 | if (mContext->mCurTypeState->mGlobalContainerCurUserTypeDef != userTypeDef) |
| 4004 | { |
| 4005 | mContext->mCurTypeState->mGlobalContainers.Clear(); |
| 4006 | for (int namespaceIdx = -1; namespaceIdx < (int)userTypeDef->mNamespaceSearch.size(); namespaceIdx++) |
| 4007 | { |
| 4008 | BfAtomComposite findStr; |
| 4009 | if (namespaceIdx != -1) |
| 4010 | findStr.Reference(userTypeDef->mNamespaceSearch[namespaceIdx]); |
| 4011 | auto typeDefItr = mSystem->mTypeDefs.TryGet(findStr); |
| 4012 | while (typeDefItr) |
| 4013 | { |
| 4014 | auto typeDef = *typeDefItr; |
| 4015 | if ((typeDef->mFullName == findStr) && (typeDef->mIsCombinedPartial) && (typeDef->IsGlobalsContainer())) |
| 4016 | { |
| 4017 | if (typeDef->mProject->ContainsReference(typeDef->mProject)) |
| 4018 | { |
| 4019 | BfGlobalContainerEntry globalEntry; |
| 4020 | globalEntry.mTypeDef = typeDef; |
| 4021 | globalEntry.mTypeInst = NULL; |
| 4022 | typeDef->PopulateMemberSets(); |
| 4023 | mContext->mCurTypeState->mGlobalContainers.Add(globalEntry); |
| 4024 | } |
| 4025 | } |
| 4026 | else if (!typeDef->mIsPartial) |
| 4027 | { |
| 4028 | //break; |
| 4029 | } |
| 4030 | |
| 4031 | typeDefItr.MoveToNextHashMatch(); |
| 4032 | } |
| 4033 | } |
| 4034 | |
| 4035 | mContext->mCurTypeState->mGlobalContainerCurUserTypeDef = userTypeDef; |
| 4036 | } |
| 4037 | |
| 4038 | // Only create actual typeInst when we have an applicable member. This helps in keeping unused globals from |
| 4039 | // reifing types |
| 4040 | for (auto& globalEntry : mContext->mCurTypeState->mGlobalContainers) |
| 4041 | { |
| 4042 | if (globalEntry.mTypeInst == NULL) |
| 4043 | { |
| 4044 | bool include = false; |
| 4045 | if (globalLookup.mKind == BfGlobalLookup::Kind_All) |
| 4046 | include = true; |
| 4047 | else if (globalLookup.mKind == BfGlobalLookup::Kind_Field) |
| 4048 | { |
| 4049 | if (globalEntry.mTypeDef->mFieldSet.ContainsWith(globalLookup.mName)) |
| 4050 | include = true; |
| 4051 | if (globalEntry.mTypeDef->mPropertySet.ContainsWith(globalLookup.mName)) |
no test coverage detected