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

Method ReferenceExternalMethodInstance

IDEHelper/Compiler/BfModule.cpp:14371–14456  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14369}
14370
14371BfModuleMethodInstance BfModule::ReferenceExternalMethodInstance(BfMethodInstance* methodInstance, BfGetMethodInstanceFlags flags)
14372{
14373 if ((flags & BfGetMethodInstanceFlag_ResultNotUsed) != 0)
14374 return BfModuleMethodInstance(methodInstance, BfIRValue());
14375
14376 if (mBfIRBuilder == NULL)
14377 return BfModuleMethodInstance(methodInstance, BfIRValue());
14378
14379 if (methodInstance->GetOwner()->IsFunction())
14380 {
14381 // No actual ref needed- not an actual generated function
14382 return BfModuleMethodInstance(methodInstance, BfIRValue());
14383 }
14384
14385 bool isGenFunction = methodInstance->mMethodInstanceGroup->mMethodIdx < 0;
14386 if (!isGenFunction)
14387 AddMethodReference(methodInstance, flags);
14388
14389 if ((mBfIRBuilder->mIgnoreWrites) || ((flags & BfGetMethodInstanceFlag_Unreified) != 0))
14390 return BfModuleMethodInstance(methodInstance, mBfIRBuilder->GetFakeVal());
14391
14392 if (IsSkippingExtraResolveChecks())
14393 return BfModuleMethodInstance(methodInstance, BfIRFunction());
14394
14395 if (methodInstance->mMethodDef->mMethodType == BfMethodType_Mixin)
14396 {
14397 return BfModuleMethodInstance(methodInstance, BfIRFunction());
14398 }
14399
14400 bool isInlined = (methodInstance->mAlwaysInline) || ((flags & BfGetMethodInstanceFlag_ForceInline) != 0);
14401 if ((methodInstance->mIsIntrinsic) || (methodInstance->mMethodDef->mIsExtern))
14402 isInlined = false;
14403
14404 BfMethodRef methodRef = methodInstance;
14405 if (isInlined)
14406 methodRef.mMethodRefFlags = (BfMethodRefFlags)(methodRef.mMethodRefFlags | BfMethodRefFlag_AlwaysInclude);
14407 else
14408 methodRef.mMethodRefFlags = BfMethodRefFlag_None;
14409
14410 if (!isGenFunction)
14411 {
14412 BfIRValue* irFuncPtr = NULL;
14413 if (mFuncReferences.TryGetValue(methodRef, &irFuncPtr))
14414 return BfModuleMethodInstance(methodInstance, *irFuncPtr);
14415 }
14416
14417 if (mAwaitingInitFinish)
14418 FinishInit();
14419
14420 BfIRValue func = CreateFunctionFrom(methodInstance, isGenFunction, isInlined);
14421
14422 if (!isGenFunction)
14423 {
14424 BF_ASSERT(func || methodInstance->mMethodInstanceGroup->mOwner->IsInterface());
14425 mFuncReferences[methodRef] = func;
14426 }
14427 BfLogSysM("Adding func reference. Module:%p MethodInst:%p NewLLVMFunc:%d OldLLVMFunc:%d\n", this, methodInstance, func.mId, methodInstance->mIRFunction.mId);
14428

Callers 4

EmitTestMethodMethod · 0.80
TryDevirtualizeCallMethod · 0.80
MatchMethodMethod · 0.80

Calls 10

BfIRValueClass · 0.85
BfIRFunctionClass · 0.85
GetFakeValMethod · 0.80
TryGetValueMethod · 0.80
IsFunctionMethod · 0.45
GetOwnerMethod · 0.45
IsInterfaceMethod · 0.45
sizeMethod · 0.45
AllocMethod · 0.45

Tested by

no test coverage detected