aboutsummaryrefslogtreecommitdiff
path: root/build/module
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-07-07 09:18:22 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-07-07 09:18:22 +0200
commit49d5628e35593a5300d39596286c768d7aa435b6 (patch)
tree43f20983a381c54aac7536e78e4f9543d8761aac /build/module
parent16c19b739a58845af7f807c3dee8021a1c421006 (diff)
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.
Diffstat (limited to 'build/module')
-rw-r--r--build/module37
1 files changed, 33 insertions, 4 deletions
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 <map>
#include <string>
-#include <unordered_map>
+#include <memory> // 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<std::string, module_init_function*>;
+ 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<module>&,
+ bool first); // First time for this project.
+
+ using loaded_module_map =
+ std::map<std::string,
+ std::pair<module_init_function*, std::unique_ptr<module>>>;
+
+ // 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<std::string, module_init_function*>;
+ extern available_module_map builtin_modules;
}
#endif // BUILD_MODULE