diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2022-10-12 08:31:54 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2022-10-13 06:49:26 +0200 |
commit | 3ba17db6300d7e0cfc4fa001b5a8eb91bf417ea3 (patch) | |
tree | 2c0878097ba9b049ea472c2c8c99a0e4ff77e959 /libbuild2/context.cxx | |
parent | d66e21ffa3ac9520fb15dd3859339b178d6e6540 (diff) |
Switch to public/private variables model
Now unqualified variables are project-private and can be typified.
Diffstat (limited to 'libbuild2/context.cxx')
-rw-r--r-- | libbuild2/context.cxx | 39 |
1 files changed, 16 insertions, 23 deletions
diff --git a/libbuild2/context.cxx b/libbuild2/context.cxx index 4cbdecb..f46a3eb 100644 --- a/libbuild2/context.cxx +++ b/libbuild2/context.cxx @@ -464,6 +464,18 @@ namespace build2 string n (t.value, c == '!' || c == '%' || c == '/' ? 1 : 0); + // Make sure it is qualified. + // + // We can support overridable public unqualified variables (which must + // all be pre-entered by the end of this constructor) but we will need + // to detect their names here in an ad hoc manner (we cannot enter them + // before this logic because of the "untyped override" requirement). + // + // Note: issue the same diagnostics as in variable_pool::update(). + // + if (n.find ('.') == string::npos) + fail << "variable " << n << " cannot be overridden"; + if (c == '!' && dir) fail << "scope-qualified global override of variable " << n; @@ -620,6 +632,10 @@ namespace build2 r.insert<mtime_target> (perform_update_id, "build.file", file_rule::instance); r.insert<mtime_target> (perform_clean_id, "build.file", file_rule::instance); } + + // End of initialization. + // + load_generation = 1; } context:: @@ -716,29 +732,6 @@ namespace build2 current_mode = inner_oif.mode; current_diag_noise = diag_noise; - auto find_ovar = [this] (const char* n) - { - const variable* v (var_pool.find (n)); // @@ TMP: pub/prv vars - - // The operation variable should have prerequisite or target visibility. - // - assert (v != nullptr && - (v->visibility == variable_visibility::prereq || - v->visibility == variable_visibility::target)); - - return v; - }; - - current_inner_ovar = - inner_oif.var_name != nullptr - ? find_ovar (inner_oif.var_name) - : nullptr; - - current_outer_ovar = - outer_oif != nullptr && outer_oif->var_name != nullptr - ? find_ovar (outer_oif->var_name) - : nullptr; - // Reset counters (serial execution). // dependency_count.store (0, memory_order_relaxed); |