diff options
Diffstat (limited to 'build2/target')
-rw-r--r-- | build2/target | 20 |
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. // |