| 5795 | } |
| 5796 | |
| 5797 | BfIRValue 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 | |
| 5849 | void BfModule::EncodeAttributeData(BfTypeInstance* typeInstance, BfType* argType, BfIRValue arg, SizedArrayImpl<uint8>& data, Dictionary<int, int>& usedStringIdMap) |
| 5850 | { |
no test coverage detected