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

Method GetMethodInstance

IDEHelper/Compiler/BfModule.cpp:14568–15481  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14566}
14567
14568BfModuleMethodInstance BfModule::GetMethodInstance(BfTypeInstance* typeInst, BfMethodDef* methodDef, const BfTypeVector& methodGenericArguments, BfGetMethodInstanceFlags flags, BfTypeInstance* foreignType, BfModule* referencingModule)
14569{
14570 if (methodDef->mMethodType == BfMethodType_Init)
14571 return BfModuleMethodInstance();
14572
14573 if (((flags & BfGetMethodInstanceFlag_ForceInline) != 0) && (mCompiler->mIsResolveOnly))
14574 {
14575 // Don't bother inlining for resolve-only
14576 flags = (BfGetMethodInstanceFlags)(flags & ~BfGetMethodInstanceFlag_ForceInline);
14577 }
14578
14579 if (methodDef->mIsExtern)
14580 flags = (BfGetMethodInstanceFlags)(flags & ~BfGetMethodInstanceFlag_ForceInline);
14581
14582 bool processNow = false;
14583 bool keepInCurrentModule = false;
14584
14585 if ((mCurMethodInstance != NULL) && (mCurMethodInstance->mIsUnspecialized))
14586 flags = (BfGetMethodInstanceFlags)(flags | BfGetMethodInstanceFlag_NoForceReification);
14587
14588 if (!typeInst->IsTypeMemberIncluded(methodDef->mDeclaringType))
14589 {
14590 return BfModuleMethodInstance();
14591 }
14592
14593 if (methodDef->mIsLocalMethod)
14594 {
14595 auto rootMethodState = mCurMethodState->GetRootMethodState();
14596 BfLocalMethod* localMethod;
14597 if (rootMethodState->mLocalMethodCache.TryGetValue(methodDef->mName, &localMethod))
14598 {
14599 // Handle the def in the correct method state
14600 return GetLocalMethodInstance(localMethod, methodGenericArguments);
14601 }
14602
14603 BFMODULE_FATAL(this, "Cannot find local method");
14604 return BfModuleMethodInstance();
14605 }
14606
14607#ifdef _DEBUG
14608 for (auto arg : methodGenericArguments)
14609 BF_ASSERT(!arg->IsVar());
14610#endif
14611
14612 BF_ASSERT(methodDef->mMethodType != BfMethodType_Ignore);
14613
14614 // We need to do the 'mNeedsMethodProcessing' check because we want to do a proper initial "awaiting reference" population
14615 // on the methods before we handle an on-demand situation. This also ensures that our type options are set before doing
14616 // a FinishInit
14617 if ((typeInst->IsIncomplete()) &&
14618 (!typeInst->mResolvingVarField) && (!typeInst->mTypeFailed))
14619 {
14620 // For autocomplete, we still may not actually generate methods. This shouldn't matter, and on-demand works differently
14621 // for resolve-only because we don't differentiate between reified/unreified there
14622 if ((methodDef->mIsStatic) /*&& (mIsComptimeModule)*/)
14623 {
14624 if (!typeInst->DefineStateAllowsStaticMethods())
14625 PopulateType(typeInst, BfPopulateType_AllowStaticMethods);

Callers 15

GetCustomAttributesMethod · 0.45
CallChainedMethodsMethod · 0.45
ProcessWorkListMethod · 0.45
PopulateReifiedMethod · 0.45
DoCompileMethod · 0.45
GetGeneratorStringMethod · 0.45
TryDevirtualizeCallMethod · 0.45
CreateCallMethod · 0.45
MatchMethodMethod · 0.45

Calls 15

TypeToStringFunction · 0.85
BfIRFunctionClass · 0.85
FailFunction · 0.85
GetRootMethodStateMethod · 0.80
TryGetValueMethod · 0.80
EnsureCeUnpausedMethod · 0.80
UndoDeclarationMethod · 0.80
GetMangleKindMethod · 0.80
IsAutocompleteMethod · 0.80

Tested by

no test coverage detected