MCPcopy Create free account
hub / github.com/beefytech/Beef / ResolveTypeResult_Validate

Method ResolveTypeResult_Validate

IDEHelper/Compiler/BfModuleTypeUtils.cpp:9819–9874  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9817}
9818
9819bool BfModule::ResolveTypeResult_Validate(BfAstNode* typeRef, BfType* resolvedTypeRef)
9820{
9821 if ((typeRef == NULL) || (resolvedTypeRef == NULL))
9822 return true;
9823
9824 BfTypeInstance* genericTypeInstance = resolvedTypeRef->ToGenericTypeInstance();
9825
9826 if ((genericTypeInstance != NULL) && (genericTypeInstance != mCurTypeInstance))
9827 {
9828 bool doValidate = (genericTypeInstance->mGenericTypeInfo->mHadValidateErrors) ||
9829 (!genericTypeInstance->mGenericTypeInfo->mValidatedGenericConstraints) ||
9830 (genericTypeInstance->mGenericTypeInfo->mIsUnspecializedVariation);
9831 if ((mCurMethodInstance != NULL) && (mCurMethodInstance->IsOrInUnspecializedVariation()))
9832 doValidate = false;
9833 if (mCurTypeInstance != NULL)
9834 {
9835 if (mCurTypeInstance->IsUnspecializedTypeVariation())
9836 doValidate = false;
9837 if (auto curGenericTypeInstance = mCurTypeInstance->ToGenericTypeInstance())
9838 {
9839 if ((curGenericTypeInstance->mDependencyMap.mMinDependDepth > 32) &&
9840 (genericTypeInstance->mDependencyMap.mMinDependDepth > 32))
9841 {
9842 Fail(StrFormat("Generic type dependency depth exceeded for type '%s'", TypeToString(genericTypeInstance).c_str()), typeRef);
9843 return false;
9844 }
9845
9846 if (curGenericTypeInstance->mGenericTypeInfo->mHadValidateErrors)
9847 doValidate = false;
9848 }
9849 if ((mContext->mCurTypeState != NULL) && (mContext->mCurTypeState->mCurBaseTypeRef != NULL) && (!mContext->mCurTypeState->mType->IsTypeAlias())) // We validate constraints for base types later
9850 doValidate = false;
9851 }
9852
9853 if (doValidate)
9854 ValidateGenericConstraints(typeRef, genericTypeInstance, false);
9855 }
9856
9857 if (auto genericInstanceTypeRef = BfNodeDynCastExact<BfGenericInstanceTypeRef>(typeRef))
9858 {
9859 if (genericTypeInstance != NULL)
9860 {
9861 auto genericTypeInfo = genericTypeInstance->GetGenericTypeInfo();
9862 for (int argIdx = 0; argIdx < (int)genericInstanceTypeRef->mGenericArguments.size(); argIdx++)
9863 {
9864 ResolveTypeResult_Validate(genericInstanceTypeRef->mGenericArguments[argIdx], genericTypeInfo->mTypeGenericArguments[argIdx]);
9865 }
9866 }
9867 }
9868 else if (auto elementedTypeRef = BfNodeDynCast<BfElementedTypeRef>(typeRef))
9869 {
9870 return ResolveTypeResult_Validate(elementedTypeRef, resolvedTypeRef->GetUnderlyingType());
9871 }
9872
9873 return true;
9874}
9875
9876BfType* BfModule::SafeResolveAliasType(BfTypeAliasType* aliasType)

Callers

nothing calls this directly

Calls 10

FailFunction · 0.85
TypeToStringFunction · 0.85
GetGenericTypeInfoMethod · 0.80
ToGenericTypeInstanceMethod · 0.45
c_strMethod · 0.45
IsTypeAliasMethod · 0.45
sizeMethod · 0.45
GetUnderlyingTypeMethod · 0.45

Tested by

no test coverage detected