diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2024-07-31 09:34:05 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2024-07-31 09:34:05 +0200 |
commit | b13b031b2b8a7390d1dd4b2658d0f0b62e43db47 (patch) | |
tree | f4d2d12c6717541ec7d2b56cfafa25ebd73070d9 /libbuild2/target.hxx | |
parent | e122c6ff4a7f21026332ce9211ad095bd44e71ea (diff) |
Add lookup limit to {scope,target}::lookup_original()
Diffstat (limited to 'libbuild2/target.hxx')
-rw-r--r-- | libbuild2/target.hxx | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/libbuild2/target.hxx b/libbuild2/target.hxx index da2ab73..c1da26c 100644 --- a/libbuild2/target.hxx +++ b/libbuild2/target.hxx @@ -773,14 +773,16 @@ namespace build2 // From the innermost scope's target type/patter-specific variables for // the target -- 3. From the innermost scope's target type/patter-specific // variables for the group -- 4. From the innermost scope's variables -- - // 5. And so on. The idea is that given two lookups from the same target, - // we can say which one came earlier. If no value is found, then the depth - // is set to ~0. + // 5. And so on. Note that if a target type/patter-specific append/prepend + // was applied, then the returned depth is of the innermost such + // append/prepend. The idea is that given two lookups from the same + // target, we can say which one came earlier. If no value is found, then + // the depth is set to ~0. // pair<lookup_type, size_t> lookup (const variable& var, const scope* bs = nullptr) const { - auto p (lookup_original (var, false, bs)); + auto p (lookup_original (var, bs)); return var.overrides == nullptr ? p : (bs != nullptr @@ -788,17 +790,31 @@ namespace build2 : base_scope ()).lookup_override (var, move (p), true); } - // If target_only is true, then only look in target and its target group - // without continuing in scopes. As an optimization, the caller can also - // pass the base scope of the target, if already known. If locked is true, - // assume the targets mutex is locked. + // If limit is target, then only look in target and its target group + // without continuing in scopes. If it is target_type, then additionally + // look in target type/pattern-specific variables in scopes (see + // scope::lookup_original() for the exact semantics). + // + // As an optimization, the caller can also pass the base scope of the + // target, if already known. + // + // If locked is true, assume the targets mutex is locked (not relevant if + // limit is target). // pair<lookup_type, size_t> lookup_original (const variable&, - bool target_only = false, + lookup_limit = lookup_limit::none, const scope* bs = nullptr, bool locked = false) const; + pair<lookup_type, size_t> + lookup_original (const variable& var, + const scope* bs, + bool locked = false) const + { + return lookup_original (var, lookup_limit::none, bs, locked); + } + // Return a value suitable for assignment. See scope for details. // value& @@ -991,11 +1007,11 @@ namespace build2 : target_->base_scope ().lookup_override (var, move (p), true, true); } - // If target_only is true, then only look in target and its target group - // without continuing in scopes. + // The limit semantics is the same as in target::lookup_original(). // pair<lookup_type, size_t> - lookup_original (const variable&, bool target_only = false) const; + lookup_original (const variable&, + lookup_limit = lookup_limit::none) const; // Return a value suitable for assignment. See target for details. // |