aboutsummaryrefslogtreecommitdiff
path: root/build/target.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'build/target.cxx')
-rw-r--r--build/target.cxx25
1 files changed, 21 insertions, 4 deletions
diff --git a/build/target.cxx b/build/target.cxx
index fbba1ed..5be0a8d 100644
--- a/build/target.cxx
+++ b/build/target.cxx
@@ -52,15 +52,32 @@ namespace build
}
value_proxy target::
- operator[] (const variable& var)
+ operator[] (const variable& var) const
{
- auto i (variables.find (var));
+ auto i (vars.find (var));
- return i != variables.end ()
- ? value_proxy (&i->second, nullptr)
+ return 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];
}
+ value_proxy target::
+ append (const variable& var)
+ {
+ value_proxy val (operator[] (var));
+
+ if (val && val.belongs (*this)) // Existing variable in this target.
+ return val;
+
+ value_proxy r (assign (var));
+
+ if (val)
+ r = val; // Copy value from the outer scope.
+
+ return r;
+ }
+
ostream&
operator<< (ostream& os, const target& t)
{