diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2017-01-25 15:41:44 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2017-02-13 12:39:24 +0200 |
commit | 88f0780e34116c0441a8d8c58b8a8fd9fde4b1f5 (patch) | |
tree | 1240b36211772479dc1220712e0daed4e35ecd85 /build2/variable.cxx | |
parent | 61aa8e2b4bd7849838c04dc1f421c4760d88319f (diff) |
Add model mutex, make var_pool const by default
Diffstat (limited to 'build2/variable.cxx')
-rw-r--r-- | build2/variable.cxx | 25 |
1 files changed, 22 insertions, 3 deletions
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 // |