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

consteval reification fixes

This commit is contained in:
Brian Fiete 2020-12-23 14:04:35 -08:00
parent 08e3f9155e
commit 21798e20f9
3 changed files with 27 additions and 7 deletions

View file

@ -12388,6 +12388,13 @@ BfModuleMethodInstance BfModule::GetMethodInstance(BfTypeInstance* typeInst, BfM
auto defFlags = (BfGetMethodInstanceFlags)(flags & ~BfGetMethodInstanceFlag_ForceInline); auto defFlags = (BfGetMethodInstanceFlags)(flags & ~BfGetMethodInstanceFlag_ForceInline);
if (mIsConstModule)
{
defFlags = (BfGetMethodInstanceFlags)(flags | BfGetMethodInstanceFlag_NoReference);
if (!mCompiler->mIsResolveOnly)
defFlags = (BfGetMethodInstanceFlags)(flags | BfGetMethodInstanceFlag_NoForceReification | BfGetMethodInstanceFlag_Unreified | BfGetMethodInstanceFlag_NoReference);
}
// Not extern // Not extern
// Create the instance in the proper module and then create a reference in this one // Create the instance in the proper module and then create a reference in this one
moduleMethodInst = instModule->GetMethodInstance(typeInst, methodDef, methodGenericArguments, defFlags, foreignType); moduleMethodInst = instModule->GetMethodInstance(typeInst, methodDef, methodGenericArguments, defFlags, foreignType);
@ -12587,7 +12594,10 @@ BfModuleMethodInstance BfModule::GetMethodInstance(BfTypeInstance* typeInst, BfM
if (lookupMethodGenericArguments.size() == 0) if (lookupMethodGenericArguments.size() == 0)
{ {
methodInstance = methodInstGroup->mDefault; methodInstance = methodInstGroup->mDefault;
if ((methodInstance != NULL) && ((flags & BfGetMethodInstanceFlag_NoReference) != 0))
return methodInstance;
if ((methodInstance != NULL) && (isReified) && (!methodInstance->mIsReified)) if ((methodInstance != NULL) && (isReified) && (!methodInstance->mIsReified))
{ {
MarkDerivedDirty(typeInst); MarkDerivedDirty(typeInst);
@ -12696,6 +12706,9 @@ BfModuleMethodInstance BfModule::GetMethodInstance(BfTypeInstance* typeInst, BfM
{ {
methodInstance = *methodInstancePtr; methodInstance = *methodInstancePtr;
if ((flags & BfGetMethodInstanceFlag_NoReference) != 0)
return methodInstance;
if ((methodInstance->mRequestedByAutocomplete) && (!mCompiler->IsAutocomplete())) if ((methodInstance->mRequestedByAutocomplete) && (!mCompiler->IsAutocomplete()))
{ {
// We didn't want to process this message yet if it was autocomplete-specific, but now we will // We didn't want to process this message yet if it was autocomplete-specific, but now we will
@ -12747,16 +12760,16 @@ BfModuleMethodInstance BfModule::GetMethodInstance(BfTypeInstance* typeInst, BfM
if (methodInstance->mIsReified != isReified) if (methodInstance->mIsReified != isReified)
BfLogSysM("GetMethodInstance %p Decl_AwaitingReference setting reified to %d\n", methodInstance, isReified); BfLogSysM("GetMethodInstance %p Decl_AwaitingReference setting reified to %d\n", methodInstance, isReified);
if ((!isReified) && if ((!isReified) &&
((methodInstance->mDeclModule == NULL) || (!methodInstance->mDeclModule->mIsModuleMutable))) ((methodInstance->mDeclModule == NULL) || (!methodInstance->mDeclModule->mIsModuleMutable)))
{ {
methodInstance->mDeclModule = mContext->mUnreifiedModule; methodInstance->mDeclModule = mContext->mUnreifiedModule;
methodInstance->mIRFunction = BfIRFunction(); methodInstance->mIRFunction = BfIRFunction();
} }
methodInstance->mIsReified = isReified; methodInstance->mIsReified = isReified;
if ((methodInstance->mHotMethod != NULL) && (!mCompiler->IsHotCompile()) && (isReified)) if ((methodInstance->mHotMethod != NULL) && (!mCompiler->IsHotCompile()) && (isReified))
{ {
methodInstance->mHotMethod->mFlags = (BfHotDepDataFlags)(methodInstance->mHotMethod->mFlags | BfHotDepDataFlag_IsOriginalBuild); methodInstance->mHotMethod->mFlags = (BfHotDepDataFlags)(methodInstance->mHotMethod->mFlags | BfHotDepDataFlag_IsOriginalBuild);
} }
@ -12766,8 +12779,8 @@ BfModuleMethodInstance BfModule::GetMethodInstance(BfTypeInstance* typeInst, BfM
{ {
// Wait until unreified // Wait until unreified
} }
else else
AddMethodToWorkList(methodInstance); AddMethodToWorkList(methodInstance);
} }
else else
{ {
@ -13024,6 +13037,9 @@ BfModuleMethodInstance BfModule::GetMethodInstance(BfTypeInstance* typeInst, BfM
addToWorkList = false; addToWorkList = false;
} }
// if ((flags & BfGetMethodInstanceFlag_NoReference) != 0)
// addToWorkList = false;
declareModule->DoMethodDeclaration(methodDef->GetMethodDeclaration(), false, addToWorkList); declareModule->DoMethodDeclaration(methodDef->GetMethodDeclaration(), false, addToWorkList);
if (processNow) if (processNow)

View file

@ -73,7 +73,8 @@ enum BfGetMethodInstanceFlags : uint16
BfGetMethodInstanceFlag_Friend = 0x100, BfGetMethodInstanceFlag_Friend = 0x100,
BfGetMethodInstanceFlag_DisableObjectAccessChecks = 0x200, BfGetMethodInstanceFlag_DisableObjectAccessChecks = 0x200,
BfGetMethodInstanceFlag_NoInline = 0x400, BfGetMethodInstanceFlag_NoInline = 0x400,
BfGetMethodInstanceFlag_DepthExceeded = 0x800 BfGetMethodInstanceFlag_DepthExceeded = 0x800,
BfGetMethodInstanceFlag_NoReference = 0x1000
}; };
class BfDependencyMap class BfDependencyMap

View file

@ -5442,6 +5442,9 @@ BfTypedValue CeMachine::Call(BfAstNode* targetSrc, BfModule* module, BfMethodIns
SetAndRestoreValue<BfModule*> prevModule(mCurModule, module); SetAndRestoreValue<BfModule*> prevModule(mCurModule, module);
SetAndRestoreValue<BfMethodInstance*> prevMethodInstance(mCurMethodInstance, methodInstance); SetAndRestoreValue<BfMethodInstance*> prevMethodInstance(mCurMethodInstance, methodInstance);
SetAndRestoreValue<BfType*> prevExpectingType(mCurExpectingType, expectingType); SetAndRestoreValue<BfType*> prevExpectingType(mCurExpectingType, expectingType);
// Reentrancy may occur as methods need defining
SetAndRestoreValue<BfMethodState*> prevMethodStateInConstEval(module->mCurMethodState, NULL);
if (mAppendAllocInfo != NULL) if (mAppendAllocInfo != NULL)
{ {