aboutsummaryrefslogtreecommitdiff
path: root/build2/context.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-02-01 16:36:24 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-02-13 12:42:41 +0200
commite3e597180487328a54721e2afb95e33ed853d586 (patch)
tree89d59f482d41eb37a90f97b0dd55c2e878e4800b /build2/context.cxx
parent1dd17210b76d544a04fc6b4f3c98162ae9718102 (diff)
Pass const scope& where modification should not happen
Diffstat (limited to 'build2/context.cxx')
-rw-r--r--build2/context.cxx22
1 files changed, 13 insertions, 9 deletions
diff --git a/build2/context.cxx b/build2/context.cxx
index 466db0d..e15294a 100644
--- a/build2/context.cxx
+++ b/build2/context.cxx
@@ -71,13 +71,14 @@ namespace build2
l6 ([&]{trace << "resetting build state";});
auto& vp (variable_pool::instance);
+ auto& sm (scope_map::instance);
variable_overrides vos;
var_override_cache.clear ();
targets.clear ();
- scopes.clear ();
+ sm.clear ();
vp.clear ();
// Reset meta/operation tables. Note that the order should match the id
@@ -101,13 +102,16 @@ namespace build2
// Create global scope. Note that the empty path is a prefix for any other
// path. See the comment in <butl/prefix-map> for details.
//
+ auto make_global_scope = [&sm] () -> scope&
{
- auto i (scopes.insert (dir_path (), false));
- global_scope = &i->second;
- global_scope->out_path_ = &i->first;
- }
+ auto i (sm.insert (dir_path (), false));
+ scope& r (i->second);
+ r.out_path_ = &i->first;
+ global_scope = scope::global_ = &r;
+ return r;
+ };
- scope& gs (*global_scope);
+ scope& gs (make_global_scope ());
// Parse and enter the command line variables. We do it before entering
// any other variables so that all the variables that are overriden are
@@ -215,7 +219,7 @@ namespace build2
//
if (c == '!' || !dir.empty ())
{
- scope& s (c == '!' ? gs : scopes.insert (dir, false)->second);
+ scope& s (c == '!' ? gs : sm.insert (dir, false)->second);
auto p (s.vars.insert (*o));
if (!p.second)
@@ -377,14 +381,14 @@ namespace build2
}
dir_path
- src_out (const dir_path& out, scope& r)
+ src_out (const dir_path& out, const scope& r)
{
assert (r.root ());
return src_out (out, r.out_path (), r.src_path ());
}
dir_path
- out_src (const dir_path& src, scope& r)
+ out_src (const dir_path& src, const scope& r)
{
assert (r.root ());
return out_src (src, r.out_path (), r.src_path ());