1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 12:32:20 +02:00

Reification fixes

This commit is contained in:
Brian Fiete 2020-05-19 07:13:15 -07:00
parent 622b832858
commit 0d1fc7e1a5
2 changed files with 8 additions and 5 deletions

View file

@ -2890,13 +2890,18 @@ bool BfIRBuilder::WantsDbgDefinition(BfType* type)
void BfIRBuilder::CreateTypeDefinition(BfType* type, bool forceDbgDefine) void BfIRBuilder::CreateTypeDefinition(BfType* type, bool forceDbgDefine)
{ {
auto populateModule = mModule->mContext->mUnreifiedModule;
auto typeInstance = type->ToTypeInstance();
if (typeInstance != NULL)
populateModule = typeInstance->mModule;
// This PopulateType is generally NOT needed, but here is a scenario in which it is: // This PopulateType is generally NOT needed, but here is a scenario in which it is:
// ClassB derives from ClassA. ClassC uses ClassB. A method inside ClassA gets modified, // ClassB derives from ClassA. ClassC uses ClassB. A method inside ClassA gets modified,
// marking ClassA as incomplete, and then ClassC rebuilds and calls MapType on ClassB. // marking ClassA as incomplete, and then ClassC rebuilds and calls MapType on ClassB.
// "ClassB" itself is still populated, but its base class (ClassA) is not -- until we call // "ClassB" itself is still populated, but its base class (ClassA) is not -- until we call
// this PopulateType below. // this PopulateType below.
if (type->IsDataIncomplete()) if (type->IsDataIncomplete())
mModule->PopulateType(type, BfPopulateType_Data); populateModule->PopulateType(type, BfPopulateType_Data);
bool isDefiningModule = ((type->GetModule() == mModule) || (type->IsFunction())); bool isDefiningModule = ((type->GetModule() == mModule) || (type->IsFunction()));
if (mModule->mExtensionCount != 0) if (mModule->mExtensionCount != 0)
@ -2906,7 +2911,7 @@ void BfIRBuilder::CreateTypeDefinition(BfType* type, bool forceDbgDefine)
// isDefiningModule = true; // isDefiningModule = true;
if ((isDefiningModule) || (type->IsValueType())) if ((isDefiningModule) || (type->IsValueType()))
mModule->PopulateType(type, BfPopulateType_DataAndMethods); populateModule->PopulateType(type, BfPopulateType_DataAndMethods);
if ((!isDefiningModule) && (!type->IsUnspecializedType()) && (type->IsValueType()) && (mHasDebugInfo)) if ((!isDefiningModule) && (!type->IsUnspecializedType()) && (type->IsValueType()) && (mHasDebugInfo))
{ {
@ -2914,8 +2919,7 @@ void BfIRBuilder::CreateTypeDefinition(BfType* type, bool forceDbgDefine)
} }
bool isPrimEnum = (type->IsEnum()) && (type->IsTypedPrimitive()); bool isPrimEnum = (type->IsEnum()) && (type->IsTypedPrimitive());
auto typeInstance = type->ToTypeInstance();
if (typeInstance == NULL) if (typeInstance == NULL)
return; return;

View file

@ -11416,7 +11416,6 @@ BfModuleMethodInstance BfModule::GetMethodInstance(BfTypeInstance* typeInst, BfM
if (!instModule->mReifyQueued) if (!instModule->mReifyQueued)
{ {
BF_ASSERT((mCompiler->mCompileState != BfCompiler::CompileState_Unreified) && (mCompiler->mCompileState != BfCompiler::CompileState_VData)); BF_ASSERT((mCompiler->mCompileState != BfCompiler::CompileState_Unreified) && (mCompiler->mCompileState != BfCompiler::CompileState_VData));
BfLogSysM("Queueing ReifyModule: %p\n", instModule); BfLogSysM("Queueing ReifyModule: %p\n", instModule);
mContext->mReifyModuleWorkList.Add(instModule); mContext->mReifyModuleWorkList.Add(instModule);
instModule->mReifyQueued = true; instModule->mReifyQueued = true;