From 721835d4dd0fe306e4b55d425f9360fac592eace Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 3 Dec 2017 13:58:28 +0200 Subject: Allow typification of variables and values across load generations The original semantics turned out to be too restrictive. For example, the user may have specified the config.c variable on the command line that is only used by an imported project that is loaded in a subsequent generation. We are also relaxing it for values since conceptually the two feel the same. For a value the (hypothetical) example is a "common" variable set in a project root that is only queried in a subdirectory in a subsequent generation. --- build2/variable.cxx | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) (limited to 'build2/variable.cxx') diff --git a/build2/variable.cxx b/build2/variable.cxx index 1afa872..8d9aa14 100644 --- a/build2/variable.cxx +++ b/build2/variable.cxx @@ -1016,16 +1016,6 @@ namespace build2 bool ut (t != nullptr && var.type != t); bool uv (v != nullptr && var.visibility != *v); - // In the global pool existing variables can only be updated during the - // same load generation or during serial execution. - // - if (global_ && - load_generation != 0 && - load_generation != var.generation && - (ut || uv)) - fail << "variable " << var.name << " already defined with different " - << (ut ? (uv ? "type and visibility" : "type") : "visibility"); - // Update type? // if (ut) @@ -1141,8 +1131,7 @@ namespace build2 move (n), t, nullptr, - v != nullptr ? *v : variable_visibility::normal, - global_ ? load_generation : 0})); + v != nullptr ? *v : variable_visibility::normal})); variable& r (p.first->second); @@ -1233,16 +1222,9 @@ namespace build2 // variable_map // - void variable_map:: + inline void variable_map:: typify (value_data& v, const variable& var) const { - // In the global state existing value can only be typified during - // the same load generation or during serial execution. - // - assert (!global_ || - load_generation == 0 || - v.generation == load_generation); - // We assume typification is not modification. // build2::typify (v, *var.type, &var); @@ -1286,9 +1268,7 @@ namespace build2 auto p (m_.emplace (var, value_data (typed ? var.type : nullptr))); value_data& r (p.first->second); - if (p.second) - r.generation = global_ ? load_generation : 0; - else + if (!p.second) { // First access after being assigned a type? // -- cgit v1.1