From 7253ffee27f6cae34e63a72b2d3d10db10571ecc Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 31 Mar 2016 10:59:45 +0200 Subject: Clean up variable lookup interfaces --- build2/scope.cxx | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'build2/scope.cxx') diff --git a/build2/scope.cxx b/build2/scope.cxx index 294833e..77efccd 100644 --- a/build2/scope.cxx +++ b/build2/scope.cxx @@ -12,21 +12,30 @@ namespace build2 { // scope // - lookup scope:: - lookup (const target_type* tt, const string* name, const variable& var) const + lookup scope:: + find (const variable& var, + const target_type* tt, const string* tn, + const target_type* gt, const string* gn) const { - using result = build2::lookup; - for (const scope* s (this); s != nullptr; ) { - if (tt != nullptr && !s->target_vars.empty ()) + if (!s->target_vars.empty ()) { - if (auto l = s->target_vars.lookup (*tt, *name, var)) - return l; + if (tt != nullptr) + { + if (auto l = s->target_vars.find (*tt, *tn, var)) + return l; + } + + if (gt != nullptr) + { + if (auto l = s->target_vars.find (*gt, *gn, var)) + return l; + } } if (auto r = s->vars.find (var)) - return result (r, &s->vars); + return lookup (r, &s->vars); switch (var.visibility) { @@ -42,7 +51,7 @@ namespace build2 } } - return result (); + return lookup (); } value& scope:: -- cgit v1.1