aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2020-03-16 08:57:29 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2020-03-17 07:47:17 +0200
commit962f83b1e551cc683f1052d32cb79b969e65af5f (patch)
tree8e3d1936db8be9b07baffac289bb3b4e06010cf8
parent9f71deeeb0f8e6fe2c29f209fc96f466fc2831b6 (diff)
Rename all find*(variable) to lookup*(variable)
Now we consistently use term "lookup" for variable value lookup. At some point we should also rename type lookup to binding and get rid of all the lookup_type aliases.
-rw-r--r--libbuild2/algorithm.cxx2
-rw-r--r--libbuild2/cc/link-rule.cxx12
-rw-r--r--libbuild2/config/operation.cxx8
-rw-r--r--libbuild2/config/utility.cxx6
-rw-r--r--libbuild2/config/utility.txx4
-rw-r--r--libbuild2/dump.cxx2
-rw-r--r--libbuild2/file.cxx2
-rw-r--r--libbuild2/parser.cxx4
-rw-r--r--libbuild2/prerequisite.cxx4
-rw-r--r--libbuild2/scope.cxx58
-rw-r--r--libbuild2/scope.hxx50
-rw-r--r--libbuild2/target.cxx26
-rw-r--r--libbuild2/target.hxx48
-rw-r--r--libbuild2/target.txx2
-rw-r--r--libbuild2/test/script/parser.cxx4
-rw-r--r--libbuild2/test/script/script.cxx30
-rw-r--r--libbuild2/test/script/script.hxx10
-rw-r--r--libbuild2/variable.cxx8
-rw-r--r--libbuild2/variable.hxx22
19 files changed, 156 insertions, 146 deletions
diff --git a/libbuild2/algorithm.cxx b/libbuild2/algorithm.cxx
index 4793f0a..1ecf4de 100644
--- a/libbuild2/algorithm.cxx
+++ b/libbuild2/algorithm.cxx
@@ -1431,7 +1431,7 @@ namespace build2
// stops at the project boundary).
//
if (!l.defined ())
- l = ctx.global_scope.find (*ctx.var_backlink, t.key ());
+ l = ctx.global_scope.lookup (*ctx.var_backlink, t.key ());
return l ? backlink_test (t, l) : nullopt;
}
diff --git a/libbuild2/cc/link-rule.cxx b/libbuild2/cc/link-rule.cxx
index 5917419..6047206 100644
--- a/libbuild2/cc/link-rule.cxx
+++ b/libbuild2/cc/link-rule.cxx
@@ -1311,16 +1311,16 @@ namespace build2
lookup l (p.prerequisite.vars[var]);
if (!l.defined ())
- l = pt->find_original (var, true).first;
+ l = pt->lookup_original (var, true).first;
if (!l.defined ())
{
bool g (pt->group != nullptr);
- l = bs.find_original (var,
- &pt->type (),
- &pt->name,
- (g ? &pt->group->type () : nullptr),
- (g ? &pt->group->name : nullptr)).first;
+ l = bs.lookup_original (var,
+ &pt->type (),
+ &pt->name,
+ (g ? &pt->group->type () : nullptr),
+ (g ? &pt->group->name : nullptr)).first;
}
if (l ? cast<bool> (*l) : u)
diff --git a/libbuild2/config/operation.cxx b/libbuild2/config/operation.cxx
index 58f6aae..37ff1a3 100644
--- a/libbuild2/config/operation.cxx
+++ b/libbuild2/config/operation.cxx
@@ -218,7 +218,7 @@ namespace build2
//
auto& vp (ctx.var_pool);
- for (auto p (rs.vars.find_namespace (*vp.find ("config")));
+ for (auto p (rs.vars.lookup_namespace (*vp.find ("config")));
p.first != p.second;
++p.first)
{
@@ -260,7 +260,7 @@ namespace build2
{
lookup l {v, *var, rs.vars};
pair<lookup, size_t> org {l, 1 /* depth */};
- pair<lookup, size_t> ovr (rs.find_override (*var, org));
+ pair<lookup, size_t> ovr (rs.lookup_override (*var, org));
if (org.first != ovr.first)
continue;
@@ -295,10 +295,10 @@ namespace build2
{
const variable& var (sv.var);
- pair<lookup, size_t> org (rs.find_original (var));
+ pair<lookup, size_t> org (rs.lookup_original (var));
pair<lookup, size_t> ovr (var.overrides == nullptr
? org
- : rs.find_override (var, org));
+ : rs.lookup_override (var, org));
const lookup& l (ovr.first);
// We definitely write values that are set on our root scope or
diff --git a/libbuild2/config/utility.cxx b/libbuild2/config/utility.cxx
index 8ad150e..7415085 100644
--- a/libbuild2/config/utility.cxx
+++ b/libbuild2/config/utility.cxx
@@ -21,7 +21,7 @@ namespace build2
{
// This is a stripped-down version of the default value case.
- pair<lookup, size_t> org (rs.find_original (var));
+ pair<lookup, size_t> org (rs.lookup_original (var));
bool n (false); // New flag.
lookup l (org.first);
@@ -33,7 +33,7 @@ namespace build2
if (var.overrides != nullptr)
{
- pair<lookup, size_t> ovr (rs.find_override (var, move (org)));
+ pair<lookup, size_t> ovr (rs.lookup_override (var, move (org)));
if (l != ovr.first) // Overriden?
{
@@ -64,7 +64,7 @@ namespace build2
const variable& vns (rs.var_pool ().insert ("config." + n));
for (scope* s (&rs); s != nullptr; s = s->parent_scope ())
{
- for (auto p (s->vars.find_namespace (vns));
+ for (auto p (s->vars.lookup_namespace (vns));
p.first != p.second;
++p.first)
{
diff --git a/libbuild2/config/utility.txx b/libbuild2/config/utility.txx
index ae40ba7..b88f76c 100644
--- a/libbuild2/config/utility.txx
+++ b/libbuild2/config/utility.txx
@@ -18,7 +18,7 @@ namespace build2
save_variable (rs, var, sflags);
- pair<lookup, size_t> org (rs.find_original (var));
+ pair<lookup, size_t> org (rs.lookup_original (var));
bool n (false); // New flag.
lookup l (org.first);
@@ -71,7 +71,7 @@ namespace build2
if (var.overrides != nullptr)
{
- pair<lookup, size_t> ovr (rs.find_override (var, move (org)));
+ pair<lookup, size_t> ovr (rs.lookup_override (var, move (org)));
if (l != ovr.first) // Overriden?
{
diff --git a/libbuild2/dump.cxx b/libbuild2/dump.cxx
index 79c2309..e253988 100644
--- a/libbuild2/dump.cxx
+++ b/libbuild2/dump.cxx
@@ -102,7 +102,7 @@ namespace build2
// The original is always from this scope/target, so depth is 1.
//
lookup l (
- s.find_override (
+ s.lookup_override (
var,
make_pair (org, 1),
k == variable_kind::target || k == variable_kind::rule,
diff --git a/libbuild2/file.cxx b/libbuild2/file.cxx
index 7903918..fb5b68a 100644
--- a/libbuild2/file.cxx
+++ b/libbuild2/file.cxx
@@ -547,7 +547,7 @@ namespace build2
temp_scope tmp (ctx.global_scope.rw ());
p.parse_variable (l, tmp, var, tt);
- value* v (tmp.vars.find_to_modify (var).first);
+ value* v (tmp.vars.lookup_to_modify (var).first);
assert (v != nullptr);
// Steal the value, the scope is going away.
diff --git a/libbuild2/parser.cxx b/libbuild2/parser.cxx
index d8660b2..8f45125 100644
--- a/libbuild2/parser.cxx
+++ b/libbuild2/parser.cxx
@@ -5748,11 +5748,11 @@ namespace build2
pair<lookup, size_t> r (p->vars[var], 1);
if (!r.first.defined ())
- r = t->find_original (var);
+ r = t->lookup_original (var);
return var.overrides == nullptr
? r.first
- : t->base_scope ().find_override (var, move (r), true).first;
+ : t->base_scope ().lookup_override (var, move (r), true).first;
}
if (t != nullptr)
diff --git a/libbuild2/prerequisite.cxx b/libbuild2/prerequisite.cxx
index 9d3a7af..cc41708 100644
--- a/libbuild2/prerequisite.cxx
+++ b/libbuild2/prerequisite.cxx
@@ -77,14 +77,14 @@ namespace build2
value& prerequisite::
append (const variable& var, const target_type& t)
{
- if (value* r = vars.find_to_modify (var).first)
+ if (value* r = vars.lookup_to_modify (var).first)
return *r;
value& r (assign (var)); // NULL.
// Note: pretty similar logic to target::append().
//
- lookup l (t.find_original (var).first);
+ lookup l (t.lookup_original (var).first);
if (l.defined ())
r = *l; // Copy value (and type) from the target/outer scope.
diff --git a/libbuild2/scope.cxx b/libbuild2/scope.cxx
index d574c11..51704fb 100644
--- a/libbuild2/scope.cxx
+++ b/libbuild2/scope.cxx
@@ -13,21 +13,21 @@ namespace build2
// scope
//
pair<lookup, size_t> scope::
- find_original (const variable& var,
- const target_type* tt, const string* tn,
- const target_type* gt, const string* gn,
- size_t start_d) const
+ lookup_original (const variable& var,
+ const target_type* tt, const string* tn,
+ const target_type* gt, const string* gn,
+ size_t start_d) const
{
assert (tt != nullptr || var.visibility != variable_visibility::target);
size_t d (0);
if (var.visibility == variable_visibility::prereq)
- return make_pair (lookup (), d);
+ return make_pair (lookup_type (), d);
// Process target type/pattern-specific prepend/append values.
//
- auto pre_app = [&var, this] (lookup& l,
+ auto pre_app = [&var, this] (lookup_type& l,
const scope* s,
const target_type* tt, const string* tn,
const target_type* gt, const string* gn)
@@ -44,7 +44,7 @@ namespace build2
// group, then we shouldn't be looking for stem in the target's
// variables. In other words, once we "jump" to group, we stay there.
//
- lookup stem (s->find_original (var, tt, tn, gt, gn, 2).first);
+ lookup_type stem (s->lookup_original (var, tt, tn, gt, gn, 2).first);
// Check the cache.
//
@@ -114,7 +114,7 @@ namespace build2
{
if (f)
{
- lookup l (s->target_vars.find (*tt, *tn, var));
+ lookup_type l (s->target_vars.find (*tt, *tn, var));
if (l.defined ())
{
@@ -132,7 +132,7 @@ namespace build2
{
if (f && gt != nullptr)
{
- lookup l (s->target_vars.find (*gt, *gn, var));
+ lookup_type l (s->target_vars.find (*gt, *gn, var));
if (l.defined ())
{
@@ -150,9 +150,9 @@ namespace build2
//
if (++d >= start_d && var.visibility != variable_visibility::target)
{
- auto p (s->vars.find (var));
+ auto p (s->vars.lookup (var));
if (p.first != nullptr)
- return make_pair (lookup (*p.first, p.second, s->vars), d);
+ return make_pair (lookup_type (*p.first, p.second, s->vars), d);
}
switch (var.visibility)
@@ -172,14 +172,14 @@ namespace build2
}
}
- return make_pair (lookup (), size_t (~0));
+ return make_pair (lookup_type (), size_t (~0));
}
pair<lookup, size_t> scope::
- find_override (const variable& var,
- pair<lookup, size_t> original,
- bool target,
- bool rule) const
+ lookup_override (const variable& var,
+ pair<lookup_type, size_t> original,
+ bool target,
+ bool rule) const
{
assert (!rule || target); // Rule-specific is target-specific.
@@ -193,7 +193,7 @@ namespace build2
//
assert (var.overrides != nullptr);
- const lookup& orig (original.first);
+ const lookup_type& orig (original.first);
size_t orig_depth (original.second);
// The first step is to find out where our cache will reside. After some
@@ -272,21 +272,21 @@ namespace build2
// Return the override value if present in scope s and (optionally) of
// the specified kind (__override, __prefix, etc).
//
- auto find = [&s, &var] (const variable* o,
- const char* k = nullptr) -> lookup
+ auto lookup = [&s, &var] (const variable* o,
+ const char* k = nullptr) -> lookup_type
{
if (k != nullptr && !o->override (k))
- return lookup ();
+ return lookup_type ();
// Note: using the original as storage variable.
//
- return lookup (s->vars.find (*o).first, &var, &s->vars);
+ return lookup_type (s->vars.lookup (*o).first, &var, &s->vars);
};
// Return true if a value is from this scope (either target type/pattern-
// specific or ordinary).
//
- auto belongs = [&s, target] (const lookup& l) -> bool
+ auto belongs = [&s, target] (const lookup_type& l) -> bool
{
if (target)
{
@@ -324,7 +324,7 @@ namespace build2
if (inner_vars != nullptr && !applies (o, inner_vars, inner_proj))
continue;
- auto l (find (o));
+ auto l (lookup (o));
if (l.defined ())
{
@@ -360,7 +360,7 @@ namespace build2
// suffixes and prepending prefixes. This is either the original or the
// __override, provided it applies. We may also not have either.
//
- lookup stem;
+ lookup_type stem;
size_t stem_depth (0);
const scope* stem_proj (nullptr);
const variable* stem_ovr (nullptr); // __override if found and applies.
@@ -410,7 +410,7 @@ namespace build2
if (stem.defined () && !applies (o, stem.vars, stem_proj))
continue;
- auto l (find (o, "__override"));
+ auto l (lookup (o, "__override"));
if (l.defined ())
{
@@ -525,8 +525,8 @@ namespace build2
// variable itself is typed. We also pass the original variable for
// diagnostics.
//
- auto lp (find (o, "__prefix"));
- auto ls (find (o, "__suffix"));
+ auto lp (lookup (o, "__prefix"));
+ auto ls (lookup (o, "__suffix"));
if (cl)
{
@@ -567,7 +567,7 @@ namespace build2
// Use the location of the innermost value that contributed as the
// location of the result.
//
- return make_pair (lookup (&cv, &var, vars), depth);
+ return make_pair (lookup_type (&cv, &var, vars), depth);
}
value& scope::
@@ -576,7 +576,7 @@ namespace build2
// Note that here we want the original value without any overrides
// applied.
//
- lookup l (find_original (var).first);
+ auto l (lookup_original (var).first);
if (l.defined () && l.belongs (*this)) // Existing var in this scope.
return vars.modify (l); // Ok since this is original.
diff --git a/libbuild2/scope.hxx b/libbuild2/scope.hxx
index 006d1a7..97ec448 100644
--- a/libbuild2/scope.hxx
+++ b/libbuild2/scope.hxx
@@ -95,64 +95,66 @@ namespace build2
// scope, do it on the the variables map directly (and note that there
// will be no overrides).
//
- lookup
+ using lookup_type = build2::lookup;
+
+ lookup_type
operator[] (const variable& var) const
{
- return find (var).first;
+ return lookup (var).first;
}
- lookup
+ lookup_type
operator[] (const variable* var) const // For cached variables.
{
assert (var != nullptr);
return operator[] (*var);
}
- lookup
+ lookup_type
operator[] (const string& name) const
{
const variable* var (ctx.var_pool.find (name));
- return var != nullptr ? operator[] (*var) : lookup ();
+ return var != nullptr ? operator[] (*var) : lookup_type ();
}
// As above, but include target type/pattern-specific variables.
//
- lookup
- find (const variable& var, const target_key& tk) const
+ lookup_type
+ lookup (const variable& var, const target_key& tk) const
{
- return find (var, tk.type, tk.name).first;
+ return lookup (var, tk.type, tk.name).first;
}
- lookup
- find (const variable& var, const target_type& tt, const string& tn) const
+ lookup_type
+ lookup (const variable& var, const target_type& tt, const string& tn) const
{
- return find (var, &tt, &tn).first;
+ return lookup (var, &tt, &tn).first;
}
- pair<lookup, size_t>
- find (const variable& var,
- const target_type* tt = nullptr,
- const string* tn = nullptr) const
+ pair<lookup_type, size_t>
+ lookup (const variable& var,
+ const target_type* tt = nullptr,
+ const string* tn = nullptr) const
{
- auto p (find_original (var, tt, tn));
- return var.overrides == nullptr ? p : find_override (var, move (p));
+ auto p (lookup_original (var, tt, tn));
+ return var.overrides == nullptr ? p : lookup_override (var, move (p));
}
// Implementation details (used by scope target lookup). The start_depth
// can be used to skip a number of initial lookups.
//
- pair<lookup, size_t>
- find_original (
+ pair<lookup_type, size_t>
+ lookup_original (
const variable&,
const target_type* tt = nullptr, const string* tn = nullptr,
const target_type* gt = nullptr, const string* gn = nullptr,
size_t start_depth = 1) const;
- pair<lookup, size_t>
- find_override (const variable&,
- pair<lookup, size_t> original,
- bool target = false,
- bool rule = false) const;
+ pair<lookup_type, size_t>
+ lookup_override (const variable&,
+ pair<lookup_type, size_t> original,
+ bool target = false,
+ bool rule = false) const;
// Return a value suitable for assignment (or append if you only want to
// append to the value from this scope). If the value does not exist in
diff --git a/libbuild2/target.cxx b/libbuild2/target.cxx
index 45d0eb2..b49071a 100644
--- a/libbuild2/target.cxx
+++ b/libbuild2/target.cxx
@@ -130,15 +130,15 @@ namespace build2
}
pair<lookup, size_t> target::
- find_original (const variable& var, bool target_only) const
+ lookup_original (const variable& var, bool target_only) const
{
- pair<lookup, size_t> r (lookup (), 0);
+ pair<lookup_type, size_t> r (lookup_type (), 0);
++r.second;
{
- auto p (vars.find (var));
+ auto p (vars.lookup (var));
if (p.first != nullptr)
- r.first = lookup (*p.first, p.second, vars);
+ r.first = lookup_type (*p.first, p.second, vars);
}
const target* g (nullptr);
@@ -154,9 +154,9 @@ namespace build2
? nullptr
: group->adhoc_group () ? group->group : group))
{
- auto p (g->vars.find (var));
+ auto p (g->vars.lookup (var));
if (p.first != nullptr)
- r.first = lookup (*p.first, p.second, g->vars);
+ r.first = lookup_type (*p.first, p.second, g->vars);
}
}
@@ -166,7 +166,7 @@ namespace build2
{
if (!target_only)
{
- auto p (base_scope ().find_original (
+ auto p (base_scope ().lookup_original (
var,
&type (),
&name,
@@ -191,7 +191,7 @@ namespace build2
// Note that here we want the original value without any overrides
// applied.
//
- lookup l (find_original (var).first);
+ auto l (lookup_original (var).first);
if (l.defined () && l.belongs (*this)) // Existing var in this target.
return vars.modify (l); // Ok since this is original.
@@ -205,22 +205,22 @@ namespace build2
}
pair<lookup, size_t> target::opstate::
- find_original (const variable& var, bool target_only) const
+ lookup_original (const variable& var, bool target_only) const
{
- pair<lookup, size_t> r (lookup (), 0);
+ pair<lookup_type, size_t> r (lookup_type (), 0);
++r.second;
{
- auto p (vars.find (var));
+ auto p (vars.lookup (var));
if (p.first != nullptr)
- r.first = lookup (*p.first, p.second, vars);
+ r.first = lookup_type (*p.first, p.second, vars);
}
// Delegate to target's find_original().
//
if (!r.first)
{
- auto p (target_->find_original (var, target_only));
+ auto p (target_->lookup_original (var, target_only));
r.first = move (p.first);
r.second = r.first ? r.second + p.second : p.second;
diff --git a/libbuild2/target.hxx b/libbuild2/target.hxx
index 4d6cc1a..1abda2d 100644
--- a/libbuild2/target.hxx
+++ b/libbuild2/target.hxx
@@ -393,24 +393,26 @@ namespace build2
// only want to lookup in this target, do it on the variable map directly
// (and note that there will be no overrides).
//
- lookup
+ using lookup_type = build2::lookup;
+
+ lookup_type
operator[] (const variable& var) const
{
- return find (var).first;
+ return lookup (var).first;
}
- lookup
+ lookup_type
operator[] (const variable* var) const // For cached variables.
{
assert (var != nullptr);
return operator[] (*var);
}
- lookup
+ lookup_type
operator[] (const string& name) const
{
const variable* var (ctx.var_pool.find (name));
- return var != nullptr ? operator[] (*var) : lookup ();
+ return var != nullptr ? operator[] (*var) : lookup_type ();
}
// As above but also return the depth at which the value is found. The
@@ -421,20 +423,20 @@ namespace build2
// 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, size_t>
- find (const variable& var) const
+ pair<lookup_type, size_t>
+ lookup (const variable& var) const
{
- auto p (find_original (var));
+ auto p (lookup_original (var));
return var.overrides == nullptr
? p
- : base_scope ().find_override (var, move (p), true);
+ : 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.
//
- pair<lookup, size_t>
- find_original (const variable&, bool target_only = false) const;
+ pair<lookup_type, size_t>
+ lookup_original (const variable&, bool target_only = false) const;
// Return a value suitable for assignment. See scope for details.
//
@@ -525,24 +527,26 @@ namespace build2
// want to lookup in this target, do it on the variable map directly
// (and note that there will be no overrides).
//
- lookup
+ using lookup_type = build2::lookup;
+
+ lookup_type
operator[] (const variable& var) const
{
- return find (var).first;
+ return lookup (var).first;
}
- lookup
+ lookup_type
operator[] (const variable* var) const // For cached variables.
{
assert (var != nullptr);
return operator[] (*var);
}
- lookup
+ lookup_type
operator[] (const string& name) const
{
const variable* var (target_->ctx.var_pool.find (name));
- return var != nullptr ? operator[] (*var) : lookup ();
+ return var != nullptr ? operator[] (*var) : lookup_type ();
}
// As above but also return the depth at which the value is found. The
@@ -550,20 +554,20 @@ namespace build2
// that is from the rule will have depth 1. That from the target - 2,
// and so on, similar to target-specific variables.
//
- pair<lookup, size_t>
- find (const variable& var) const
+ pair<lookup_type, size_t>
+ lookup (const variable& var) const
{
- auto p (find_original (var));
+ auto p (lookup_original (var));
return var.overrides == nullptr
? p
- : target_->base_scope ().find_override (var, move (p), true, true);
+ : 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.
//
- pair<lookup, size_t>
- find_original (const variable&, bool target_only = false) const;
+ pair<lookup_type, size_t>
+ lookup_original (const variable&, bool target_only = false) const;
// Return a value suitable for assignment. See target for details.
//
diff --git a/libbuild2/target.txx b/libbuild2/target.txx
index 395e612..0e4d9bf 100644
--- a/libbuild2/target.txx
+++ b/libbuild2/target.txx
@@ -93,7 +93,7 @@ namespace build2
{
// Include target type/pattern-specific variables.
//
- if (auto l = s.find (*s.ctx.var_extension, tt, tn))
+ if (auto l = s.lookup (*s.ctx.var_extension, tt, tn))
{
// Help the user here and strip leading '.' from the extension.
//
diff --git a/libbuild2/test/script/parser.cxx b/libbuild2/test/script/parser.cxx
index 4a5a64a..06cefc7 100644
--- a/libbuild2/test/script/parser.cxx
+++ b/libbuild2/test/script/parser.cxx
@@ -3377,8 +3377,8 @@ namespace build2
}
return pvar != nullptr
- ? scope_->find (*pvar)
- : script_->find_in_buildfile (name);
+ ? scope_->lookup (*pvar)
+ : script_->lookup_in_buildfile (name);
}
size_t parser::
diff --git a/libbuild2/test/script/script.cxx b/libbuild2/test/script/script.cxx
index d8cf5fb..79b8bca 100644
--- a/libbuild2/test/script/script.cxx
+++ b/libbuild2/test/script/script.cxx
@@ -533,7 +533,7 @@ namespace build2
// Note that the test variable's visibility is target.
//
- lookup l (find_in_buildfile ("test", false));
+ auto l (lookup_in_buildfile ("test", false));
// Note that we have similar code for simple tests.
//
@@ -608,7 +608,7 @@ namespace build2
}
lookup scope::
- find (const variable& var) const
+ lookup (const variable& var) const
{
// Search script scopes until we hit the root.
//
@@ -616,18 +616,18 @@ namespace build2
do
{
- auto p (s->vars.find (var));
+ auto p (s->vars.lookup (var));
if (p.first != nullptr)
- return lookup (*p.first, p.second, s->vars);
+ return lookup_type (*p.first, p.second, s->vars);
}
while ((s->parent != nullptr ? (s = s->parent) : nullptr) != nullptr);
- return find_in_buildfile (var.name);
+ return lookup_in_buildfile (var.name);
}
lookup scope::
- find_in_buildfile (const string& n, bool target_only) const
+ lookup_in_buildfile (const string& n, bool target_only) const
{
// Switch to the corresponding buildfile variable. Note that we don't
// want to insert a new variable into the pool (we might be running
@@ -637,7 +637,7 @@ namespace build2
const variable* pvar (root.test_target.ctx.var_pool.find (n));
if (pvar == nullptr)
- return lookup ();
+ return lookup_type ();
const variable& var (*pvar);
@@ -648,12 +648,12 @@ namespace build2
// value. In this case, presumably the override also affects the
// script target and we will pick it up there. A bit fuzzy.
//
- auto p (root.test_target.find_original (var, target_only));
+ auto p (root.test_target.lookup_original (var, target_only));
if (p.first)
{
if (var.overrides != nullptr)
- p = root.target_scope.find_override (var, move (p), true);
+ p = root.target_scope.lookup_override (var, move (p), true);
return p.first;
}
@@ -670,7 +670,7 @@ namespace build2
value& scope::
append (const variable& var)
{
- lookup l (find (var));
+ auto l (lookup (var));
if (l.defined () && l.belongs (*this)) // Existing var in this scope.
return vars.modify (l);
@@ -695,23 +695,23 @@ namespace build2
s.insert (s.end (), v.begin (), v.end ());
};
- if (lookup l = find (root.test_var))
+ if (auto l = lookup (root.test_var))
s.push_back (cast<path> (l).representation ());
- if (lookup l = find (root.options_var))
+ if (auto l = lookup (root.options_var))
append (cast<strings> (l));
- if (lookup l = find (root.arguments_var))
+ if (auto l = lookup (root.arguments_var))
append (cast<strings> (l));
// Keep redirects/cleanups out of $N.
//
size_t n (s.size ());
- if (lookup l = find (root.redirects_var))
+ if (auto l = lookup (root.redirects_var))
append (cast<strings> (l));
- if (lookup l = find (root.cleanups_var))
+ if (auto l = lookup (root.cleanups_var))
append (cast<strings> (l));
// Set the $N values if present.
diff --git a/libbuild2/test/script/script.hxx b/libbuild2/test/script/script.hxx
index 8e5df16..a28ef25 100644
--- a/libbuild2/test/script/script.hxx
+++ b/libbuild2/test/script/script.hxx
@@ -369,15 +369,17 @@ namespace build2
// and then outer buildfile scopes (including testscript-type/pattern
// specific).
//
- lookup
- find (const variable&) const;
+ using lookup_type = build2::lookup;
+
+ lookup_type
+ lookup (const variable&) const;
// As above but only look for buildfile variables. If target_only is
// false then also look in scopes of the test target (this should only
// be done if the variable's visibility is target).
//
- lookup
- find_in_buildfile (const string&, bool target_only = true) const;
+ lookup_type
+ lookup_in_buildfile (const string&, bool target_only = true) const;
// Return a value suitable for assignment. If the variable does not
// exist in this scope's map, then a new one with the NULL value is
diff --git a/libbuild2/variable.cxx b/libbuild2/variable.cxx
index 90d5120..0460344 100644
--- a/libbuild2/variable.cxx
+++ b/libbuild2/variable.cxx
@@ -1387,7 +1387,7 @@ namespace build2
const variable_map empty_variable_map (nullptr /* context */);
auto variable_map::
- find (const variable& var, bool typed) const ->
+ lookup (const variable& var, bool typed) const ->
pair<const value_data*, const variable&>
{
const variable* v (&var);
@@ -1419,10 +1419,10 @@ namespace build2
}
auto variable_map::
- find_to_modify (const variable& var, bool typed) ->
+ lookup_to_modify (const variable& var, bool typed) ->
pair<value_data*, const variable&>
{
- auto p (find (var, typed));
+ auto p (lookup (var, typed));
auto* r (const_cast<value_data*> (p.first));
if (r != nullptr)
@@ -1499,7 +1499,7 @@ namespace build2
//
const variable_map& vm (j->second);
{
- auto p (vm.find (var, false));
+ auto p (vm.lookup (var, false));
if (const variable_map::value_data* v = p.first)
{
// Check if this is the first access after being assigned a type.
diff --git a/libbuild2/variable.hxx b/libbuild2/variable.hxx
index 02df60b..071cb5f 100644
--- a/libbuild2/variable.hxx
+++ b/libbuild2/variable.hxx
@@ -1362,44 +1362,46 @@ namespace build2
// Lookup. Note that variable overrides will not be applied, even if
// set in this map.
//
- lookup
+ using lookup_type = build2::lookup;
+
+ lookup_type
operator[] (const variable& var) const
{
- auto p (find (var));
- return lookup (p.first, &p.second, this);
+ auto p (lookup (var));
+ return lookup_type (p.first, &p.second, this);
}
- lookup
+ lookup_type
operator[] (const variable* var) const // For cached variables.
{
assert (var != nullptr);
return operator[] (*var);
}
- lookup
+ lookup_type
operator[] (const string& name) const
{
const variable* var (ctx != nullptr
? ctx->var_pool.find (name)
: nullptr);
- return var != nullptr ? operator[] (*var) : lookup ();
+ return var != nullptr ? operator[] (*var) : lookup_type ();
}
// If typed is false, leave the value untyped even if the variable is.
// The second half of the pair is the storage variable.
//
pair<const value_data*, const variable&>
- find (const variable&, bool typed = true) const;
+ lookup (const variable&, bool typed = true) const;
pair<value_data*, const variable&>
- find_to_modify (const variable&, bool typed = true);
+ lookup_to_modify (const variable&, bool typed = true);
// Convert a lookup pointing to a value belonging to this variable map
// to its non-const version. Note that this is only safe on the original
// values (see find_original()).
//
value&
- modify (const lookup& l)
+ modify (const lookup_type& l)
{
assert (l.vars == this);
value& r (const_cast<value&> (*l.value));
@@ -1432,7 +1434,7 @@ namespace build2
insert (const variable&, bool typed = true);
pair<const_iterator, const_iterator>
- find_namespace (const variable& ns) const
+ lookup_namespace (const variable& ns) const
{
auto r (m_.find_sub (ns));
return make_pair (const_iterator (r.first, *this),