| 992 | } |
| 993 | |
| 994 | void BfContext::RebuildType(BfType* type, bool deleteOnDemandTypes, bool rebuildModule, bool placeSpecializiedInPurgatory) |
| 995 | { |
| 996 | BfTypeInstance* typeInst = type->ToTypeInstance(); |
| 997 | |
| 998 | if (type->IsDeleting()) |
| 999 | { |
| 1000 | return; |
| 1001 | } |
| 1002 | |
| 1003 | type->mDirty = true; |
| 1004 | |
| 1005 | bool wantDeleteType = (type->IsOnDemand()) && (deleteOnDemandTypes); |
| 1006 | if (type->IsConstExprValue()) |
| 1007 | { |
| 1008 | auto constExprType = (BfConstExprValueType*)type; |
| 1009 | if ((constExprType->mValue.mTypeCode != BfTypeCode_StringId) && (constExprType->mValue.mTypeCode != BfTypeCode_Struct) && |
| 1010 | (constExprType->mType->mSize != mScratchModule->GetPrimitiveType(constExprType->mValue.mTypeCode)->mSize)) |
| 1011 | wantDeleteType = true; |
| 1012 | } |
| 1013 | if (wantDeleteType) |
| 1014 | { |
| 1015 | BfLogSysM("On-demand type %p attempted rebuild - deleting\n", type); |
| 1016 | DeleteType(type); |
| 1017 | auto depType = type->ToDependedType(); |
| 1018 | if (depType != NULL) |
| 1019 | RebuildDependentTypes(depType); |
| 1020 | return; |
| 1021 | } |
| 1022 | |
| 1023 | if (typeInst == NULL) |
| 1024 | { |
| 1025 | type->mDefineState = BfTypeDefineState_Undefined; |
| 1026 | |
| 1027 | BfTypeProcessRequest* typeProcessRequest = mPopulateTypeWorkList.Alloc(); |
| 1028 | typeProcessRequest->mType = type; |
| 1029 | mCompiler->mStats.mTypesQueued++; |
| 1030 | mCompiler->UpdateCompletion(); |
| 1031 | |
| 1032 | return; |
| 1033 | } |
| 1034 | |
| 1035 | typeInst->mRebuildFlags = (BfTypeRebuildFlags)(typeInst->mRebuildFlags | BfTypeRebuildFlag_InRebuildType); |
| 1036 | defer( |
| 1037 | { |
| 1038 | typeInst->mRebuildFlags = (BfTypeRebuildFlags)(typeInst->mRebuildFlags & ~BfTypeRebuildFlag_InRebuildType); |
| 1039 | }); |
| 1040 | |
| 1041 | if (mCompiler->mCeMachine != NULL) |
| 1042 | mCompiler->mCeMachine->ClearTypeData(typeInst); |
| 1043 | |
| 1044 | BF_ASSERT_REL(typeInst->mDefineState != BfTypeDefineState_DefinedAndMethodsSlotting); |
| 1045 | |
| 1046 | // We need to verify lookups before we rebuild the type, because a type lookup change needs to count as a TypeDataChanged |
| 1047 | VerifyTypeLookups(typeInst); |
| 1048 | |
| 1049 | if (typeInst->mRevision != mCompiler->mRevision) |
| 1050 | { |
| 1051 | BfLogSysM("Setting revision. Type: %p Revision: %d\n", typeInst, mCompiler->mRevision); |
no test coverage detected