aboutsummaryrefslogtreecommitdiff
path: root/build/rule-map
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/rule-map
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/rule-map')
-rw-r--r--build/rule-map46
1 files changed, 46 insertions, 0 deletions
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 <map>
+#include <vector>
+#include <string>
+#include <typeindex>
+#include <functional> // reference_wrapper
+
+#include <butl/prefix-map>
+
+#include <build/types>
+#include <build/operation>
+
+namespace build
+{
+ class rule;
+
+ using target_type_rule_map = std::map<
+ std::type_index, // Target type.
+ butl::prefix_map<std::string, // Rule hint.
+ std::reference_wrapper<rule>, '.'>>;
+
+ // This is an "indexed map" with (operation_id - 1) being the
+ // index.
+ //
+ class rule_map: public std::vector<target_type_rule_map>
+ {
+ public:
+ template <typename T>
+ 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