diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2016-03-31 10:59:45 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2016-03-31 10:59:45 +0200 |
commit | 7253ffee27f6cae34e63a72b2d3d10db10571ecc (patch) | |
tree | c86b321ad4d2bcb05eda451ad3cae5ac8429cabf /build2/target.cxx | |
parent | 6417a4e6af2b7732ec0da6af24f1a56f7cdada3f (diff) |
Clean up variable lookup interfaces
Diffstat (limited to 'build2/target.cxx')
-rw-r--r-- | build2/target.cxx | 49 |
1 files changed, 10 insertions, 39 deletions
diff --git a/build2/target.cxx b/build2/target.cxx index 9d2f7af..e945d6d 100644 --- a/build2/target.cxx +++ b/build2/target.cxx @@ -114,55 +114,26 @@ namespace build2 return *r; } - lookup<const value> target:: + lookup target:: operator[] (const variable& var) const { - using result = lookup<const value>; - if (auto p = vars.find (var)) - return result (p, &vars); + return lookup (p, &vars); if (group != nullptr) { if (auto p = group->vars.find (var)) - return result (p, &group->vars); + return lookup (p, &group->vars); } - // We cannot simply delegate to scope's lookup() since we also need - // to check the group. + // Delegate to scope's find(). // - for (const scope* s (&base_scope ()); s != nullptr; ) - { - if (!s->target_vars.empty ()) - { - if (auto l = s->target_vars.lookup (type (), name, var)) - return l; - - if (group != nullptr) - { - if (auto l = s->target_vars.lookup (group->type (), group->name, var)) - return l; - } - } - - if (auto r = s->vars.find (var)) - return result (r, &s->vars); - - switch (var.visibility) - { - case variable_visibility::scope: - s = nullptr; - break; - case variable_visibility::project: - s = s->root () ? nullptr : s->parent_scope (); - break; - case variable_visibility::normal: - s = s->parent_scope (); - break; - } - } - - return result (); + return base_scope ().find ( + var, + &type (), + &name, + group != nullptr ? &group->type () : nullptr, + group != nullptr ? &group->name : nullptr); } value& target:: |