diff --git a/src/Lib/Script/CRTPLuaScriptObject.cc b/src/Lib/Script/CRTPLuaScriptObject.cc index 49889be706020830df0555093798eb43ffe3ceb6..d7dd9ac53aa5f74964eb46896fcea9f3efcf43a7 100644 --- a/src/Lib/Script/CRTPLuaScriptObject.cc +++ b/src/Lib/Script/CRTPLuaScriptObject.cc @@ -17,6 +17,21 @@ FreeFunctions::print(lua_State *L) noexcept // ModuleDeclaration +bool +ModuleDeclaration::resolvModules(LuaContext *const context) noexcept +{ + for (const auto &str : importNames) { + const ModuleDeclaration *const mod = context->getModule(str); + if (mod) { + importedModules.emplace_back(mod); + } else { + context->setFailed("Failed to find needed module: " + str); + return false; + } + } + return true; +} + int ModuleDeclaration::setName(lua_State *const L) noexcept { @@ -184,7 +199,8 @@ ModuleDeclaration::validateModule(lua_State *const L) const noexcept for (const auto &str : unusedImports) listStrImports += " " + str; - context->setFailed("There are imported modules that are used without being declared:" + + context->setFailed("There are imported modules that are " + "used without being declared:" + listStrImports + "\n"); return false; } diff --git a/src/Lib/Script/CRTPLuaScriptObject.hh b/src/Lib/Script/CRTPLuaScriptObject.hh index 5f717f7b5dac8c67c630b6d4df3f62f1c02ea8ad..1c09bc203862bca3f00dd6b53c501c725b154fe3 100644 --- a/src/Lib/Script/CRTPLuaScriptObject.hh +++ b/src/Lib/Script/CRTPLuaScriptObject.hh @@ -250,6 +250,7 @@ script_class (ModuleDeclaration) { // Will be resolved later std::vector<std::string> importNames{}; + std::vector<const ModuleDeclaration *> importedModules{}; bool validateModule(lua_State *const) const noexcept; @@ -262,6 +263,8 @@ public: std::vector<OptionDeclaration *> moduleOptions{}; std::vector<FunctionDeclaration *> moduleFunctions{}; std::vector<JobDeclaration *> moduleJobs{}; + + bool resolvModules(LuaContext *const) noexcept; }; // Holds all the free functions (well, not really free functions here...)