diff --git a/IDEHelper/Compiler/BfCompiler.cpp b/IDEHelper/Compiler/BfCompiler.cpp index 4b93745f..c30d970b 100644 --- a/IDEHelper/Compiler/BfCompiler.cpp +++ b/IDEHelper/Compiler/BfCompiler.cpp @@ -1792,7 +1792,8 @@ void BfCompiler::CreateVData(BfVDataModule* bfModule) bool hadRet = false; String entryClassName = project->mStartupObject; - typeDef = mSystem->FindTypeDef(entryClassName, 0, bfModule->mProject); + typeDef = mSystem->FindTypeDef(entryClassName, 0, bfModule->mProject, {}, NULL, BfFindTypeDefFlag_AllowGlobal); + if (typeDef != NULL) { auto type = bfModule->ResolveTypeDef(typeDef); @@ -1911,7 +1912,10 @@ void BfCompiler::CreateVData(BfVDataModule* bfModule) } 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) { String entryClassName = project->mStartupObject; - auto typeDef = mSystem->FindTypeDef(entryClassName, 0, project); + auto typeDef = mSystem->FindTypeDef(entryClassName, 0, project, {}, NULL, BfFindTypeDefFlag_AllowGlobal); if (typeDef != NULL) { typeDef->mIsAlwaysInclude = true; diff --git a/IDEHelper/Compiler/BfSystem.cpp b/IDEHelper/Compiler/BfSystem.cpp index 10ab8c22..54337b48 100644 --- a/IDEHelper/Compiler/BfSystem.cpp +++ b/IDEHelper/Compiler/BfSystem.cpp @@ -2222,7 +2222,7 @@ bool BfSystem::CheckTypeDefReference(BfTypeDef* typeDef, BfProject* project) return project->ContainsReference(typeDef->mProject); } -BfTypeDef* BfSystem::FindTypeDef(const BfAtomComposite& findName, int numGenericArgs, BfProject* project, const Array& namespaceSearch, BfTypeDef** ambiguousTypeDef) +BfTypeDef* BfSystem::FindTypeDef(const BfAtomComposite& findName, int numGenericArgs, BfProject* project, const Array& namespaceSearch, BfTypeDef** ambiguousTypeDef, BfFindTypeDefFlags flags) { if (findName.GetPartsCount() == 1) { @@ -2254,7 +2254,8 @@ BfTypeDef* BfSystem::FindTypeDef(const BfAtomComposite& findName, int numGeneric { BfTypeDef* typeDef = *itr; - if ((typeDef->mIsPartial) || (typeDef->IsGlobalsContainer())) + if ((typeDef->mIsPartial) || + ((typeDef->IsGlobalsContainer()) && ((flags & BfFindTypeDefFlag_AllowGlobal) == 0))) { itr.MoveToNextHashMatch(); continue; @@ -2368,7 +2369,7 @@ bool BfSystem::FindTypeDef(const BfAtomComposite& findName, int numGenericArgs, return hadMatch; } -BfTypeDef* BfSystem::FindTypeDef(const StringImpl& typeName, int numGenericArgs, BfProject* project, const Array& namespaceSearch, BfTypeDef** ambiguousTypeDef) +BfTypeDef* BfSystem::FindTypeDef(const StringImpl& typeName, int numGenericArgs, BfProject* project, const Array& namespaceSearch, BfTypeDef** ambiguousTypeDef, BfFindTypeDefFlags flags) { BfAtomComposite qualifiedFindName; BfAtom* tempData[16]; @@ -2377,7 +2378,7 @@ BfTypeDef* BfSystem::FindTypeDef(const StringImpl& typeName, int numGenericArgs, BfTypeDef* result = NULL; if (ParseAtomComposite(typeName, qualifiedFindName)) - result = FindTypeDef(qualifiedFindName, numGenericArgs, project, namespaceSearch, ambiguousTypeDef); + result = FindTypeDef(qualifiedFindName, numGenericArgs, project, namespaceSearch, ambiguousTypeDef, flags); if (qualifiedFindName.mParts == tempData) qualifiedFindName.mParts = NULL; return result; diff --git a/IDEHelper/Compiler/BfSystem.h b/IDEHelper/Compiler/BfSystem.h index b6faaa93..7b244ed8 100644 --- a/IDEHelper/Compiler/BfSystem.h +++ b/IDEHelper/Compiler/BfSystem.h @@ -1363,6 +1363,12 @@ public: } }; +enum BfFindTypeDefFlags +{ + BfFindTypeDefFlag_None, + BfFindTypeDefFlag_AllowGlobal +}; + class BfSystem { public: @@ -1473,9 +1479,9 @@ public: BfTypeReference* GetTypeRefElement(BfTypeReference* typeRef); BfTypeDef* FilterDeletedTypeDef(BfTypeDef* typeDef); bool CheckTypeDefReference(BfTypeDef* typeDef, BfProject* project); - BfTypeDef* FindTypeDef(const BfAtomComposite& findName, int numGenericArgs = 0, BfProject* project = NULL, const Array& namespaceSearch = Array(), BfTypeDef** ambiguousTypeDef = NULL); + BfTypeDef* FindTypeDef(const BfAtomComposite& findName, int numGenericArgs = 0, BfProject* project = NULL, const Array& namespaceSearch = Array(), BfTypeDef** ambiguousTypeDef = NULL, BfFindTypeDefFlags flags = BfFindTypeDefFlag_None); 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& namespaceSearch = Array(), BfTypeDef** ambiguousTypeDef = NULL); + BfTypeDef* FindTypeDef(const StringImpl& typeName, int numGenericArgs = 0, BfProject* project = NULL, const Array& namespaceSearch = Array(), BfTypeDef** ambiguousTypeDef = NULL, BfFindTypeDefFlags flags = BfFindTypeDefFlag_None); BfTypeDef* FindTypeDef(const StringImpl& typeName, BfProject* project); BfTypeDef* FindTypeDefEx(const StringImpl& typeName); void FindFixitNamespaces(const StringImpl& typeName, int numGenericArgs, BfProject* project, std::set& fixitNamespaces);