1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-09 03:52:19 +02:00

Fixed reifying dll import methods during hot compile

This commit is contained in:
Brian Fiete 2025-01-09 05:58:32 -08:00
parent 85fcca9c76
commit 05f17ce3ae

View file

@ -14692,6 +14692,23 @@ BfModuleMethodInstance BfModule::GetMethodInstance(BfTypeInstance* typeInst, BfM
} }
} }
auto _CheckDllImport = [&]()
{
auto declModule = methodInstance->mDeclModule;
if ((!methodInstance->mIRFunction) && (declModule->mIsModuleMutable) && (!declModule->mBfIRBuilder->mIgnoreWrites))
{
auto importKind = methodInstance->GetImportCallKind();
if (importKind != BfImportCallKind_None)
{
BfLogSysM("DllImportGlobalVar creating %p in module %p from module %p\n", methodInstance, declModule, this);
methodInstance->mIRFunction = mBfIRBuilder->GetFakeVal();
auto func = declModule->CreateDllImportGlobalVar(methodInstance, true);
BF_ASSERT(func);
declModule->mFuncReferences[methodInstance] = func;
}
}
};
if ((methodInstance != NULL) && (!doingRedeclare)) if ((methodInstance != NULL) && (!doingRedeclare))
{ {
SetMethodDependency(methodInstance); SetMethodDependency(methodInstance);
@ -14794,18 +14811,7 @@ BfModuleMethodInstance BfModule::GetMethodInstance(BfTypeInstance* typeInst, BfM
if (methodInstance->mDeclModule != this) if (methodInstance->mDeclModule != this)
return ReferenceExternalMethodInstance(methodInstance, flags); return ReferenceExternalMethodInstance(methodInstance, flags);
if ((!methodInstance->mIRFunction) && (mIsModuleMutable) && (!mBfIRBuilder->mIgnoreWrites)) _CheckDllImport();
{
auto importKind = methodInstance->GetImportCallKind();
if (importKind != BfImportCallKind_None)
{
BfLogSysM("DllImportGlobalVar creating %p\n", methodInstance);
methodInstance->mIRFunction = mBfIRBuilder->GetFakeVal();
auto func = CreateDllImportGlobalVar(methodInstance, true);
BF_ASSERT(func);
mFuncReferences[methodInstance] = func;
}
}
return BfModuleMethodInstance(methodInstance); return BfModuleMethodInstance(methodInstance);
} }
@ -15040,6 +15046,11 @@ BfModuleMethodInstance BfModule::GetMethodInstance(BfTypeInstance* typeInst, BfM
if (methodInstance->mDeclModule != this) if (methodInstance->mDeclModule != this)
return ReferenceExternalMethodInstance(methodInstance, flags); return ReferenceExternalMethodInstance(methodInstance, flags);
if (doingRedeclare)
{
_CheckDllImport();
}
return BfModuleMethodInstance(methodInstance); return BfModuleMethodInstance(methodInstance);
} }