mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 03:28:20 +02:00
Moved Main method reification to PopulateReified
This commit is contained in:
parent
9972ff32ab
commit
0df06b9870
1 changed files with 48 additions and 45 deletions
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue