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

Method CreateTypeDataRef

IDEHelper/Compiler/BfModule.cpp:5797–5847  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5795}
5796
5797BfIRValue BfModule::CreateTypeDataRef(BfType* type, bool forceConstant)
5798{
5799 if (mBfIRBuilder->mIgnoreWrites)
5800 {
5801 return mBfIRBuilder->CreateTypeOf(type);
5802 }
5803
5804 if (mIsComptimeModule)
5805 {
5806 if (forceConstant)
5807 return mBfIRBuilder->CreateTypeOfComptime(type);
5808
5809 auto typeTypeDef = ResolveTypeDef(mCompiler->mTypeTypeDef);
5810 auto typeTypeInst = typeTypeDef->ToTypeInstance();
5811 return mBfIRBuilder->Comptime_GetReflectType(type->mTypeId, mBfIRBuilder->MapType(typeTypeInst));
5812 }
5813
5814 PopulateType(type);
5815
5816 BfIRValue globalVariable;
5817
5818 BfIRValue* globalVariablePtr = NULL;
5819 if (mTypeDataRefs.TryGetValue(type, &globalVariablePtr))
5820 {
5821 if (*globalVariablePtr)
5822 return mBfIRBuilder->CreateTypeOf(type, *globalVariablePtr);
5823 }
5824
5825 auto typeTypeDef = ResolveTypeDef(mCompiler->mTypeTypeDef);
5826 auto typeTypeInst = typeTypeDef->ToTypeInstance();
5827 auto typeInstance = type->ToTypeInstance();
5828
5829 StringT<4096> typeDataName;
5830 if (typeInstance != NULL)
5831 {
5832 BfMangler::MangleStaticFieldName(typeDataName, mCompiler->GetMangleKind(), typeInstance, "sBfTypeData");
5833 }
5834 else
5835 {
5836 typeDataName += "sBfTypeData.";
5837 BfMangler::Mangle(typeDataName, mCompiler->GetMangleKind(), type, this);
5838 }
5839
5840 BfLogSysM("Creating TypeData %s\n", typeDataName.c_str());
5841
5842 globalVariable = mBfIRBuilder->CreateGlobalVariable(mBfIRBuilder->MapTypeInst(typeTypeInst, BfIRPopulateType_Full), true, BfIRLinkageType_External, BfIRValue(), typeDataName);
5843 mBfIRBuilder->SetReflectTypeData(mBfIRBuilder->MapType(type), globalVariable);
5844
5845 mTypeDataRefs[type] = globalVariable;
5846 return mBfIRBuilder->CreateTypeOf(type, globalVariable);
5847}
5848
5849void BfModule::EncodeAttributeData(BfTypeInstance* typeInstance, BfType* argType, BfIRValue arg, SizedArrayImpl<uint8>& data, Dictionary<int, int>& usedStringIdMap)
5850{

Callers 7

CreateConstantMethod · 0.80
CallMethod · 0.80
EvaluateMethod · 0.80
CreateCallMethod · 0.80
MatchMethodMethod · 0.80
VisitMethod · 0.80
LookupTypePropMethod · 0.80

Calls 12

BfIRValueClass · 0.85
CreateTypeOfMethod · 0.80
CreateTypeOfComptimeMethod · 0.80
MapTypeMethod · 0.80
TryGetValueMethod · 0.80
GetMangleKindMethod · 0.80
CreateGlobalVariableMethod · 0.80
MapTypeInstMethod · 0.80
SetReflectTypeDataMethod · 0.80
ToTypeInstanceMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected