From 7882632e9338fd1ce7de04d790b495826e49d4b1 Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Thu, 17 Oct 2019 05:31:57 -0700 Subject: [PATCH] Changed ProgramStart/ProgramEnd to ensure StaticInits get called --- IDE/src/Debugger/DebugManager.bf | 8 -------- IDE/src/IDEApp.bf | 7 +++++++ IDE/src/Program.bf | 2 +- IDEHelper/Compiler/BfDefBuilder.cpp | 9 ++++----- IDEHelper/Compiler/BfSystem.cpp | 1 - IDEHelper/DebugManager.cpp | 11 +++++++---- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/IDE/src/Debugger/DebugManager.bf b/IDE/src/Debugger/DebugManager.bf index 8979d0a1..4242fdde 100644 --- a/IDE/src/Debugger/DebugManager.bf +++ b/IDE/src/Debugger/DebugManager.bf @@ -118,9 +118,6 @@ namespace IDE.Debugger [StdCall,CLink] static extern void Debugger_Delete(); - [StdCall,CLink] - static extern void Debugger_ProgramDone(); - [StdCall,CLink] static extern int32 Debugger_GetAddrSize(); @@ -398,11 +395,6 @@ namespace IDE.Debugger Debugger_LoadDebugVisualizers(fileName); } - public static void ProgramDone() - { - Debugger_ProgramDone(); - } - public void FullReportMemory() { Debugger_FullReportMemory(); diff --git a/IDE/src/IDEApp.bf b/IDE/src/IDEApp.bf index 472ff67c..5508d849 100644 --- a/IDE/src/IDEApp.bf +++ b/IDE/src/IDEApp.bf @@ -498,12 +498,19 @@ namespace IDE } } + [StdCall,CLink] + static extern void IDEHelper_ProgramStart(); + [StdCall,CLink] + static extern void IDEHelper_ProgramDone(); + public this() { sApp = this; gApp = this; mMainThread = Thread.CurrentThread; + IDEHelper_ProgramStart(); + #if !CLI mDebugger = new DebugManager(); mVerb = .OpenOrNew; diff --git a/IDE/src/Program.bf b/IDE/src/Program.bf index d9451763..46cce0e8 100644 --- a/IDE/src/Program.bf +++ b/IDE/src/Program.bf @@ -52,7 +52,7 @@ namespace A0 { static ~this() { - IDE.Debugger.DebugManager.ProgramDone(); + IDE.IDEApp.[Friend]IDEHelper_ProgramDone(); #if BF_PLATFORM_WINDOWS if (IDE.IDEApp.sExitTest) diff --git a/IDEHelper/Compiler/BfDefBuilder.cpp b/IDEHelper/Compiler/BfDefBuilder.cpp index 762c9732..ef00c03d 100644 --- a/IDEHelper/Compiler/BfDefBuilder.cpp +++ b/IDEHelper/Compiler/BfDefBuilder.cpp @@ -1364,11 +1364,9 @@ void BfDefBuilder::Visit(BfTypeDeclaration* typeDeclaration) numGenericParams = (int)typeDeclaration->mGenericParams->mGenericParams.size(); if (outerTypeDef != NULL) numGenericParams += (int)outerTypeDef->mGenericParamDefs.size(); - - BfLogSys(mCurSource->mSystem, "DefBuilder %p Hash:%d isAutoComplete:%d\n", mCurTypeDef, mSystem->mTypeDefs.GetHash(mCurTypeDef), isAutoCompleteTempType); - + if (!isAutoCompleteTempType) - { + { BfTypeDef* prevDef = NULL; // auto checkTypeDef = mSystem->mTypeDefs.Find(fullName); @@ -1466,7 +1464,8 @@ void BfDefBuilder::Visit(BfTypeDeclaration* typeDeclaration) outerTypeDef->mNestedTypes.push_back(mCurActualTypeDef); } - BfLogSysM("Creating TypeDef %p from TypeDecl: %p Source: %p ResolvePass: %d\n", mCurTypeDef, typeDeclaration, typeDeclaration->GetSourceData(), mResolvePassData != NULL); + BfLogSysM("Creating TypeDef %p Hash:%d from TypeDecl: %p Source: %p ResolvePass: %d AutoComplete:%d\n", mCurTypeDef, mSystem->mTypeDefs.GetHash(mCurTypeDef), typeDeclaration, + typeDeclaration->GetSourceData(), mResolvePassData != NULL, isAutoCompleteTempType); mCurTypeDef->mSource = mCurSource; mCurTypeDef->mSource->mRefCount++; diff --git a/IDEHelper/Compiler/BfSystem.cpp b/IDEHelper/Compiler/BfSystem.cpp index a8248ea6..f4399c89 100644 --- a/IDEHelper/Compiler/BfSystem.cpp +++ b/IDEHelper/Compiler/BfSystem.cpp @@ -3813,4 +3813,3 @@ BF_EXPORT void BF_CALLTYPE BfSystem_FixTypes(BfSystem* bfSystem) fixTypesHelper.mBfSystem = bfSystem; fixTypesHelper.Fix(); } - diff --git a/IDEHelper/DebugManager.cpp b/IDEHelper/DebugManager.cpp index 8388b4cc..9e772e5a 100644 --- a/IDEHelper/DebugManager.cpp +++ b/IDEHelper/DebugManager.cpp @@ -629,9 +629,7 @@ BF_EXPORT void BF_CALLTYPE Debugger_Create() //_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_CHECK_EVERY_16_DF); //TODO: _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF /*| _CRTDBG_CHECK_EVERY_16_DF*/); //_CrtSetAllocHook(BfAllocHook); - - BfIRCodeGen::StaticInit(); - + #ifdef BF_PLATFORM_WINDOWS _CrtMemCheckpoint(&gStartMemCheckpoint); #endif @@ -683,7 +681,12 @@ BF_EXPORT void BF_CALLTYPE Debugger_Delete() #endif } -BF_EXPORT void BF_CALLTYPE Debugger_ProgramDone() +BF_EXPORT void BF_CALLTYPE IDEHelper_ProgramStart() +{ + BfIRCodeGen::StaticInit(); +} + +BF_EXPORT void BF_CALLTYPE IDEHelper_ProgramDone() { //TODO: //::MessageBoxA(NULL, "Done", "Done", MB_OK);