aboutsummaryrefslogtreecommitdiff
path: root/build2/scope.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-02-10 17:28:40 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-02-13 12:42:42 +0200
commit62f962ec68435f6acade5769335153ffb90aad69 (patch)
tree0c3e95ebca03969faa692d2a5fdb9199f886886c /build2/scope.cxx
parent1821a11704143a89581b26e285d968230b86a8ac (diff)
Some ground work for proper variable cache implementation
Diffstat (limited to 'build2/scope.cxx')
-rw-r--r--build2/scope.cxx13
1 files changed, 10 insertions, 3 deletions
diff --git a/build2/scope.cxx b/build2/scope.cxx
index aaa0077..6f21636 100644
--- a/build2/scope.cxx
+++ b/build2/scope.cxx
@@ -53,7 +53,8 @@ namespace build2
//
// @@ MT
//
- value& cache (s->target_vars.cache[make_tuple (&v, tt, *tn)]);
+ variable_map::value_data& cache (
+ s->target_vars.cache[make_tuple (&v, tt, *tn)]);
// Un-typify the cache. This can be necessary, for example, if we are
// changing from one value-typed stem to another.
@@ -185,7 +186,7 @@ namespace build2
//
// We also keep track of the root scope of the project from which this
// innermost value comes. This is used to decide whether a non-recursive
- // project-wise override applies.
+ // project-wise override applies. And also where our variable cache is.
//
const variable_map* inner_vars (nullptr);
const scope* inner_proj (nullptr);
@@ -303,7 +304,7 @@ namespace build2
if (inner_vars == nullptr)
{
inner_vars = l.vars;
- inner_proj = s->root_scope (); // Not actually used.
+ inner_proj = s->root_scope ();
}
apply = true;
@@ -322,6 +323,12 @@ namespace build2
assert (inner_vars != nullptr);
+ // If for some reason we are not in a project, use the cache from the
+ // global scope.
+ //
+ if (inner_proj == nullptr)
+ inner_proj = global_scope;
+
// Implementing proper caching is tricky so for now we are going to re-
// calculate the value every time. Later, the plan is to use value
// versioning (incremented on every update) to detect stem value changes.