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

Method GetFunction

IDEHelper/Compiler/CeMachine.cpp:10473–10559  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10471}
10472
10473CeFunction* CeMachine::GetFunction(BfMethodInstance* methodInstance, BfIRValue func, bool& added)
10474{
10475 if (func)
10476 {
10477 if ((func.IsConst()) || (func.IsFake()))
10478 return NULL;
10479
10480 auto funcVal = mCeModule->mBfIRBuilder->mBeIRCodeGen->TryGetBeValue(func.mId);
10481 if (funcVal == NULL)
10482 return NULL;
10483 }
10484
10485 CeFunctionInfo** functionInfoPtr = NULL;
10486 CeFunctionInfo* ceFunctionInfo = NULL;
10487 CeFunction* ceFunction = NULL;
10488 if (!mFunctions.TryAdd(methodInstance, NULL, &functionInfoPtr))
10489 {
10490 ceFunctionInfo = *functionInfoPtr;
10491 BF_ASSERT(ceFunctionInfo->mCeFunction != NULL);
10492 return ceFunctionInfo->mCeFunction;
10493 }
10494
10495 BF_ASSERT(!methodInstance->mInCEMachine);
10496 methodInstance->mInCEMachine = true;
10497
10498 BfLogSys(mCeModule->mSystem, "CeMachine::GetFunction %p\n", methodInstance);
10499
10500 if (!func)
10501 {
10502 ceFunctionInfo = new CeFunctionInfo();
10503 }
10504 else
10505 {
10506 auto funcVal = mCeModule->mBfIRBuilder->mBeIRCodeGen->GetBeValue(func.mId);
10507 if (auto function = BeValueDynCast<BeFunction>(funcVal))
10508 {
10509 String funcName = function->mName;
10510 if (funcName.EndsWith("__INLINE"))
10511 funcName.RemoveFromEnd(8);
10512
10513 CeFunctionInfo** namedFunctionInfoPtr = NULL;
10514 if (mNamedFunctionMap.TryAdd(funcName, NULL, &namedFunctionInfoPtr))
10515 {
10516 ceFunctionInfo = new CeFunctionInfo();
10517 ceFunctionInfo->mName = funcName;
10518 *namedFunctionInfoPtr = ceFunctionInfo;
10519 }
10520 else
10521 {
10522 ceFunctionInfo = *namedFunctionInfoPtr;
10523 if ((ceFunctionInfo->mMethodInstance != NULL) && (ceFunctionInfo->mMethodInstance != methodInstance))
10524 {
10525 // This ceFunctionInfo is already taken - probably from a name mangling conflict
10526 ceFunctionInfo = new CeFunctionInfo();
10527 }
10528 }
10529 }
10530 else

Callers 5

GetBuiltInFuncMethod · 0.45
CreateFunctionFromMethod · 0.45
SetupIRFunctionMethod · 0.45
CallMethod · 0.45
ExecuteMethod · 0.45

Calls 9

TryGetBeValueMethod · 0.80
GetBeValueMethod · 0.80
IsConstMethod · 0.45
IsFakeMethod · 0.45
TryAddMethod · 0.45
EndsWithMethod · 0.45
RemoveFromEndMethod · 0.45
GetOwnerMethod · 0.45
IsVarMethod · 0.45

Tested by

no test coverage detected