From 49d5628e35593a5300d39596286c768d7aa435b6 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 7 Jul 2015 09:18:22 +0200 Subject: Rework module architecture Now the target type and rule maps are in scopes (builtins -- in global scope). We also now have the map of loaded modules in the root scope of each project. --- build/module | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) (limited to 'build/module') diff --git a/build/module b/build/module index 54a202c..43ab1e0 100644 --- a/build/module +++ b/build/module @@ -5,18 +5,47 @@ #ifndef BUILD_MODULE #define BUILD_MODULE +#include #include -#include +#include // unique_ptr namespace build { class scope; class location; - using module_init_function = void (scope& root, scope& base, const location&); - using module_map = std::unordered_map; + class module + { + public: + virtual + ~module () = default; + }; - extern module_map modules; + extern "C" + using module_init_function = + void (scope& root, + scope& base, + const location&, + std::unique_ptr&, + bool first); // First time for this project. + + using loaded_module_map = + std::map>>; + + // Load the specified module. Used by the parser but also by some + // modules to load prerequisite modules. + // + void + load_module (const std::string& name, + scope& root, + scope& base, + const location&); + + // Builtin modules. + // + using available_module_map = std::map; + extern available_module_map builtin_modules; } #endif // BUILD_MODULE -- cgit v1.1