From 88f0780e34116c0441a8d8c58b8a8fd9fde4b1f5 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 25 Jan 2017 15:41:44 +0200 Subject: Add model mutex, make var_pool const by default --- build2/variable.cxx | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'build2/variable.cxx') diff --git a/build2/variable.cxx b/build2/variable.cxx index 48ea8aa..ec72fdc 100644 --- a/build2/variable.cxx +++ b/build2/variable.cxx @@ -906,6 +906,23 @@ namespace build2 // variable_pool // const variable& variable_pool:: + insert (string n) + { + // We are not overriding anything so skip the insert_() checks. + // + auto p ( + insert ( + variable {move (n), nullptr, nullptr, variable_visibility::normal})); + + const variable& r (p.first->second); + + if (r.override != nullptr) + fail << "variable " << r.name << " cannot be overridden"; + + return r; + } + + const variable& variable_pool:: insert (string n, const build2::value_type* t, const variable_visibility* v, @@ -943,16 +960,18 @@ namespace build2 } // Check overridability (all overrides, if any, should already have - // been enetered (see context.cxx:reset()). + // been entered (see context.cxx:reset()). // - if (o != nullptr && r.override != nullptr && !*o) + if (r.override != nullptr && (o == nullptr || !*o)) fail << "variable " << r.name << " cannot be overridden"; } return r; } - variable_pool var_pool; + variable_pool variable_pool::instance; + const variable_pool& variable_pool::cinstance = variable_pool::instance; + const variable_pool& var_pool = variable_pool::cinstance; // variable_map // -- cgit v1.1