aboutsummaryrefslogtreecommitdiff
path: root/build2/parser.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-02-10 14:26:16 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-02-13 12:42:42 +0200
commitdbd30777d1c60bdcdff226b5f97582dba0bba4ba (patch)
tree30b2beaf482201e11282eb884243f301678305b5 /build2/parser.cxx
parent92b98aee1eb9f9550634720b96eec0be1831ebb7 (diff)
Allow back overriding variables specified in buildfiles
It is still not clear whether this is the right thing to allow, conceptually, but with this disallowed it's hard to test this functionality. Perhaps we should have an attribute [overridable]. The problem is one will also have to set this variable to some value (e.g., [null]) which is not exactly the same as undefined (especially when testing).
Diffstat (limited to 'build2/parser.cxx')
-rw-r--r--build2/parser.cxx17
1 files changed, 11 insertions, 6 deletions
diff --git a/build2/parser.cxx b/build2/parser.cxx
index 2ffd0cf..154c123 100644
--- a/build2/parser.cxx
+++ b/build2/parser.cxx
@@ -458,7 +458,8 @@ namespace build2
const variable& var (
var_pool.rw (*scope_).insert (
- parse_variable_name (move (pns), ploc)));
+ parse_variable_name (move (pns), ploc),
+ true)); // Allow overrides.
// Apply variable attributes.
//
@@ -727,7 +728,8 @@ namespace build2
{
const variable& var (
var_pool.rw (*scope_).insert (
- parse_variable_name (move (ns), nloc)));
+ parse_variable_name (move (ns), nloc),
+ true)); // Allow overrides.
// Apply variable attributes.
//
@@ -1054,7 +1056,7 @@ namespace build2
auto& vp (var_pool.rw (*scope_));
if (p != string::npos)
- var = &vp.insert (split (p));
+ var = &vp.insert (split (p), true); // Allow overrides.
//
// This could still be the 'foo =...' case.
//
@@ -1069,7 +1071,7 @@ namespace build2
(v[p = 0] == '=' ||
(n > 1 && v[0] == '+' && v[p = 1] == '=')))
{
- var = &vp.insert (move (t.value));
+ var = &vp.insert (move (t.value), true); // Allow overrides.
next (t, tt); // Get the peeked token.
split (p); // Returned name should be empty.
}
@@ -1593,7 +1595,10 @@ namespace build2
if (type != nullptr)
{
if (var.type == nullptr)
- var_pool.update (const_cast<variable&> (var), type);
+ {
+ const bool o (true); // Allow overrides.
+ var_pool.update (const_cast<variable&> (var), type, nullptr, &o);
+ }
else if (var.type != type)
fail (l) << "changing variable " << var << " type from "
<< var.type->name << " to " << type->name;
@@ -3502,7 +3507,7 @@ namespace build2
// Lookup.
//
- const auto& var (var_pool.rw (*scope_).insert (move (name)));
+ const auto& var (var_pool.rw (*scope_).insert (move (name), true));
return target_ != nullptr ? (*target_)[var] : (*scope_)[var];
// Undefined/NULL namespace variables are not allowed.