| 6410 | } |
| 6411 | |
| 6412 | BfIRValue BfModule::CreateTypeData(BfType* type, BfCreateTypeDataContext& ctx, bool forceReflectFields, bool needsTypeData, bool needsTypeNames, bool needsVData) |
| 6413 | { |
| 6414 | if ((IsHotCompile()) && (!type->mDirty)) |
| 6415 | return BfIRValue(); |
| 6416 | |
| 6417 | BfIRValue* irValuePtr = NULL; |
| 6418 | if (mTypeDataRefs.TryGetValue(type, &irValuePtr)) |
| 6419 | { |
| 6420 | return *irValuePtr; |
| 6421 | } |
| 6422 | |
| 6423 | BfTypeInstance* typeInstance = type->ToTypeInstance(); |
| 6424 | BfType* typeInstanceType = ResolveTypeDef(mCompiler->mReflectTypeInstanceTypeDef); |
| 6425 | mBfIRBuilder->PopulateType(typeInstanceType, BfIRPopulateType_Full_ForceDefinition); |
| 6426 | |
| 6427 | if (typeInstanceType == NULL) |
| 6428 | { |
| 6429 | AssertErrorState(); |
| 6430 | return BfIRValue(); |
| 6431 | } |
| 6432 | |
| 6433 | int typeCode = BfTypeCode_None; |
| 6434 | int typeFlags = 0; |
| 6435 | BfIRValue typeTypeData = GetTypeTypeData(type, ctx, needsTypeData, false, needsTypeNames, typeFlags, typeCode); |
| 6436 | |
| 6437 | BfType* longType = GetPrimitiveType(BfTypeCode_Int64); |
| 6438 | BfType* intType = GetPrimitiveType(BfTypeCode_Int32); |
| 6439 | BfType* intPtrType = GetPrimitiveType(BfTypeCode_IntPtr); |
| 6440 | BfType* shortType = GetPrimitiveType(BfTypeCode_Int16); |
| 6441 | BfType* byteType = GetPrimitiveType(BfTypeCode_Int8); |
| 6442 | |
| 6443 | BfType* typeIdType = intType; |
| 6444 | |
| 6445 | auto voidPtrType = GetPrimitiveType(BfTypeCode_NullPtr); |
| 6446 | auto voidPtrIRType = mBfIRBuilder->MapType(voidPtrType); |
| 6447 | auto voidPtrPtrIRType = mBfIRBuilder->GetPointerTo(voidPtrIRType); |
| 6448 | auto voidPtrNull = GetDefaultValue(voidPtrType); |
| 6449 | |
| 6450 | SizedArray<BfIRValue, 4> typeValueParams; |
| 6451 | GetConstClassValueParam(typeTypeData, typeValueParams); |
| 6452 | |
| 6453 | FixConstValueParams(mContext->mBfObjectType, typeValueParams); |
| 6454 | BfIRValue objectData = mBfIRBuilder->CreateConstAgg_Value(mBfIRBuilder->MapTypeInst(mContext->mBfObjectType, BfIRPopulateType_Full), typeValueParams); |
| 6455 | |
| 6456 | StringT<512> typeDataName; |
| 6457 | if ((typeInstance != NULL) && (!typeInstance->IsTypeAlias())) |
| 6458 | { |
| 6459 | BfMangler::MangleStaticFieldName(typeDataName, mCompiler->GetMangleKind(), typeInstance, "sBfTypeData"); |
| 6460 | if (typeInstance->mTypeDef->IsGlobalsContainer()) |
| 6461 | typeDataName += "`G`" + typeInstance->mTypeDef->mProject->mName; |
| 6462 | } |
| 6463 | else |
| 6464 | { |
| 6465 | typeDataName += "sBfTypeData."; |
| 6466 | BfMangler::Mangle(typeDataName, mCompiler->GetMangleKind(), type, mContext->mScratchModule); |
| 6467 | } |
| 6468 | |
| 6469 | int virtSlotIdx = -1; |
no test coverage detected