aboutsummaryrefslogtreecommitdiff
path: root/build/dump.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-07-29 12:20:53 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-07-29 12:20:53 +0200
commit729b56300c441a0d63c7d2013eb5a881211d352b (patch)
treed363c5f282b910e1f014161e24c6dfc6a5fcba40 /build/dump.cxx
parent1cf1603cae3064aff734f52d23c06098e81a8111 (diff)
Initial support for target type/pattern-specific variables
Diffstat (limited to 'build/dump.cxx')
-rw-r--r--build/dump.cxx97
1 files changed, 78 insertions, 19 deletions
diff --git a/build/dump.cxx b/build/dump.cxx
index 6b6debe..e426f0b 100644
--- a/build/dump.cxx
+++ b/build/dump.cxx
@@ -18,32 +18,76 @@ using namespace std;
namespace build
{
- static bool
- dump_variables (ostream& os, string& ind, const variable_map& vars)
+ static void
+ dump_variable (ostream& os, const variable& var, const value_ptr& val)
{
- bool r (false);
+ os << var.name << " = ";
- for (const auto& e: vars)
+ if (val == nullptr)
+ os << "[null]";
+ else
{
- const variable& var (e.first);
- const value_ptr& val (e.second);
+ //@@ TODO: assuming it is a list.
+ //
+ os << dynamic_cast<list_value&> (*val);
+ }
+ }
+ static void
+ dump_variables (ostream& os, string& ind, const variable_map& vars)
+ {
+ for (const auto& e: vars)
+ {
os << endl
- << ind << var.name << " = ";
+ << ind;
- if (val == nullptr)
- os << "[null]";
- else
+ dump_variable (os, e.first, e.second);
+ }
+ }
+
+ static void
+ dump_variables (ostream& os, string& ind, const variable_type_map& vtm)
+ {
+ for (const auto& vt: vtm)
+ {
+ const target_type& t (vt.first);
+ const variable_pattern_map& vpm (vt.second);
+
+ for (const auto& vp: vpm)
{
- //@@ TODO: assuming it is a list.
- //
- os << dynamic_cast<list_value&> (*val);
- }
+ const string p (vp.first);
+ const variable_map& vars (vp.second);
- r = true;
- }
+ os << endl
+ << ind;
+
+ if (t.id != target::static_type.id)
+ os << t.name << '{';
+
+ os << p;
+
+ if (t.id != target::static_type.id)
+ os << '}';
+
+ os << ':';
- return r;
+ if (vars.size () == 1)
+ {
+ os << ' ';
+ dump_variable (os, vars.begin ()->first, vars.begin ()->second);
+ }
+ else
+ {
+ os << endl
+ << ind << '{';
+ ind += " ";
+ dump_variables (os, ind, vars);
+ ind.resize (ind.size () - 2);
+ os << endl
+ << ind << '}';
+ }
+ }
+ }
}
static void
@@ -120,9 +164,24 @@ namespace build
bool vb (false), sb (false); // Variable/scope block.
- // Variables.
+ // Target type/pattern-sepcific variables.
+ //
+ if (!p.target_vars.empty ())
+ {
+ dump_variables (os, ind, p.target_vars);
+ vb = true;
+ }
+
+ // Scope variables.
//
- vb = dump_variables (os, ind, p.vars);
+ if (!p.vars.empty ())
+ {
+ if (vb)
+ os << endl;
+
+ dump_variables (os, ind, p.vars);
+ vb = true;
+ }
// Nested scopes of which we are a parent.
//