mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 19:48:20 +02:00
Added ability to put Main method in an anonymous static section
This commit is contained in:
parent
9a7bb95107
commit
125f7b85a7
3 changed files with 20 additions and 9 deletions
|
@ -1792,7 +1792,8 @@ void BfCompiler::CreateVData(BfVDataModule* bfModule)
|
||||||
bool hadRet = false;
|
bool hadRet = false;
|
||||||
|
|
||||||
String entryClassName = project->mStartupObject;
|
String entryClassName = project->mStartupObject;
|
||||||
typeDef = mSystem->FindTypeDef(entryClassName, 0, bfModule->mProject);
|
typeDef = mSystem->FindTypeDef(entryClassName, 0, bfModule->mProject, {}, NULL, BfFindTypeDefFlag_AllowGlobal);
|
||||||
|
|
||||||
if (typeDef != NULL)
|
if (typeDef != NULL)
|
||||||
{
|
{
|
||||||
auto type = bfModule->ResolveTypeDef(typeDef);
|
auto type = bfModule->ResolveTypeDef(typeDef);
|
||||||
|
@ -1911,7 +1912,10 @@ void BfCompiler::CreateVData(BfVDataModule* bfModule)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mPassInstance->Fail(StrFormat("Unable to find Main method in class '%s'", entryClassName.c_str()));
|
if (entryClassName.IsEmpty())
|
||||||
|
mPassInstance->Fail("Unable to find Main method in global namespace. Consider specifying a Startup Object in the project properties.");
|
||||||
|
else
|
||||||
|
mPassInstance->Fail(StrFormat("Unable to find Main method in specified Startup Object '%s'", entryClassName.c_str()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6171,7 +6175,7 @@ void BfCompiler::CompileReified()
|
||||||
for (auto project : mSystem->mProjects)
|
for (auto project : mSystem->mProjects)
|
||||||
{
|
{
|
||||||
String entryClassName = project->mStartupObject;
|
String entryClassName = project->mStartupObject;
|
||||||
auto typeDef = mSystem->FindTypeDef(entryClassName, 0, project);
|
auto typeDef = mSystem->FindTypeDef(entryClassName, 0, project, {}, NULL, BfFindTypeDefFlag_AllowGlobal);
|
||||||
if (typeDef != NULL)
|
if (typeDef != NULL)
|
||||||
{
|
{
|
||||||
typeDef->mIsAlwaysInclude = true;
|
typeDef->mIsAlwaysInclude = true;
|
||||||
|
|
|
@ -2222,7 +2222,7 @@ bool BfSystem::CheckTypeDefReference(BfTypeDef* typeDef, BfProject* project)
|
||||||
return project->ContainsReference(typeDef->mProject);
|
return project->ContainsReference(typeDef->mProject);
|
||||||
}
|
}
|
||||||
|
|
||||||
BfTypeDef* BfSystem::FindTypeDef(const BfAtomComposite& findName, int numGenericArgs, BfProject* project, const Array<BfAtomComposite>& namespaceSearch, BfTypeDef** ambiguousTypeDef)
|
BfTypeDef* BfSystem::FindTypeDef(const BfAtomComposite& findName, int numGenericArgs, BfProject* project, const Array<BfAtomComposite>& namespaceSearch, BfTypeDef** ambiguousTypeDef, BfFindTypeDefFlags flags)
|
||||||
{
|
{
|
||||||
if (findName.GetPartsCount() == 1)
|
if (findName.GetPartsCount() == 1)
|
||||||
{
|
{
|
||||||
|
@ -2254,7 +2254,8 @@ BfTypeDef* BfSystem::FindTypeDef(const BfAtomComposite& findName, int numGeneric
|
||||||
{
|
{
|
||||||
BfTypeDef* typeDef = *itr;
|
BfTypeDef* typeDef = *itr;
|
||||||
|
|
||||||
if ((typeDef->mIsPartial) || (typeDef->IsGlobalsContainer()))
|
if ((typeDef->mIsPartial) ||
|
||||||
|
((typeDef->IsGlobalsContainer()) && ((flags & BfFindTypeDefFlag_AllowGlobal) == 0)))
|
||||||
{
|
{
|
||||||
itr.MoveToNextHashMatch();
|
itr.MoveToNextHashMatch();
|
||||||
continue;
|
continue;
|
||||||
|
@ -2368,7 +2369,7 @@ bool BfSystem::FindTypeDef(const BfAtomComposite& findName, int numGenericArgs,
|
||||||
return hadMatch;
|
return hadMatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
BfTypeDef* BfSystem::FindTypeDef(const StringImpl& typeName, int numGenericArgs, BfProject* project, const Array<BfAtomComposite>& namespaceSearch, BfTypeDef** ambiguousTypeDef)
|
BfTypeDef* BfSystem::FindTypeDef(const StringImpl& typeName, int numGenericArgs, BfProject* project, const Array<BfAtomComposite>& namespaceSearch, BfTypeDef** ambiguousTypeDef, BfFindTypeDefFlags flags)
|
||||||
{
|
{
|
||||||
BfAtomComposite qualifiedFindName;
|
BfAtomComposite qualifiedFindName;
|
||||||
BfAtom* tempData[16];
|
BfAtom* tempData[16];
|
||||||
|
@ -2377,7 +2378,7 @@ BfTypeDef* BfSystem::FindTypeDef(const StringImpl& typeName, int numGenericArgs,
|
||||||
|
|
||||||
BfTypeDef* result = NULL;
|
BfTypeDef* result = NULL;
|
||||||
if (ParseAtomComposite(typeName, qualifiedFindName))
|
if (ParseAtomComposite(typeName, qualifiedFindName))
|
||||||
result = FindTypeDef(qualifiedFindName, numGenericArgs, project, namespaceSearch, ambiguousTypeDef);
|
result = FindTypeDef(qualifiedFindName, numGenericArgs, project, namespaceSearch, ambiguousTypeDef, flags);
|
||||||
if (qualifiedFindName.mParts == tempData)
|
if (qualifiedFindName.mParts == tempData)
|
||||||
qualifiedFindName.mParts = NULL;
|
qualifiedFindName.mParts = NULL;
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -1363,6 +1363,12 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum BfFindTypeDefFlags
|
||||||
|
{
|
||||||
|
BfFindTypeDefFlag_None,
|
||||||
|
BfFindTypeDefFlag_AllowGlobal
|
||||||
|
};
|
||||||
|
|
||||||
class BfSystem
|
class BfSystem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -1473,9 +1479,9 @@ public:
|
||||||
BfTypeReference* GetTypeRefElement(BfTypeReference* typeRef);
|
BfTypeReference* GetTypeRefElement(BfTypeReference* typeRef);
|
||||||
BfTypeDef* FilterDeletedTypeDef(BfTypeDef* typeDef);
|
BfTypeDef* FilterDeletedTypeDef(BfTypeDef* typeDef);
|
||||||
bool CheckTypeDefReference(BfTypeDef* typeDef, BfProject* project);
|
bool CheckTypeDefReference(BfTypeDef* typeDef, BfProject* project);
|
||||||
BfTypeDef* FindTypeDef(const BfAtomComposite& findName, int numGenericArgs = 0, BfProject* project = NULL, const Array<BfAtomComposite>& namespaceSearch = Array<BfAtomComposite>(), BfTypeDef** ambiguousTypeDef = NULL);
|
BfTypeDef* FindTypeDef(const BfAtomComposite& findName, int numGenericArgs = 0, BfProject* project = NULL, const Array<BfAtomComposite>& namespaceSearch = Array<BfAtomComposite>(), BfTypeDef** ambiguousTypeDef = NULL, BfFindTypeDefFlags flags = BfFindTypeDefFlag_None);
|
||||||
bool FindTypeDef(const BfAtomComposite& findName, int numGenericArgs, BfProject* project, const BfAtomComposite& checkNamespace, bool allowPrivate, BfTypeDefLookupContext* ctx);
|
bool FindTypeDef(const BfAtomComposite& findName, int numGenericArgs, BfProject* project, const BfAtomComposite& checkNamespace, bool allowPrivate, BfTypeDefLookupContext* ctx);
|
||||||
BfTypeDef* FindTypeDef(const StringImpl& typeName, int numGenericArgs = 0, BfProject* project = NULL, const Array<BfAtomComposite>& namespaceSearch = Array<BfAtomComposite>(), BfTypeDef** ambiguousTypeDef = NULL);
|
BfTypeDef* FindTypeDef(const StringImpl& typeName, int numGenericArgs = 0, BfProject* project = NULL, const Array<BfAtomComposite>& namespaceSearch = Array<BfAtomComposite>(), BfTypeDef** ambiguousTypeDef = NULL, BfFindTypeDefFlags flags = BfFindTypeDefFlag_None);
|
||||||
BfTypeDef* FindTypeDef(const StringImpl& typeName, BfProject* project);
|
BfTypeDef* FindTypeDef(const StringImpl& typeName, BfProject* project);
|
||||||
BfTypeDef* FindTypeDefEx(const StringImpl& typeName);
|
BfTypeDef* FindTypeDefEx(const StringImpl& typeName);
|
||||||
void FindFixitNamespaces(const StringImpl& typeName, int numGenericArgs, BfProject* project, std::set<String>& fixitNamespaces);
|
void FindFixitNamespaces(const StringImpl& typeName, int numGenericArgs, BfProject* project, std::set<String>& fixitNamespaces);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue