aboutsummaryrefslogtreecommitdiff
path: root/build/target.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-08-24 09:51:15 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-08-24 14:52:43 +0200
commit68f96f9213e849d0d7c4cedf3edeaec99743ee27 (patch)
tree271913d74c906971cac555319f5e14d0c66e0c16 /build/target.cxx
parent0d5234f4aefd3cc5b5948cc1b9dd009e50046f5e (diff)
New variable architecture
Diffstat (limited to 'build/target.cxx')
-rw-r--r--build/target.cxx32
1 files changed, 17 insertions, 15 deletions
diff --git a/build/target.cxx b/build/target.cxx
index aaf8a5e..6315d04 100644
--- a/build/target.cxx
+++ b/build/target.cxx
@@ -116,16 +116,18 @@ namespace build
return *r;
}
- value_proxy target::
+ lookup<const value> target::
operator[] (const variable& var) const
{
+ using result = lookup<const value>;
+
if (auto p = vars.find (var))
- return value_proxy (p, &vars);
+ return result (p, &vars);
if (group != nullptr)
{
if (auto p = group->vars.find (var))
- return value_proxy (p, &group->vars);
+ return result (p, &group->vars);
}
// Cannot simply delegate to scope's operator[] since we also
@@ -135,7 +137,7 @@ namespace build
{
if (!s->target_vars.empty ())
{
- auto find_specific = [&var, s] (const target& t) -> value_proxy
+ auto find_specific = [&var, s] (const target& t) -> result
{
// Search across target type hierarchy.
//
@@ -154,10 +156,10 @@ namespace build
continue;
if (auto p = j->second.find (var))
- return value_proxy (p, &j->second);
+ return result (p, &j->second);
}
- return value_proxy ();
+ return result ();
};
if (auto p = find_specific (*this))
@@ -171,24 +173,24 @@ namespace build
}
if (auto p = s->vars.find (var))
- return value_proxy (p, &s->vars);
+ return result (p, &s->vars);
}
- return value_proxy ();
+ return result ();
}
- value_proxy target::
+ value& target::
append (const variable& var)
{
- value_proxy val (operator[] (var));
+ auto l (operator[] (var));
- if (val && val.belongs (*this)) // Existing variable in this target.
- return val;
+ if (l && l.belongs (*this)) // Existing variable in this target.
+ return const_cast<value&> (*l);
- value_proxy r (assign (var));
+ value& r (assign (var));
- if (val)
- r = val; // Copy value from the outer scope.
+ if (l)
+ r = *l; // Copy value from the outer scope.
return r;
}