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/rule-map | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 build/rule-map (limited to 'build/rule-map') diff --git a/build/rule-map b/build/rule-map new file mode 100644 index 0000000..883800b --- /dev/null +++ b/build/rule-map @@ -0,0 +1,46 @@ +// file : build/rule-map -*- C++ -*- +// copyright : Copyright (c) 2014-2015 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#ifndef BUILD_RULE_MAP +#define BUILD_RULE_MAP + +#include +#include +#include +#include +#include // reference_wrapper + +#include + +#include +#include + +namespace build +{ + class rule; + + using target_type_rule_map = std::map< + std::type_index, // Target type. + butl::prefix_map, '.'>>; + + // This is an "indexed map" with (operation_id - 1) being the + // index. + // + class rule_map: public std::vector + { + public: + template + void + insert (operation_id oid, const char* hint, rule& r) + { + if (oid > size ()) + resize (oid < 3 ? 3 : oid); // 3 is the number of builtin operations. + + (*this)[oid - 1][typeid (T)].emplace (hint, r); + } + }; +} + +#endif // BUILD_RULE_MAP -- cgit v1.1