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

Method GetCallTableIdx

IDEHelper/Compiler/CeMachine.cpp:1448–1504  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1446}
1447
1448int CeBuilder::GetCallTableIdx(BeFunction* beFunction, CeOperand* outOperand)
1449{
1450 int* callIdxPtr = NULL;
1451 if (mFunctionMap.TryAdd(beFunction, NULL, &callIdxPtr))
1452 {
1453 CeFunctionInfo* ceFunctionInfo = NULL;
1454 mCeMachine->mNamedFunctionMap.TryGetValue(beFunction->mName, &ceFunctionInfo);
1455 if (ceFunctionInfo != NULL)
1456 ceFunctionInfo->mRefCount++;
1457 else
1458 {
1459 if (outOperand != NULL)
1460 {
1461 auto checkBuilder = this;
1462 if (checkBuilder->mParentBuilder != NULL)
1463 checkBuilder = checkBuilder->mParentBuilder;
1464
1465 int innerFunctionIdx = 0;
1466 if (checkBuilder->mInnerFunctionMap.TryGetValue(beFunction, &innerFunctionIdx))
1467 {
1468 auto innerFunction = checkBuilder->mCeFunction->mInnerFunctions[innerFunctionIdx];
1469 if (innerFunction->mInitializeState < CeFunction::InitializeState_Initialized)
1470 mCeMachine->PrepareFunction(innerFunction, checkBuilder);
1471
1472 CeOperand result = FrameAlloc(mCeMachine->GetBeContext()->GetPrimitiveType((sizeof(BfMethodInstance*) == 8) ? BeTypeCode_Int64 : BeTypeCode_Int32));
1473 Emit(CeOp_GetMethod_Inner);
1474 EmitFrameOffset(result);
1475 Emit((int32)innerFunctionIdx);
1476
1477 *outOperand = result;
1478 return -1;
1479 }
1480 }
1481
1482 Fail(StrFormat("Unable to locate method %s", beFunction->mName.c_str()));
1483 }
1484
1485 CeCallEntry callEntry;
1486 callEntry.mFunctionInfo = ceFunctionInfo;
1487 *callIdxPtr = (int)mCeFunction->mCallTable.size();
1488 mCeFunction->mCallTable.Add(callEntry);
1489
1490 if ((ceFunctionInfo != NULL) && (mCeFunction->mCeFunctionInfo != NULL))
1491 {
1492 auto callerType = mCeFunction->GetOwner();
1493 auto calleeType = ceFunctionInfo->GetOwner();
1494
1495 if ((callerType != NULL) && (calleeType != NULL))
1496 {
1497 // This will generally already be set, but there are some error cases (such as duplicate type names)
1498 // where this will not be set yet
1499 callerType->mModule->AddDependency(calleeType, callerType, BfDependencyMap::DependencyFlag_Calls);
1500 }
1501 }
1502 }
1503 return *callIdxPtr;
1504}
1505

Callers

nothing calls this directly

Calls 11

FailFunction · 0.85
TryGetValueMethod · 0.80
PrepareFunctionMethod · 0.80
GetBeContextMethod · 0.80
AddDependencyMethod · 0.80
TryAddMethod · 0.45
GetPrimitiveTypeMethod · 0.45
c_strMethod · 0.45
sizeMethod · 0.45
AddMethod · 0.45
GetOwnerMethod · 0.45

Tested by

no test coverage detected