mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-09 12:02:21 +02:00
Fixed a module extension issue with mIRFunction not being cleared
This commit is contained in:
parent
07a8e1fe23
commit
d7da98444e
7 changed files with 71 additions and 66 deletions
5
IDE/Tests/BugW002/BeefProj.toml
Normal file
5
IDE/Tests/BugW002/BeefProj.toml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
FileVersion = 1
|
||||||
|
|
||||||
|
[Project]
|
||||||
|
Name = "Bug"
|
||||||
|
StartupObject = "Bug.Program"
|
6
IDE/Tests/BugW002/BeefSpace.toml
Normal file
6
IDE/Tests/BugW002/BeefSpace.toml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
FileVersion = 1
|
||||||
|
Projects = {Bug = {Path = "."}}
|
||||||
|
|
||||||
|
[Workspace]
|
||||||
|
StartupProject = "Bug"
|
||||||
|
|
8
IDE/Tests/BugW002/scripts/Test.txt
Normal file
8
IDE/Tests/BugW002/scripts/Test.txt
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
# This tests extensions in Span<uint8>, whose IRFunction was not being cleared
|
||||||
|
|
||||||
|
ShowFile("src/Program.bf")
|
||||||
|
Compile()
|
||||||
|
ToggleCommentAt("Main_OpenReg")
|
||||||
|
Compile()
|
||||||
|
ToggleCommentAt("Main_GetValue")
|
||||||
|
Compile()
|
25
IDE/Tests/BugW002/src/Program.bf
Normal file
25
IDE/Tests/BugW002/src/Program.bf
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
#pragma warning disable 168
|
||||||
|
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Bug
|
||||||
|
{
|
||||||
|
class Program
|
||||||
|
{
|
||||||
|
static void Main()
|
||||||
|
{
|
||||||
|
/*Main_OpenReg
|
||||||
|
Windows.HKey key = 0;
|
||||||
|
Windows.RegOpenKeyExA(Windows.HKEY_LOCAL_MACHINE, @"SYSTEM\CurrentControlSet\Control\Session Manager\Environment", 0, Windows.KEY_QUERY_VALUE, out key);
|
||||||
|
if (key.IsInvalid)
|
||||||
|
Runtime.FatalError();
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*Main_GetValue
|
||||||
|
String path = scope .();
|
||||||
|
if (key.GetValue("path", path) case .Err)
|
||||||
|
Runtime.FatalError();
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -4125,6 +4125,8 @@ BfIRFunction BfIRBuilder::CreateFunction(BfIRFunctionType funcType, BfIRLinkageT
|
||||||
return fakeVal;
|
return fakeVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BF_ASSERT(mModule->mIsModuleMutable);
|
||||||
|
|
||||||
BfIRFunction retVal = WriteCmd(BfIRCmd_CreateFunction, funcType, (uint8)linkageType, name);
|
BfIRFunction retVal = WriteCmd(BfIRCmd_CreateFunction, funcType, (uint8)linkageType, name);
|
||||||
NEW_CMD_INSERTED_IRVALUE;
|
NEW_CMD_INSERTED_IRVALUE;
|
||||||
mFunctionMap[name] = retVal;
|
mFunctionMap[name] = retVal;
|
||||||
|
|
|
@ -4032,11 +4032,6 @@ BfIRValue BfModule::CreateClassVDataGlobal(BfTypeInstance* typeInstance, int* ou
|
||||||
|
|
||||||
StringT<128> classVDataName;
|
StringT<128> classVDataName;
|
||||||
|
|
||||||
if ((mCompiler->IsHotCompile()) && (typeInstance->mTypeDef->mName->ToString() == "ClassC"))
|
|
||||||
{
|
|
||||||
NOP;
|
|
||||||
}
|
|
||||||
|
|
||||||
String memberName = "sBfClassVData";
|
String memberName = "sBfClassVData";
|
||||||
if ((typeInstance->mHotTypeData != NULL) && ((typeInstance->mHotTypeData->mHadDataChange) || (typeInstance->mHotTypeData->mPendingDataChange)))
|
if ((typeInstance->mHotTypeData != NULL) && ((typeInstance->mHotTypeData->mHadDataChange) || (typeInstance->mHotTypeData->mPendingDataChange)))
|
||||||
{
|
{
|
||||||
|
@ -9104,11 +9099,6 @@ void BfModule::ValidateCustomAttributes(BfCustomAttributes* customAttributes, Bf
|
||||||
}
|
}
|
||||||
|
|
||||||
void BfModule::GetCustomAttributes(BfCustomAttributes* customAttributes, BfAttributeDirective* attributesDirective, BfAttributeTargets attrTarget)
|
void BfModule::GetCustomAttributes(BfCustomAttributes* customAttributes, BfAttributeDirective* attributesDirective, BfAttributeTargets attrTarget)
|
||||||
{
|
|
||||||
if ((mCurMethodInstance != NULL) && (mCurMethodInstance->mMethodDef->mName == "OpenAudio"))
|
|
||||||
{
|
|
||||||
NOP;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((attributesDirective != NULL) && (mCompiler->mResolvePassData != NULL) &&
|
if ((attributesDirective != NULL) && (mCompiler->mResolvePassData != NULL) &&
|
||||||
(attributesDirective->IsFromParser(mCompiler->mResolvePassData->mParser)) && (mCompiler->mResolvePassData->mSourceClassifier != NULL))
|
(attributesDirective->IsFromParser(mCompiler->mResolvePassData->mParser)) && (mCompiler->mResolvePassData->mSourceClassifier != NULL))
|
||||||
|
@ -11172,11 +11162,6 @@ BfModuleMethodInstance BfModule::GetMethodInstance(BfTypeInstance* typeInst, BfM
|
||||||
{
|
{
|
||||||
SetAndRestoreValue<bool> prevIgnoreWrites(mBfIRBuilder->mIgnoreWrites, false);
|
SetAndRestoreValue<bool> prevIgnoreWrites(mBfIRBuilder->mIgnoreWrites, false);
|
||||||
|
|
||||||
if ((methodInstance->mMethodDef->mName == "Unwrap") && (mModuleName == "System_Result_PTR_void"))
|
|
||||||
{
|
|
||||||
NOP;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mAwaitingInitFinish)
|
if (mAwaitingInitFinish)
|
||||||
FinishInit();
|
FinishInit();
|
||||||
|
|
||||||
|
@ -14569,11 +14554,6 @@ void BfModule::ProcessMethod_SetupParams(BfMethodInstance* methodInstance, BfTyp
|
||||||
auto methodDef = methodInstance->mMethodDef;
|
auto methodDef = methodInstance->mMethodDef;
|
||||||
auto methodDeclaration = methodDef->mMethodDeclaration;
|
auto methodDeclaration = methodDef->mMethodDeclaration;
|
||||||
|
|
||||||
if (methodDef->mName == "GetIt")
|
|
||||||
{
|
|
||||||
NOP;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isThisStruct = false;
|
bool isThisStruct = false;
|
||||||
if (thisType != NULL)
|
if (thisType != NULL)
|
||||||
isThisStruct = thisType->IsStruct() && !thisType->IsTypedPrimitive();
|
isThisStruct = thisType->IsStruct() && !thisType->IsTypedPrimitive();
|
||||||
|
@ -18384,11 +18364,6 @@ void BfModule::DoMethodDeclaration(BfMethodDeclaration* methodDeclaration, bool
|
||||||
if (mCurMethodInstance->mMethodInstanceGroup->mOnDemandKind == BfMethodOnDemandKind_NoDecl_AwaitingReference)
|
if (mCurMethodInstance->mMethodInstanceGroup->mOnDemandKind == BfMethodOnDemandKind_NoDecl_AwaitingReference)
|
||||||
mCurMethodInstance->mMethodInstanceGroup->mOnDemandKind = BfMethodOnDemandKind_Decl_AwaitingReference;
|
mCurMethodInstance->mMethodInstanceGroup->mOnDemandKind = BfMethodOnDemandKind_Decl_AwaitingReference;
|
||||||
|
|
||||||
if (mCurTypeInstance->mTypeDef->mName->ToString() == "ClassA")
|
|
||||||
{
|
|
||||||
NOP;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ignoreWrites = mBfIRBuilder->mIgnoreWrites;
|
bool ignoreWrites = mBfIRBuilder->mIgnoreWrites;
|
||||||
|
|
||||||
if (mAwaitingInitFinish)
|
if (mAwaitingInitFinish)
|
||||||
|
@ -20322,16 +20297,6 @@ bool BfModule::Finish()
|
||||||
BP_ZONE("BfModule::Finish");
|
BP_ZONE("BfModule::Finish");
|
||||||
BfLogSysM("BfModule finish: %p\n", this);
|
BfLogSysM("BfModule finish: %p\n", this);
|
||||||
|
|
||||||
if (mCompiler->mCanceling)
|
|
||||||
{
|
|
||||||
NOP;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mModuleName == "System_Array")
|
|
||||||
{
|
|
||||||
NOP;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mHadBuildError)
|
if (mHadBuildError)
|
||||||
{
|
{
|
||||||
// Don't AssertErrorState here, this current pass may not have failed but
|
// Don't AssertErrorState here, this current pass may not have failed but
|
||||||
|
@ -20558,11 +20523,6 @@ void BfModule::ClearModuleData()
|
||||||
mAddedToCount = false;
|
mAddedToCount = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mCompiler->mCanceling)
|
|
||||||
{
|
|
||||||
NOP;
|
|
||||||
}
|
|
||||||
|
|
||||||
mDICompileUnit = BfIRMDNode();
|
mDICompileUnit = BfIRMDNode();
|
||||||
mIsModuleMutable = false;
|
mIsModuleMutable = false;
|
||||||
mIncompleteMethodCount = 0;
|
mIncompleteMethodCount = 0;
|
||||||
|
@ -20598,18 +20558,6 @@ void BfModule::ClearModuleData()
|
||||||
if (mNextAltModule != NULL)
|
if (mNextAltModule != NULL)
|
||||||
mNextAltModule->ClearModuleData();
|
mNextAltModule->ClearModuleData();
|
||||||
|
|
||||||
for (auto typeInstance : mOwnedTypeInstances)
|
|
||||||
{
|
|
||||||
if (typeInstance->IsSpecializedType())
|
|
||||||
{
|
|
||||||
for (auto&& methodGroup : typeInstance->mMethodInstanceGroups)
|
|
||||||
{
|
|
||||||
if (methodGroup.mDefault != NULL)
|
|
||||||
methodGroup.mDefault->mDeclModule = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
BfLogSysM("ClearModuleData. Deleting IRBuilder: %p\n", mBfIRBuilder);
|
BfLogSysM("ClearModuleData. Deleting IRBuilder: %p\n", mBfIRBuilder);
|
||||||
delete mBfIRBuilder;
|
delete mBfIRBuilder;
|
||||||
mBfIRBuilder = NULL;
|
mBfIRBuilder = NULL;
|
||||||
|
@ -20631,9 +20579,15 @@ void BfModule::DisownMethods()
|
||||||
{
|
{
|
||||||
if (methodGroup.mDefault != NULL)
|
if (methodGroup.mDefault != NULL)
|
||||||
{
|
{
|
||||||
|
if (methodGroup.mDefault->mIRFunction)
|
||||||
|
{
|
||||||
|
BF_ASSERT(methodGroup.mDefault->mDeclModule != NULL);
|
||||||
if (methodGroup.mDefault->mDeclModule == this)
|
if (methodGroup.mDefault->mDeclModule == this)
|
||||||
|
{
|
||||||
methodGroup.mDefault->mIRFunction = BfIRFunction();
|
methodGroup.mDefault->mIRFunction = BfIRFunction();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (methodGroup.mMethodSpecializationMap != NULL)
|
if (methodGroup.mMethodSpecializationMap != NULL)
|
||||||
{
|
{
|
||||||
|
@ -20641,11 +20595,13 @@ void BfModule::DisownMethods()
|
||||||
{
|
{
|
||||||
auto methodInstance = mapPair.mValue;
|
auto methodInstance = mapPair.mValue;
|
||||||
if (methodInstance->mDeclModule == this)
|
if (methodInstance->mDeclModule == this)
|
||||||
|
{
|
||||||
methodInstance->mIRFunction = BfIRFunction();
|
methodInstance->mIRFunction = BfIRFunction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BfModule::ClearModule()
|
void BfModule::ClearModule()
|
||||||
|
|
|
@ -4092,18 +4092,21 @@ void BfModule::AddMethodToWorkList(BfMethodInstance* methodInstance)
|
||||||
methodInstance->mIRFunction = func;
|
methodInstance->mIRFunction = func;
|
||||||
|
|
||||||
module->mFuncReferences[methodInstance] = func;
|
module->mFuncReferences[methodInstance] = func;
|
||||||
if (module != this)
|
|
||||||
{
|
|
||||||
// For extension modules we need to keep track of our own methods so we can know which methods
|
|
||||||
// we have defined ourselves and which are from the parent module or other extensions
|
|
||||||
if (!func.IsFake())
|
|
||||||
mFuncReferences[methodInstance] = func;
|
|
||||||
}
|
|
||||||
|
|
||||||
module->AddMethodToWorkList(methodInstance);
|
module->AddMethodToWorkList(methodInstance);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((!methodInstance->mIRFunction) && (!methodInstance->mIsUnspecialized))
|
||||||
|
{
|
||||||
|
if (!mIsModuleMutable)
|
||||||
|
StartExtension();
|
||||||
|
|
||||||
|
BfIRValue func = CreateFunctionFrom(methodInstance, false, methodInstance->mAlwaysInline);
|
||||||
|
methodInstance->mIRFunction = func;
|
||||||
|
mFuncReferences[methodInstance] = func;
|
||||||
|
}
|
||||||
|
|
||||||
BF_ASSERT(methodInstance->mDeclModule == this);
|
BF_ASSERT(methodInstance->mDeclModule == this);
|
||||||
|
|
||||||
if (defaultMethod == methodInstance)
|
if (defaultMethod == methodInstance)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue