aboutsummaryrefslogtreecommitdiff
path: root/build2/target
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-04-02 09:06:26 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-04-02 09:06:26 +0200
commit54fb34bb1ccfac35addd381921be316302276b1b (patch)
tree96f34e4efb2e8ff7742b417f0591e8d57ae441ff /build2/target
parent175437114658325674a9fec4ea49703e192c4ffc (diff)
Add notion of lookup depth, fix bug with NULL overrides
Diffstat (limited to 'build2/target')
-rw-r--r--build2/target20
1 files changed, 19 insertions, 1 deletions
diff --git a/build2/target b/build2/target
index af573fa..eb6154a 100644
--- a/build2/target
+++ b/build2/target
@@ -276,7 +276,10 @@ namespace build2
// (and note that there will be no overrides).
//
lookup
- operator[] (const variable&) const;
+ operator[] (const variable& var) const
+ {
+ return find (var).first;
+ }
lookup
operator[] (const string& name) const
@@ -284,6 +287,21 @@ namespace build2
return operator[] (var_pool.find (name));
}
+ // As above but also return the depth at which the value is found. The
+ // depth is calculated by adding 1 for each test performed. So a value
+ // that is from the target will have depth 1. That from the group -- 2.
+ // From the innermost scope's target type/patter-specific variables --
+ // 3. From the innermost scope's variables -- 4. 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.
+ //
+ pair<lookup, size_t>
+ find (const variable&) const;
+
+ pair<lookup, size_t>
+ find (const string& name) const {return find (var_pool.find (name));}
+
+
// Return a value suitable for assignment. See class scope for
// details.
//