about summary refs log tree commit diff
path: root/src/rt
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2011-08-31 16:22:19 -0700
committerPatrick Walton <pcwalton@mimiga.net>2011-08-31 16:22:19 -0700
commitdc6f78561c238c472a6bab50eea36f4b3a39671d (patch)
treed899a00b92a63881f83b752984c05a3fda85dd4d /src/rt
parentdfcbfa61f3cbc331f4ab0ecf7fdd71b5faea773a (diff)
downloadrust-dc6f78561c238c472a6bab50eea36f4b3a39671d.tar.gz
rust-dc6f78561c238c472a6bab50eea36f4b3a39671d.zip
rt: Prevent trailing commas from showing up when logging oddly aligned arrays
Diffstat (limited to 'src/rt')
-rw-r--r--src/rt/rust_shape.cpp13
-rw-r--r--src/rt/rust_shape.h27
2 files changed, 24 insertions, 16 deletions
diff --git a/src/rt/rust_shape.cpp b/src/rt/rust_shape.cpp
index a693684fa89..066bc1a115c 100644
--- a/src/rt/rust_shape.cpp
+++ b/src/rt/rust_shape.cpp
@@ -426,7 +426,7 @@ cmp::walk_variant(tag_info &tinfo, uint32_t variant_id,
 
 void
 log::walk_string(const std::pair<ptr,ptr> &data) {
-    out << "\"" << std::hex;
+    out << prefix << "\"" << std::hex;
 
     ptr subdp = data.first;
     while (subdp < data.second) {
@@ -443,7 +443,7 @@ log::walk_string(const std::pair<ptr,ptr> &data) {
 
 void
 log::walk_struct(const uint8_t *end_sp) {
-    out << "(";
+    out << prefix << "(";
 
     bool first = true;
     while (sp != end_sp) {
@@ -464,16 +464,15 @@ log::walk_vec(bool is_pod, const std::pair<ptr,ptr> &data) {
         return;
     }
 
-    out << "[";
+    out << prefix << "[";
 
     log sub(*this, data.first);
     sub.end_dp = data.second;
 
-    bool first = true;
     while (sub.dp < data.second) {
-        if (!first) out << ", ";
         sub.walk_reset();
-        sub.align = true, first = false;
+        sub.align = true;
+        sub.prefix = ", ";
     }
 
     out << "]";
@@ -500,7 +499,7 @@ log::walk_variant(tag_info &tinfo, uint32_t variant_id,
 void
 log::walk_res(const rust_fn *dtor, unsigned n_params,
               const type_param *params, const uint8_t *end_sp, bool live) {
-    out << "res";
+    out << prefix << "res";
 
     if (this->sp == end_sp)
         return;
diff --git a/src/rt/rust_shape.h b/src/rt/rust_shape.h
index dacfddba049..bf8247ec0dc 100644
--- a/src/rt/rust_shape.h
+++ b/src/rt/rust_shape.h
@@ -974,6 +974,7 @@ class log : public data<log,ptr> {
 
 private:
     std::ostream &out;
+    const char *prefix;
     bool in_string;
 
     log(log &other,
@@ -986,7 +987,8 @@ private:
                     in_params,
                     in_tables ? in_tables : other.tables,
                     other.dp),
-      out(other.out) {}
+      out(other.out),
+      prefix("") {}
 
     log(log &other,
         const uint8_t *in_sp,
@@ -999,7 +1001,8 @@ private:
                     in_params,
                     in_tables,
                     in_dp),
-      out(other.out) {}
+      out(other.out),
+      prefix("") {}
 
     log(log &other, ptr in_dp)
     : data<log,ptr>(other.task,
@@ -1008,7 +1011,8 @@ private:
                     other.params,
                     other.tables,
                     in_dp),
-      out(other.out) {}
+      out(other.out),
+      prefix("") {}
 
     void walk_evec(bool is_pod, uint16_t sp_size) {
         walk_vec(is_pod, get_evec_data_range(dp));
@@ -1019,28 +1023,29 @@ private:
     }
 
     void walk_tag(tag_info &tinfo, uint32_t tag_variant) {
-        out << "tag" << tag_variant;
+        out << prefix << "tag" << tag_variant;
         data<log,ptr>::walk_variant(tinfo, tag_variant);
     }
 
     void walk_box() {
-        out << "@";
+        out << prefix << "@";
         data<log,ptr>::walk_box_contents();
     }
 
     void walk_fn() {
-        out << "fn";
+        out << prefix << "fn";
         data<log,ptr>::walk_fn_contents(dp);
     }
 
     void walk_obj() {
-        out << "obj";
+        out << prefix << "obj";
         data<log,ptr>::walk_obj_contents(dp);
     }
 
     void walk_subcontext(log &sub) { sub.walk(); }
 
     void walk_box_contents(log &sub, ptr &ref_count_dp) {
+        out << prefix;
         if (!ref_count_dp) {
             out << "(null)";
         } else {
@@ -1059,7 +1064,10 @@ private:
                   const type_param *params, const uint8_t *end_sp, bool live);
 
     template<typename T>
-    inline void walk_number() { fmt_number(out, get_dp<T>(dp)); }
+    inline void walk_number() {
+        out << prefix;
+        fmt_number(out, get_dp<T>(dp));
+    }
 
 public:
     log(rust_task *in_task,
@@ -1070,7 +1078,8 @@ public:
         uint8_t *in_data,
         std::ostream &in_out)
     : data<log,ptr>(in_task, in_align, in_sp, in_params, in_tables, in_data),
-      out(in_out) {}
+      out(in_out),
+      prefix("") {}
 };
 
 }   // end namespace shape