aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-07-28 16:10:08 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-07-28 16:10:08 +0200
commit07ed482f1ad14eb314a17b108f91484e894e5207 (patch)
treefd21cb65e41453eecc184cbbb4fe3a356a6f5ccc
parentb11aaa16d404ce7dc55de6b7338dccbf053a72bd (diff)
Fix dump not to type target type/pattern-specific prepend/append
-rw-r--r--build2/dump.cxx36
-rw-r--r--build2/variable8
2 files changed, 30 insertions, 14 deletions
diff --git a/build2/dump.cxx b/build2/dump.cxx
index a8b02d1..506ebff 100644
--- a/build2/dump.cxx
+++ b/build2/dump.cxx
@@ -57,23 +57,32 @@ namespace build2
static void
dump_variable (ostream& os,
- const variable& var,
- const lookup& org,
+ const variable_map& vm,
+ const variable_map::const_iterator& vi,
const scope& s,
variable_kind k)
{
// Target type/pattern-specific prepends/appends are kept untyped and not
// overriden.
//
- if (k == variable_kind::tt_pat && org->extra != 0)
+ if (k == variable_kind::tt_pat && vi.extra () != 0)
{
// @@ Might be useful to dump the cache.
//
- assert (org->type == nullptr);
- os << var.name << (org->extra == 1 ? " =+ " : " += ");
+ const auto& p (vi.untyped ());
+ const variable& var (p.first);
+ const value& v (p.second);
+ assert (v.type == nullptr);
+
+ os << var.name << (v.extra == 1 ? " =+ " : " += ");
+ dump_value (os, v, false);
}
else
{
+ const auto& p (*vi);
+ const variable& var (p.first);
+ const value& v (p.second);
+
if (var.type != nullptr)
os << '[' << var.type->name << "] ";
@@ -87,11 +96,14 @@ namespace build2
var.name.rfind (".__suffix") == string::npos &&
var.name.rfind (".__prefix") == string::npos)
{
+ lookup org (v, vm);
+
// The original is always from this scope/target, so depth is 1.
//
lookup l (
s.find_override (
var, make_pair (org, 1), k == variable_kind::target).first);
+
assert (l.defined ()); // We at least have the original.
if (org != l)
@@ -100,9 +112,9 @@ namespace build2
os << " # original: ";
}
}
- }
- dump_value (os, *org, org->type != var.type);
+ dump_value (os, v, v.type != var.type);
+ }
}
static void
@@ -112,12 +124,12 @@ namespace build2
const scope& s,
variable_kind k)
{
- for (const auto& e: vars)
+ for (auto i (vars.begin ()), e (vars.end ()); i != e; ++i)
{
os << endl
<< ind;
- dump_variable (os, e.first, lookup (&e.second, &vars), s, k);
+ dump_variable (os, vars, i, s, k);
}
}
@@ -155,11 +167,7 @@ namespace build2
if (vars.size () == 1)
{
os << ' ';
- dump_variable (os,
- vars.begin ()->first,
- lookup (&vars.begin ()->second, &vars),
- s,
- variable_kind::tt_pat);
+ dump_variable (os, vars, vars.begin (), s, variable_kind::tt_pat);
}
else
{
diff --git a/build2/variable b/build2/variable
index f3fc0dd..9888aa0 100644
--- a/build2/variable
+++ b/build2/variable
@@ -720,8 +720,16 @@ namespace build2
{
iterator_adapter () = default;
iterator_adapter (const I& i): I (i) {}
+
+ // Automatically type a newly typed value on access.
+ //
typename I::reference operator* () const;
typename I::pointer operator-> () const;
+
+ // Untyped access.
+ //
+ uint16_t extra () const {return I::operator* ().second.extra;}
+ typename I::reference untyped () const {return I::operator* ();}
};
using const_iterator = iterator_adapter<map_type::const_iterator>;