mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 12:32:20 +02:00
Fixed method slotting when method is already in work list
This commit is contained in:
parent
37c4074c44
commit
7e03ce86bc
1 changed files with 76 additions and 64 deletions
|
@ -5636,100 +5636,112 @@ void BfModule::DoTypeInstanceMethodProcessing(BfTypeInstance* typeInstance)
|
||||||
if ((pass == 1) != (methodDef->mIsOverride))
|
if ((pass == 1) != (methodDef->mIsOverride))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
bool doGetMethodInstance = true;
|
||||||
|
|
||||||
auto methodInstanceGroup = &typeInstance->mMethodInstanceGroups[methodDef->mIdx];
|
auto methodInstanceGroup = &typeInstance->mMethodInstanceGroups[methodDef->mIdx];
|
||||||
|
|
||||||
if ((methodInstanceGroup->mOnDemandKind != BfMethodOnDemandKind_AlwaysInclude) &&
|
if ((methodInstanceGroup->mOnDemandKind != BfMethodOnDemandKind_AlwaysInclude) &&
|
||||||
(methodInstanceGroup->mOnDemandKind != BfMethodOnDemandKind_Decl_AwaitingDecl))
|
(methodInstanceGroup->mOnDemandKind != BfMethodOnDemandKind_Decl_AwaitingDecl))
|
||||||
{
|
{
|
||||||
BfLogSysM("Skipping GetMethodInstance on MethodDef: %p OnDemandKind: %d\n", methodDef, methodInstanceGroup->mOnDemandKind);
|
BfLogSysM("Skipping GetMethodInstance on MethodDef: %p OnDemandKind: %d\n", methodDef, methodInstanceGroup->mOnDemandKind);
|
||||||
continue;
|
doGetMethodInstance = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (methodDef->mMethodType == BfMethodType_Init)
|
if (methodDef->mMethodType == BfMethodType_Init)
|
||||||
continue;
|
doGetMethodInstance = false;
|
||||||
|
|
||||||
int prevWorklistSize = (int)mContext->mMethodWorkList.size();
|
BfMethodInstance* methodInstance = NULL;
|
||||||
|
|
||||||
auto flags = ((methodDef->mGenericParams.size() != 0) || (typeInstance->IsUnspecializedType())) ? BfGetMethodInstanceFlag_UnspecializedPass : BfGetMethodInstanceFlag_None;
|
if (doGetMethodInstance)
|
||||||
|
|
||||||
if (methodInstanceGroup->mOnDemandKind != BfMethodOnDemandKind_AlwaysInclude)
|
|
||||||
flags = (BfGetMethodInstanceFlags)(flags | BfGetMethodInstanceFlag_MethodInstanceOnly);
|
|
||||||
|
|
||||||
auto moduleMethodInstance = GetMethodInstance(typeInstance, methodDef, BfTypeVector(), flags);
|
|
||||||
|
|
||||||
auto methodInstance = moduleMethodInstance.mMethodInstance;
|
|
||||||
if (methodInstance == NULL)
|
|
||||||
{
|
{
|
||||||
BF_ASSERT(typeInstance->IsGenericTypeInstance() && (typeInstance->mTypeDef->mIsCombinedPartial));
|
int prevWorklistSize = (int)mContext->mMethodWorkList.size();
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((!mCompiler->mIsResolveOnly) &&
|
auto flags = ((methodDef->mGenericParams.size() != 0) || (typeInstance->IsUnspecializedType())) ? BfGetMethodInstanceFlag_UnspecializedPass : BfGetMethodInstanceFlag_None;
|
||||||
((methodInstanceGroup->mOnDemandKind == BfMethodOnDemandKind_Decl_AwaitingReference) || (!typeInstance->IsReified())))
|
|
||||||
{
|
|
||||||
bool forceMethodImpl = false;
|
|
||||||
|
|
||||||
BfCustomAttributes* customAttributes = methodInstance->GetCustomAttributes();
|
if (methodInstanceGroup->mOnDemandKind != BfMethodOnDemandKind_AlwaysInclude)
|
||||||
if ((customAttributes != NULL) && (typeInstance->IsReified()))
|
flags = (BfGetMethodInstanceFlags)(flags | BfGetMethodInstanceFlag_MethodInstanceOnly);
|
||||||
|
|
||||||
|
auto moduleMethodInstance = GetMethodInstance(typeInstance, methodDef, BfTypeVector(), flags);
|
||||||
|
|
||||||
|
methodInstance = moduleMethodInstance.mMethodInstance;
|
||||||
|
if (methodInstance == NULL)
|
||||||
{
|
{
|
||||||
for (auto& attr : customAttributes->mAttributes)
|
BF_ASSERT(typeInstance->IsGenericTypeInstance() && (typeInstance->mTypeDef->mIsCombinedPartial));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((!mCompiler->mIsResolveOnly) &&
|
||||||
|
((methodInstanceGroup->mOnDemandKind == BfMethodOnDemandKind_Decl_AwaitingReference) || (!typeInstance->IsReified())))
|
||||||
|
{
|
||||||
|
bool forceMethodImpl = false;
|
||||||
|
|
||||||
|
BfCustomAttributes* customAttributes = methodInstance->GetCustomAttributes();
|
||||||
|
if ((customAttributes != NULL) && (typeInstance->IsReified()))
|
||||||
{
|
{
|
||||||
auto attrTypeInst = attr.mType->ToTypeInstance();
|
for (auto& attr : customAttributes->mAttributes)
|
||||||
auto attrCustomAttributes = attrTypeInst->mCustomAttributes;
|
|
||||||
if (attrCustomAttributes == NULL)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
for (auto& attrAttr : attrCustomAttributes->mAttributes)
|
|
||||||
{
|
{
|
||||||
if (attrAttr.mType->ToTypeInstance()->IsInstanceOf(mCompiler->mAttributeUsageAttributeTypeDef))
|
auto attrTypeInst = attr.mType->ToTypeInstance();
|
||||||
|
auto attrCustomAttributes = attrTypeInst->mCustomAttributes;
|
||||||
|
if (attrCustomAttributes == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
for (auto& attrAttr : attrCustomAttributes->mAttributes)
|
||||||
{
|
{
|
||||||
// Check for Flags arg
|
if (attrAttr.mType->ToTypeInstance()->IsInstanceOf(mCompiler->mAttributeUsageAttributeTypeDef))
|
||||||
if (attrAttr.mCtorArgs.size() < 2)
|
|
||||||
continue;
|
|
||||||
auto constant = attrTypeInst->mConstHolder->GetConstant(attrAttr.mCtorArgs[1]);
|
|
||||||
if (constant == NULL)
|
|
||||||
continue;
|
|
||||||
if (constant->mTypeCode == BfTypeCode_Boolean)
|
|
||||||
continue;
|
|
||||||
if ((constant->mInt8 & BfCustomAttributeFlags_AlwaysIncludeTarget) != 0)
|
|
||||||
forceMethodImpl = true;
|
|
||||||
|
|
||||||
if (attrTypeInst->mAttributeData == NULL)
|
|
||||||
PopulateType(attrTypeInst);
|
|
||||||
BF_ASSERT(attrTypeInst->mAttributeData != NULL);
|
|
||||||
if (attrTypeInst->mAttributeData != NULL)
|
|
||||||
{
|
{
|
||||||
if ((attrTypeInst->mAttributeData->mAlwaysIncludeUser & BfAlwaysIncludeFlag_IncludeAllMethods) != 0)
|
// Check for Flags arg
|
||||||
|
if (attrAttr.mCtorArgs.size() < 2)
|
||||||
|
continue;
|
||||||
|
auto constant = attrTypeInst->mConstHolder->GetConstant(attrAttr.mCtorArgs[1]);
|
||||||
|
if (constant == NULL)
|
||||||
|
continue;
|
||||||
|
if (constant->mTypeCode == BfTypeCode_Boolean)
|
||||||
|
continue;
|
||||||
|
if ((constant->mInt8 & BfCustomAttributeFlags_AlwaysIncludeTarget) != 0)
|
||||||
forceMethodImpl = true;
|
forceMethodImpl = true;
|
||||||
|
|
||||||
// "AssumeInstantiated" also forces default ctor
|
if (attrTypeInst->mAttributeData == NULL)
|
||||||
if (((attrTypeInst->mAttributeData->mAlwaysIncludeUser & BfAlwaysIncludeFlag_AssumeInstantiated) != 0) &&
|
PopulateType(attrTypeInst);
|
||||||
(methodDef->mMethodType == BfMethodType_Ctor) && (methodDef->mParams.IsEmpty()))
|
BF_ASSERT(attrTypeInst->mAttributeData != NULL);
|
||||||
forceMethodImpl = true;
|
if (attrTypeInst->mAttributeData != NULL)
|
||||||
|
{
|
||||||
|
if ((attrTypeInst->mAttributeData->mAlwaysIncludeUser & BfAlwaysIncludeFlag_IncludeAllMethods) != 0)
|
||||||
|
forceMethodImpl = true;
|
||||||
|
|
||||||
|
// "AssumeInstantiated" also forces default ctor
|
||||||
|
if (((attrTypeInst->mAttributeData->mAlwaysIncludeUser & BfAlwaysIncludeFlag_AssumeInstantiated) != 0) &&
|
||||||
|
(methodDef->mMethodType == BfMethodType_Ctor) && (methodDef->mParams.IsEmpty()))
|
||||||
|
forceMethodImpl = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (methodInstance->mMethodDef->mDeclaringType->mProject->mTargetType == BfTargetType_BeefTest)
|
if (methodInstance->mMethodDef->mDeclaringType->mProject->mTargetType == BfTargetType_BeefTest)
|
||||||
{
|
|
||||||
if ((customAttributes != NULL) && (customAttributes->Contains(mCompiler->mTestAttributeTypeDef)))
|
|
||||||
{
|
{
|
||||||
forceMethodImpl = true;
|
if ((customAttributes != NULL) && (customAttributes->Contains(mCompiler->mTestAttributeTypeDef)))
|
||||||
|
{
|
||||||
|
forceMethodImpl = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (forceMethodImpl)
|
||||||
|
{
|
||||||
|
if (!typeInstance->IsReified())
|
||||||
|
mContext->mScratchModule->PopulateType(typeInstance, BfPopulateType_Data);
|
||||||
|
// Reify method
|
||||||
|
mContext->mScratchModule->GetMethodInstance(typeInstance, methodDef, BfTypeVector());
|
||||||
|
BF_ASSERT(methodInstanceGroup->mOnDemandKind != BfMethodOnDemandKind_Decl_AwaitingReference);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (forceMethodImpl)
|
|
||||||
{
|
|
||||||
if (!typeInstance->IsReified())
|
|
||||||
mContext->mScratchModule->PopulateType(typeInstance, BfPopulateType_Data);
|
|
||||||
// Reify method
|
|
||||||
mContext->mScratchModule->GetMethodInstance(typeInstance, methodDef, BfTypeVector());
|
|
||||||
BF_ASSERT(methodInstanceGroup->mOnDemandKind != BfMethodOnDemandKind_Decl_AwaitingReference);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
methodInstance = methodInstanceGroup->mDefault;
|
||||||
|
if (methodInstance == NULL)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
bool methodUsedVirtually = false;
|
bool methodUsedVirtually = false;
|
||||||
if (typeInstance->IsInterface())
|
if (typeInstance->IsInterface())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue