From 19af3f6b0873a92582e4787a87a6f14df53ff6ae Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 10 Oct 2022 18:22:31 +0200 Subject: Preparatory work for public/private variable distinction We still always use the public var_pool from context but where required, all access now goes through scope::var_pool(). --- libbuild2/scope.hxx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'libbuild2/scope.hxx') diff --git a/libbuild2/scope.hxx b/libbuild2/scope.hxx index 2105512..598d7e8 100644 --- a/libbuild2/scope.hxx +++ b/libbuild2/scope.hxx @@ -136,7 +136,7 @@ namespace build2 lookup_type operator[] (const string& name) const { - const variable* var (ctx.var_pool.find (name)); + const variable* var (var_pool ().find (name)); return var != nullptr ? operator[] (*var) : lookup_type (); } @@ -508,6 +508,10 @@ namespace build2 const path& src_root_file; // build[2]/bootstrap/src-root.build[2] const path& out_root_file; // build[2]/bootstrap/src-root.build[2] + // Project-private variable pool. + // + variable_pool var_pool; + // Meta/operations supported by this project. // build2::meta_operations meta_operations; @@ -589,12 +593,21 @@ namespace build2 return const_cast (*this); } + // @@ TODO: find root scope and return its var_pool falling back to + // ctx.var_pool if no root scope. + // variable_pool& var_pool () { return ctx.var_pool.rw (*this); } + const variable_pool& + var_pool () const + { + return ctx.var_pool; + } + private: friend class parser; friend class scope_map; -- cgit v1.1