From 5c369faa461ec4416d2d4b231a5b36963a7315ce Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 4 Apr 2016 13:06:50 +0200 Subject: Implement value typing, null support via value attributes For example: v = [null] v = [string] abc v += ABC # abcABC --- build2/scope.cxx | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'build2/scope.cxx') diff --git a/build2/scope.cxx b/build2/scope.cxx index b0bd109..b74d52a 100644 --- a/build2/scope.cxx +++ b/build2/scope.cxx @@ -307,15 +307,18 @@ namespace build2 value& scope:: append (const variable& var) { - auto l (operator[] (var)); + // Note that here we want the original value without any overrides + // applied. + // + lookup l (find_original (var).first); - if (l && l.belongs (*this)) // Existing variable in this scope. - return const_cast (*l); + if (l.defined () && l.belongs (*this)) // Existing var in this scope. + return const_cast (*l); // Ok since this is original. - value& r (assign (var)); + value& r (assign (var)); // NULL. - if (l) - r = *l; // Copy value from the outer scope. + if (l.defined ()) + r = *l; // Copy value (and type) from the outer scope. return r; } -- cgit v1.1