1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-09 20:12:21 +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);
@ -12588,6 +12595,9 @@ BfModuleMethodInstance BfModule::GetMethodInstance(BfTypeInstance* typeInst, BfM
{ {
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
@ -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

@ -5443,6 +5443,9 @@ BfTypedValue CeMachine::Call(BfAstNode* targetSrc, BfModule* module, BfMethodIns
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)
{ {
if ((mAppendAllocInfo->mAppendSizeValue) && (!mAppendAllocInfo->mAppendSizeValue.IsConst())) if ((mAppendAllocInfo->mAppendSizeValue) && (!mAppendAllocInfo->mAppendSizeValue.IsConst()))