Brian Fiete 3 роки тому
батько
коміт
4f83b61a10

+ 8 - 0
IDE/src/Compiler/BfCompiler.bf

@@ -76,6 +76,9 @@ namespace IDE.Compiler
 		[CallingConvention(.Stdcall), CLink]
 		static extern int32 BfCompiler_GetCurConstEvalExecuteId(void* bfCompiler);
 
+		[CallingConvention(.Stdcall), CLink]
+		static extern bool BfCompiler_GetLastHadComptimeRebuilds(void* bfCompiler);
+
         [CallingConvention(.Stdcall), CLink]
         static extern void BfCompiler_Delete(void* bfCompiler);
 
@@ -834,5 +837,10 @@ namespace IDE.Compiler
 				}
 			}
 		}
+
+		public bool GetLastHadComptimeRebuilds()
+		{
+			return BfCompiler_GetLastHadComptimeRebuilds(mNativeBfCompiler);
+		}
     }
 }

+ 1 - 5
IDE/src/IDEApp.bf

@@ -9168,11 +9168,7 @@ namespace IDE
 			if (lastCompileHadMessages)
 				doCompile = true;
 
-			bool needsComptime = true;
-			for (var project in mWorkspace.mProjects)
-			{
-				//Set needsComptime
-			}
+			bool needsComptime = bfCompiler.GetLastHadComptimeRebuilds();
 
 			if ((!workspaceOptions.mIncrementalBuild) && (!lastCompileHadMessages))
 			{

+ 13 - 0
IDEHelper/Compiler/BfCompiler.cpp

@@ -360,6 +360,8 @@ BfCompiler::BfCompiler(BfSystem* bfSystem, bool isResolveOnly)
 	//mMaxInterfaceSlots = 16;
 	mMaxInterfaceSlots = -1;
 	mInterfaceSlotCountChanged = false;
+	mLastHadComptimeRebuilds = false;
+	mHasComptimeRebuilds = false;
 	
 	mHSPreserveIdx = 0;
 	mCompileLogFP = NULL;
@@ -6561,6 +6563,7 @@ bool BfCompiler::DoCompile(const StringImpl& outputDirectory)
 
 	// Inc revision for next run through Compile
 	mRevision++;
+	mHasComptimeRebuilds = false;
 	int revision = mRevision;
 	BfLogSysM("Compile Start. Revision: %d. HasParser:%d AutoComplete:%d\n", revision, 
 		(mResolvePassData != NULL) && (mResolvePassData->mParser != NULL), 
@@ -7494,6 +7497,11 @@ bool BfCompiler::DoCompile(const StringImpl& outputDirectory)
 		return false;
 	}
 
+	if (didCancel)
+		mLastHadComptimeRebuilds = mHasComptimeRebuilds || mLastHadComptimeRebuilds;
+	else
+		mLastHadComptimeRebuilds = mHasComptimeRebuilds;
+
 	return !didCancel && !mHasQueuedTypeRebuilds;
 }
 
@@ -9081,6 +9089,11 @@ BF_EXPORT int BF_CALLTYPE BfCompiler_GetCurConstEvalExecuteId(BfCompiler* bfComp
 	return bfCompiler->mCEMachine->mExecuteId;
 }
 
+BF_EXPORT float BF_CALLTYPE BfCompiler_GetLastHadComptimeRebuilds(BfCompiler* bfCompiler)
+{
+	return bfCompiler->mLastHadComptimeRebuilds;
+}
+
 BF_EXPORT void BF_CALLTYPE BfCompiler_Cancel(BfCompiler* bfCompiler)
 {
 	bfCompiler->Cancel();

+ 3 - 1
IDEHelper/Compiler/BfCompiler.h

@@ -328,7 +328,9 @@ public:
 	bool mFastFinish;
 	bool mHasQueuedTypeRebuilds; // Infers we had a fast finish that requires a type rebuild
 	bool mHadCancel;
-	bool mWantsDeferMethodDecls;		
+	bool mWantsDeferMethodDecls;
+	bool mLastHadComptimeRebuilds;
+	bool mHasComptimeRebuilds;
 	bool mInInvalidState;
 	float mCompletionPct;
 	int mHSPreserveIdx;

+ 1 - 0
IDEHelper/Compiler/BfContext.cpp

@@ -1947,6 +1947,7 @@ void BfContext::UpdateRevisedTypes()
 
 			for (auto& kv : typeInst->mCeTypeInfo->mRebuildMap)
 			{
+				mCompiler->mHasComptimeRebuilds = true;
 				if (kv.mKey.mKind == CeRebuildKey::Kind_File)
 				{
 					String* keyPtr = NULL;

+ 1 - 0
IDEHelper/Compiler/CeMachine.cpp

@@ -3031,6 +3031,7 @@ void CeContext::AddRebuild(const CeRebuildKey& key, const CeRebuildValue& value)
 	if (mCurModule->mCurTypeInstance->mCeTypeInfo == NULL)
 		mCurModule->mCurTypeInstance->mCeTypeInfo = new BfCeTypeInfo();
 	mCurModule->mCurTypeInstance->mCeTypeInfo->mRebuildMap[key] = value;
+	mCurModule->mCompiler->mHasComptimeRebuilds = true;
 }
 
 uint8* CeContext::CeMalloc(int size)

+ 3 - 1
IDEHelper/Tests/src/Comptime.bf

@@ -231,7 +231,8 @@ namespace Tests
 		}
 
 		const String cTest0 = Compiler.ReadText("Test0.txt");
-
+		const uint8[?] cTest0Binary = Compiler.ReadBinary("Test0.txt");
+		
 		[Test]
 		public static void TestBasics()
 		{
@@ -274,6 +275,7 @@ namespace Tests
 			Test.Assert(serCtx.mStr == "x 10\ny 2\n");
 
 			Test.Assert(cTest0 == "Test\n0");
+			Test.Assert((cTest0Binary[0] == (.)'T') && ((cTest0Binary.Count == 6) || (cTest0Binary.Count == 7)));
 		}
 	}
 }