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 &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 &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 &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 { 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(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::walk_variant(tinfo, tag_variant); } void walk_box() { - out << "@"; + out << prefix << "@"; data::walk_box_contents(); } void walk_fn() { - out << "fn"; + out << prefix << "fn"; data::walk_fn_contents(dp); } void walk_obj() { - out << "obj"; + out << prefix << "obj"; data::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 - inline void walk_number() { fmt_number(out, get_dp(dp)); } + inline void walk_number() { + out << prefix; + fmt_number(out, get_dp(dp)); + } public: log(rust_task *in_task, @@ -1070,7 +1078,8 @@ public: uint8_t *in_data, std::ostream &in_out) : data(in_task, in_align, in_sp, in_params, in_tables, in_data), - out(in_out) {} + out(in_out), + prefix("") {} }; } // end namespace shape