瀏覽代碼

Moved Main method reification to PopulateReified

Brian Fiete 3 年之前
父節點
當前提交
0df06b9870
共有 1 個文件被更改,包括 48 次插入45 次删除
  1. 48 45
      IDEHelper/Compiler/BfCompiler.cpp

+ 48 - 45
IDEHelper/Compiler/BfCompiler.cpp

@@ -5595,6 +5595,7 @@ int ArrTest()
 
 void BfCompiler::PopulateReified()
 {
+	BfLogSysM("BfCompiler::PopulateReified\n");
 	BP_ZONE("PopulateReified");
 
 	BfContext* context = mContext;
@@ -5864,6 +5865,50 @@ void BfCompiler::PopulateReified()
 			}
 		}
 
+		if (mOptions.mCompileOnDemandKind != BfCompileOnDemandKind_AlwaysInclude)
+		{
+			BfLogSysM("BfCompiler::PopulateReified finding Main\n");
+			for (auto project : mSystem->mProjects)
+			{
+				String entryClassName = project->mStartupObject;
+				auto typeDef = mSystem->FindTypeDef(entryClassName, 0, project, {}, NULL, BfFindTypeDefFlag_AllowGlobal);
+				if (typeDef != NULL)
+				{
+					typeDef->mIsAlwaysInclude = true;
+					auto resolvedType = mContext->mScratchModule->ResolveTypeDef(typeDef);
+					if (resolvedType != NULL)
+					{
+						auto resolvedTypeInst = resolvedType->ToTypeInstance();
+						if (resolvedTypeInst != NULL)
+						{
+							auto module = resolvedTypeInst->GetModule();
+							if (!module->mIsReified)
+								module->ReifyModule();
+							mContext->mScratchModule->PopulateType(resolvedType, BfPopulateType_Full);
+
+							BfMemberSetEntry* memberSetEntry;
+							if (resolvedTypeInst->mTypeDef->mMethodSet.TryGetWith(String("Main"), &memberSetEntry))
+							{
+								BfMethodDef* methodDef = (BfMethodDef*)memberSetEntry->mMemberDef;
+								while (methodDef != NULL)
+								{
+									auto moduleMethodInstance = mContext->mScratchModule->GetMethodInstanceAtIdx(resolvedTypeInst, methodDef->mIdx);
+									auto methodInstance = moduleMethodInstance.mMethodInstance;
+									if (methodInstance->GetParamCount() != 0)
+									{
+										mContext->mScratchModule->GetInternalMethod("CreateParamsArray");
+										mContext->mScratchModule->GetInternalMethod("DeleteStringArray");
+									}
+
+									methodDef = methodDef->mNextWithSameName;
+								}
+							}
+						}
+					}
+				}
+			}
+		}
+
 		BfLogSysM("PopulateReified iteration done\n");
 
 		didWork |= DoWorkLoop(reifiedOnly, reifiedOnly);
@@ -6616,7 +6661,8 @@ void BfCompiler::ClearOldHotData()
 }
 
 void BfCompiler::CompileReified()
-{	
+{
+	BfLogSysM("BfCompiler::CompileReified\n");
 	BP_ZONE("Compile_ResolveTypeDefs");
 
 	Array<BfTypeDef*> deferTypeDefs;
@@ -6695,50 +6741,7 @@ void BfCompiler::CompileReified()
 		if (alwaysInclude)
 			mContext->mScratchModule->PopulateType(typeInst, BfPopulateType_Full);
 	}
-	
-	if (mOptions.mCompileOnDemandKind != BfCompileOnDemandKind_AlwaysInclude)
-	{
-		for (auto project : mSystem->mProjects)
-		{
-			String entryClassName = project->mStartupObject;
-			auto typeDef = mSystem->FindTypeDef(entryClassName, 0, project, {}, NULL, BfFindTypeDefFlag_AllowGlobal);
-			if (typeDef != NULL)
-			{
-				typeDef->mIsAlwaysInclude = true;
-				auto resolvedType = mContext->mScratchModule->ResolveTypeDef(typeDef);
-				if (resolvedType != NULL)
-				{
-					auto resolvedTypeInst = resolvedType->ToTypeInstance();
-					if (resolvedTypeInst != NULL)
-					{
-						auto module = resolvedTypeInst->GetModule();
-						if (!module->mIsReified)
-							module->ReifyModule();
-						mContext->mScratchModule->PopulateType(resolvedType, BfPopulateType_Full);
-
-						BfMemberSetEntry* memberSetEntry;
-						if (resolvedTypeInst->mTypeDef->mMethodSet.TryGetWith(String("Main"), &memberSetEntry))
-						{
-							BfMethodDef* methodDef = (BfMethodDef*)memberSetEntry->mMemberDef;
-							while (methodDef != NULL)
-							{
-								auto moduleMethodInstance = mContext->mScratchModule->GetMethodInstanceAtIdx(resolvedTypeInst, methodDef->mIdx);
-								auto methodInstance = moduleMethodInstance.mMethodInstance;
-								if (methodInstance->GetParamCount() != 0)
-								{
-									mContext->mScratchModule->GetInternalMethod("CreateParamsArray");
-									mContext->mScratchModule->GetInternalMethod("DeleteStringArray");
-								}
-								
-								methodDef = methodDef->mNextWithSameName;
-							}
-						}						
-					}
-				}
-			}
-		}
-	}
-
+		
 	PopulateReified();	
 }