From 6535bf6175af32e2514faf75d2742424751a783b Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 15 Apr 2015 14:10:50 +0200 Subject: New variables architecture Now operator[] is only used for lookup. --- build/target.cxx | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'build/target.cxx') 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 (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) { -- cgit v1.1