aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-04-17 15:25:00 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-04-17 15:25:00 +0200
commit3c0bf7825ce2aaa8f0c5a29757ce61bbbba40b5c (patch)
treef812fff72fa582e0e8c621fd4ee1f2cba36284ea
parent8f8ab1e8f6d85748547c0d0e9987eed4f3c3e17b (diff)
Search in target group during variable lookup
-rw-r--r--build/target13
-rw-r--r--build/target.cxx10
2 files changed, 15 insertions, 8 deletions
diff --git a/build/target b/build/target
index 3033e4e..49c135f 100644
--- a/build/target
+++ b/build/target
@@ -103,7 +103,7 @@ namespace build
: prereq (&p), target (&t) {}
};
- //
+ // Target.
//
class target
{
@@ -122,8 +122,10 @@ namespace build
const std::string* ext; // Extension, NULL means unspecified,
// empty means no extension.
- target* group {nullptr}; // Target group to which this target
- // belongs, if any.
+ target* group {nullptr}; // Target group to which this target belongs,
+ // if any. Note that we assume that the group
+ // and all its members are in the same scope
+ // (see, for example, variable lookup).
public:
// Most qualified scope that contains this target.
//
@@ -148,8 +150,9 @@ namespace build
public:
variable_map vars;
- // Lookup, including in outer scopes. If you only want to lookup
- // in this target, do it on the the variables map directly.
+ // Lookup, including in groups to which this target belongs and
+ // then in outer scopes. If you only want to lookup in this target,
+ // do it on the the variables map directly.
//
value_proxy
operator[] (const variable&) const;
diff --git a/build/target.cxx b/build/target.cxx
index cb751ad..4f06596 100644
--- a/build/target.cxx
+++ b/build/target.cxx
@@ -56,10 +56,14 @@ namespace build
{
auto i (vars.find (var));
- return i != vars.end ()
+ if (i != vars.end ())
// @@ Same issue as in variable_map: need ro_value_proxy.
- ? value_proxy (&const_cast<value_ptr&> (i->second), &vars)
- : base_scope ()[var];
+ return value_proxy (&const_cast<value_ptr&> (i->second), &vars);
+
+ if (group != nullptr)
+ return (*group)[var];
+
+ return base_scope ()[var];
}
value_proxy target::