From c24713ac104512df6238c97747ebd6698160beb7 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Thu, 19 Sep 2024 16:16:44 +0200 Subject: [PATCH] Type#GetLoadDependencies(): VERIFY() that no nullptr is returned --- tools/mkclass/classcompiler.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/tools/mkclass/classcompiler.cpp b/tools/mkclass/classcompiler.cpp index 0a6596078..f85719ac5 100644 --- a/tools/mkclass/classcompiler.cpp +++ b/tools/mkclass/classcompiler.cpp @@ -381,14 +381,25 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo&) m_Impl << "const std::unordered_set& TypeImpl<" << klass.Name << ">::GetLoadDependencies() const" << std::endl << "{" << std::endl - << "\tstatic const std::unordered_set deps ({" << std::endl; + << "\tstatic const auto deps ([] {" << std::endl; + + for (auto& dep : klass.LoadDependencies) + m_Impl << "\t\tauto type" << dep << " (GetByName(\"" << dep << "\").get());" << std::endl; + + m_Impl << std::endl; + + for (auto& dep : klass.LoadDependencies) + m_Impl << "\t\tVERIFY(type" << dep << ");" << std::endl; + + m_Impl << std::endl + << "\t\treturn std::unordered_set{"; for (const std::string& dep : klass.LoadDependencies) - m_Impl << "\t\tGetByName(\"" << dep << "\").get()," << std::endl; + m_Impl << " type" << dep << ","; - m_Impl << "\t});" << std::endl; - - m_Impl << "\treturn deps;" << std::endl + m_Impl << " };" << std::endl + << "\t}());" << std::endl << std::endl + << "\treturn deps;" << std::endl << "}" << std::endl << std::endl; } @@ -1465,6 +1476,7 @@ void ClassCompiler::CompileStream(const std::string& path, std::istream& input, << "#include \"base/objectlock.hpp\"" << std::endl << "#include \"base/utility.hpp\"" << std::endl << "#include \"base/convert.hpp\"" << std::endl + << "#include \"base/debug.hpp\"" << std::endl << "#include \"base/dependencygraph.hpp\"" << std::endl << "#include \"base/logger.hpp\"" << std::endl << "#include \"base/function.hpp\"" << std::endl