aboutsummaryrefslogtreecommitdiff
path: root/build/target.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-04-15 14:10:50 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-04-15 14:10:50 +0200
commit6535bf6175af32e2514faf75d2742424751a783b (patch)
tree21312b28ffe2bbb459a57e80a1f8eec498327d9f /build/target.cxx
parentad720fabd468974e3909f62a0f4e4e3cf0d03aef (diff)
New variables architecture
Now operator[] is only used for lookup.
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)
{