aboutsummaryrefslogtreecommitdiff
path: root/build/dump.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-02-27 16:57:34 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-02-27 16:57:34 +0200
commit4372f041bb7401c3adc2d5710566b13f64722102 (patch)
tree5f37f6e69e5529d3628b7611bb642dba15d885c0 /build/dump.cxx
parente1d2e3b63934c1e193429f1d6c4e04abc0e85d56 (diff)
Variable assignment, appending support
Diffstat (limited to 'build/dump.cxx')
-rw-r--r--build/dump.cxx72
1 files changed, 72 insertions, 0 deletions
diff --git a/build/dump.cxx b/build/dump.cxx
new file mode 100644
index 0000000..4294e92
--- /dev/null
+++ b/build/dump.cxx
@@ -0,0 +1,72 @@
+// file : build/dump.cxx -*- C++ -*-
+// copyright : Copyright (c) 2014-2015 Code Synthesis Tools CC
+// license : MIT; see accompanying LICENSE file
+
+#include <build/dump>
+
+#include <string>
+#include <cassert>
+#include <iostream>
+
+#include <build/scope>
+#include <build/variable>
+#include <build/diagnostics>
+
+using namespace std;
+
+namespace build
+{
+ static void
+ dump_scope (scope& p, scope_map::iterator& i, string& ind)
+ {
+ string d (diag_relative_work (p.path ()));
+
+ if (d.back () != path::traits::directory_separator)
+ d += '/';
+
+ cerr << ind << d << ":" << endl
+ << ind << '{' << endl;
+
+ ind += " ";
+
+ for (const auto& e: p.variables)
+ {
+ const variable& var (e.first);
+ const value_ptr& val (e.second);
+
+ cerr << ind << var.name << " = ";
+
+ if (val == nullptr)
+ cerr << "[undefined]";
+ else
+ {
+ //@@ TODO: assuming it is a list.
+ //
+ cerr << dynamic_cast<list_value&> (*val).data;
+ }
+
+ cerr << endl;
+ }
+
+ // Print nested scopes of which we are a parent.
+ //
+ for (auto e (scopes.end ()); i != e && i->second.parent () == &p; )
+ {
+ scope& s (i->second);
+ dump_scope (s, ++i, ind);
+ }
+
+ ind.resize (ind.size () - 2);
+ cerr << ind << '}' << endl;
+ }
+
+ void
+ dump_scopes ()
+ {
+ string ind;
+ auto i (scopes.begin ());
+ scope& r (i->second); // Root scope.
+ assert (&r == root_scope);
+ dump_scope (r, ++i, ind);
+ }
+}