| 2658 | } |
| 2659 | |
| 2660 | BfTypeDef* BfSystem::FindTypeDef(const BfAtomComposite& findName, int numGenericArgs, BfProject* project, const Array<BfAtomComposite>& namespaceSearch, BfTypeDef** ambiguousTypeDef, BfFindTypeDefFlags flags) |
| 2661 | { |
| 2662 | if (findName.GetPartsCount() == 1) |
| 2663 | { |
| 2664 | BfTypeDef** typeDefPtr = NULL; |
| 2665 | if (mSystemTypeDefs.TryGetValueWith(findName.mParts[0]->mString, &typeDefPtr)) |
| 2666 | return FilterDeletedTypeDef(*typeDefPtr); |
| 2667 | } |
| 2668 | |
| 2669 | // This searched globals, but we were already doing that down below at the LAST step. Right? |
| 2670 | BfTypeDef* foundTypeDef = NULL; |
| 2671 | BfAtomCompositeT<16> qualifiedFindName; |
| 2672 | |
| 2673 | bool allowGlobal = (flags & BfFindTypeDefFlag_AllowGlobal) != 0; |
| 2674 | |
| 2675 | int foundPri = (int)0x80000000; |
| 2676 | for (int namespaceIdx = 0; namespaceIdx <= (int) namespaceSearch.size(); namespaceIdx++) |
| 2677 | { |
| 2678 | int curNamespacePri = 0; |
| 2679 | if (namespaceIdx < (int)namespaceSearch.size()) |
| 2680 | { |
| 2681 | auto& namespaceDeclaration = namespaceSearch[namespaceIdx]; |
| 2682 | qualifiedFindName.Set(namespaceDeclaration, findName); |
| 2683 | } |
| 2684 | else |
| 2685 | { |
| 2686 | qualifiedFindName = findName; |
| 2687 | } |
| 2688 | |
| 2689 | int partialStartEntryIdx = -1; |
| 2690 | |
| 2691 | auto itr = mTypeDefs.TryGet(qualifiedFindName); |
| 2692 | while (itr) |
| 2693 | { |
| 2694 | BfTypeDef* typeDef = *itr; |
| 2695 | |
| 2696 | if ((typeDef->mIsPartial) || |
| 2697 | ((typeDef->IsGlobalsContainer()) && ((flags & BfFindTypeDefFlag_AllowGlobal) == 0))) |
| 2698 | { |
| 2699 | bool handled = false; |
| 2700 | if ((itr.mCurEntry < mTypeDefs.mPartialSkipCache.mSize) && (!allowGlobal)) |
| 2701 | { |
| 2702 | auto& entry = mTypeDefs.mPartialSkipCache[itr.mCurEntry]; |
| 2703 | if (entry.mRevision == mTypeDefs.mRevision) |
| 2704 | { |
| 2705 | if (entry.mIndex == -1) |
| 2706 | { |
| 2707 | // No non-partial here |
| 2708 | break; |
| 2709 | } |
| 2710 | |
| 2711 | itr.mCurEntry = entry.mIndex; |
| 2712 | typeDef = *itr; |
| 2713 | handled = true; |
| 2714 | } |
| 2715 | } |
| 2716 | |
| 2717 | if (!handled) |
no test coverage detected