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

Method CreateClassVDataExtGlobal

IDEHelper/Compiler/BfModule.cpp:5695–5795  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5693}
5694
5695BfIRValue BfModule::CreateClassVDataExtGlobal(BfTypeInstance* declTypeInst, BfTypeInstance* implTypeInst, int startVirtIdx)
5696{
5697 if (mBfIRBuilder->mIgnoreWrites)
5698 return mBfIRBuilder->GetFakeVal();
5699
5700 int numElements = declTypeInst->GetSelfVTableSize() - declTypeInst->GetOrigSelfVTableSize();
5701 if (numElements < 0)
5702 InternalError("CreateClassVDataExtGlobal numElements < 0");
5703 if (numElements <= 0)
5704 return BfIRValue();
5705
5706 BF_ASSERT(implTypeInst->mVirtualMethodTable[startVirtIdx].mDeclaringMethod.mMethodNum == -1);
5707 BF_ASSERT(implTypeInst->mVirtualMethodTable[startVirtIdx].mDeclaringMethod.mTypeInstance == declTypeInst);
5708
5709 if (declTypeInst->mInheritDepth == implTypeInst->mInheritDepth)
5710 BF_ASSERT(declTypeInst == implTypeInst);
5711 else
5712 BF_ASSERT(implTypeInst->mInheritDepth > declTypeInst->mInheritDepth);
5713
5714 if (declTypeInst != implTypeInst)
5715 {
5716 BfTypeInstance* highestImpl = declTypeInst;
5717
5718 for (int virtIdx = startVirtIdx + 1; virtIdx < (int)declTypeInst->mVirtualMethodTable.size(); virtIdx++)
5719 {
5720 if (implTypeInst->mVirtualMethodTable[virtIdx].mDeclaringMethod.mMethodNum == -1)
5721 break; // Start of an ext entry for another type
5722
5723 auto checkImplTypeInst = implTypeInst->mVirtualMethodTable[virtIdx].mImplementingMethod.mTypeInstance;
5724 if ((checkImplTypeInst != NULL) && (checkImplTypeInst->mInheritDepth > highestImpl->mInheritDepth))
5725 highestImpl = checkImplTypeInst;
5726 }
5727
5728 if (highestImpl != implTypeInst)
5729 return CreateClassVDataExtGlobal(declTypeInst, highestImpl, startVirtIdx);
5730 }
5731
5732 BfVDataExtEntry mapEntry;
5733 mapEntry.mDeclTypeInst = declTypeInst;
5734 mapEntry.mImplTypeInst = implTypeInst;
5735
5736 BfIRValue* irValuePtr = NULL;
5737 if (mClassVDataExtRefs.TryGetValue(mapEntry, &irValuePtr))
5738 return *irValuePtr;
5739
5740 PopulateType(declTypeInst, BfPopulateType_DataAndMethods);
5741 PopulateType(implTypeInst, BfPopulateType_DataAndMethods);
5742 StringT<512> classVDataName;
5743 BfMangler::MangleStaticFieldName(classVDataName, mCompiler->GetMangleKind(), implTypeInst, "bf_hs_replace_VDataExt");
5744 if (declTypeInst != implTypeInst)
5745 {
5746 classVDataName += StrFormat("_%d", implTypeInst->mInheritDepth - declTypeInst->mInheritDepth);
5747 }
5748
5749 auto voidPtrType = GetPrimitiveType(BfTypeCode_NullPtr);
5750 auto voidPtrIRType = mBfIRBuilder->MapType(voidPtrType);
5751
5752 SizedArray<BfIRValue, 32> vData;

Callers

nothing calls this directly

Calls 15

BfIRValueClass · 0.85
GetFakeValMethod · 0.80
GetSelfVTableSizeMethod · 0.80
GetOrigSelfVTableSizeMethod · 0.80
TryGetValueMethod · 0.80
GetMangleKindMethod · 0.80
MapTypeMethod · 0.80
IsImplementedMethod · 0.80
CreateGlobalVariableMethod · 0.80
CreateConstAgg_ValueMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected