| 2767 | } |
| 2768 | |
| 2769 | void BfContext::VerifyTypeLookups(BfTypeInstance* typeInst) |
| 2770 | { |
| 2771 | for (auto& lookupEntryPair : typeInst->mLookupResults) |
| 2772 | { |
| 2773 | BfTypeLookupEntry& lookupEntry = lookupEntryPair.mKey; |
| 2774 | bool isDirty = false; |
| 2775 | if (lookupEntry.mName.IsEmpty()) |
| 2776 | { |
| 2777 | // If the name lookup failed before, thats because we didn't have the right atoms. Are there new atoms now? |
| 2778 | if (lookupEntry.mAtomUpdateIdx != mSystem->mAtomUpdateIdx) |
| 2779 | isDirty = true; |
| 2780 | } |
| 2781 | else |
| 2782 | { |
| 2783 | // If any atoms have been placed in the graveyard, typesHash will be zero and thus cause a rebuild |
| 2784 | uint32 atomUpdateIdx = lookupEntry.mName.GetAtomUpdateIdx(); |
| 2785 | |
| 2786 | if (atomUpdateIdx == 0) |
| 2787 | { |
| 2788 | isDirty = true; |
| 2789 | } |
| 2790 | else |
| 2791 | { |
| 2792 | // Sanity check, mostly checking that useTypeDef wasn't deleted |
| 2793 | BF_ASSERT((lookupEntry.mUseTypeDef->mName->mAtomUpdateIdx >= 1) && (lookupEntry.mUseTypeDef->mName->mAtomUpdateIdx <= mSystem->mAtomUpdateIdx)); |
| 2794 | |
| 2795 | // Only do the actual lookup if types were added or removed whose name is contained in one of the name parts referenced |
| 2796 | if (atomUpdateIdx != lookupEntry.mAtomUpdateIdx) |
| 2797 | { |
| 2798 | // NOTE: we purposely don't use mNextRevision here. If the the was NOT rebuilt then that means we didn't actually rebuild |
| 2799 | // so the mNextRevision will be ignored |
| 2800 | auto useTypeDef = lookupEntry.mUseTypeDef; |
| 2801 | BfTypeDef* ambiguousTypeDef = NULL; |
| 2802 | BfTypeLookupResult* lookupResult = &lookupEntryPair.mValue; |
| 2803 | |
| 2804 | BfTypeLookupResultCtx lookupResultCtx; |
| 2805 | lookupResultCtx.mResult = lookupResult; |
| 2806 | lookupResultCtx.mIsVerify = true; |
| 2807 | |
| 2808 | BfTypeDef* result = typeInst->mModule->FindTypeDefRaw(lookupEntry.mName, lookupEntry.mNumGenericParams, typeInst, useTypeDef, NULL, &lookupResultCtx); |
| 2809 | if ((result == NULL) && (lookupResult->mFoundInnerType)) |
| 2810 | { |
| 2811 | // Allow this- if there were new types added then the types would be rebuilt already |
| 2812 | } |
| 2813 | else if (result != lookupResult->mTypeDef) |
| 2814 | { |
| 2815 | isDirty = true; |
| 2816 | } |
| 2817 | else |
| 2818 | lookupEntry.mAtomUpdateIdx = atomUpdateIdx; |
| 2819 | } |
| 2820 | } |
| 2821 | } |
| 2822 | |
| 2823 | if (isDirty) |
| 2824 | { |
| 2825 | // Clear lookup results to avoid infinite recursion |
| 2826 | typeInst->mLookupResults.Clear(); |
no test coverage detected