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/variable.ixx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'libbuild2/variable.ixx') diff --git a/libbuild2/variable.ixx b/libbuild2/variable.ixx index a84c012..7cafd89 100644 --- a/libbuild2/variable.ixx +++ b/libbuild2/variable.ixx @@ -916,8 +916,21 @@ namespace build2 inline const variable* variable_pool:: find (const string& n) const { + // The pool chaining semantics for lookup: first check own pool then, if + // not found, check the outer pool. + // auto i (map_.find (&n)); - return i != map_.end () ? &i->second : nullptr; + if (i != map_.end ()) + return &i->second; + + if (outer_ != nullptr) + { + i = outer_->map_.find (&n); + if (i != outer_->map_.end ()) + return &i->second; + } + + return nullptr; } // variable_map -- cgit v1.1