From 3ba17db6300d7e0cfc4fa001b5a8eb91bf417ea3 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 12 Oct 2022 08:31:54 +0200 Subject: Switch to public/private variables model Now unqualified variables are project-private and can be typified. --- libbuild2/context.cxx | 39 ++++++++++++++++----------------------- 1 file changed, 16 insertions(+), 23 deletions(-) (limited to 'libbuild2/context.cxx') 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 (perform_update_id, "build.file", file_rule::instance); r.insert (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); -- cgit v1.1