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

Method GetInterfaceSlotNum

IDEHelper/Compiler/BfModule.cpp:15545–15583  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15543}
15544
15545BfIRValue BfModule::GetInterfaceSlotNum(BfTypeInstance* ifaceType)
15546{
15547 BfIRValue globalValue;
15548
15549 BfIRValue* globalValuePtr = NULL;
15550 if (mInterfaceSlotRefs.TryGetValue(ifaceType, &globalValuePtr))
15551 {
15552 globalValue = *globalValuePtr;
15553 }
15554
15555 if (!globalValue)
15556 {
15557 // This is necessary to reify the interface type
15558 PopulateType(ifaceType);
15559
15560 StringT<512> slotVarName;
15561 BfMangler::MangleStaticFieldName(slotVarName, mCompiler->GetMangleKind(), ifaceType, "sBfSlotOfs");
15562 BfType* intType = GetPrimitiveType(BfTypeCode_Int32);
15563 BfIRValue value;
15564
15565 if ((mCompiler->mHotState != NULL) && (ifaceType->mSlotNum >= 0))
15566 {
15567 /*// If this interface already existed before this hot compile but we never indirectly called any of its methods
15568 // then the sBfSlotOfs could have gotten its symbol stripped, so actually define it here.
15569 int virtSlotIdx = ifaceType->mSlotNum + 1;
15570 value = GetConstValue32(virtSlotIdx);*/
15571 mCompiler->mHotState->mSlotDefineTypeIds.Add(ifaceType->mTypeId);
15572 ifaceType->mDirty = true; // Makes sure we create interface in vdata
15573 }
15574
15575 globalValue = mBfIRBuilder->CreateGlobalVariable(mBfIRBuilder->MapType(intType), true, BfIRLinkageType_External, value, slotVarName);
15576 mInterfaceSlotRefs[ifaceType] = globalValue;
15577 // Make sure we reify
15578 PopulateType(ifaceType, BfPopulateType_Declaration);
15579 AddDependency(ifaceType, mCurTypeInstance, BfDependencyMap::DependencyFlag_StaticValue);
15580 }
15581
15582 return mBfIRBuilder->CreateAlignedLoad(globalValue/*, "slotOfs"*/, 4);
15583}
15584
15585void BfModule::HadSlotCountDependency()
15586{

Callers 1

CreateCallMethod · 0.80

Calls 6

TryGetValueMethod · 0.80
GetMangleKindMethod · 0.80
CreateGlobalVariableMethod · 0.80
MapTypeMethod · 0.80
AddMethod · 0.45
CreateAlignedLoadMethod · 0.45

Tested by

no test coverage detected