diff --git a/src/rt/rust_shape.cpp b/src/rt/rust_shape.cpp index e80512b92a01..71a11a7d7586 100644 --- a/src/rt/rust_shape.cpp +++ b/src/rt/rust_shape.cpp @@ -111,23 +111,42 @@ print::walk_struct(bool align, const uint8_t *end_sp) { void print::walk_res(bool align, const rust_fn *dtor, uint16_t n_ty_params, - const uint8_t *ty_params_sp) { + const uint8_t *ty_params_sp, const uint8_t *end_sp) { DPRINT("res@%p", dtor); - if (!n_ty_params) + + // Print type parameters. + if (n_ty_params) { + DPRINT("<"); + + bool first = true; + for (uint16_t i = 0; i < n_ty_params; i++) { + if (!first) + DPRINT(","); + first = false; + get_u16_bump(sp); // Skip over the size. + walk(align); + } + + DPRINT(">"); + } + + // Print arguments. + + if (sp == end_sp) return; - DPRINT("<"); + DPRINT("("); bool first = true; - for (uint16_t i = 0; i < n_ty_params; i++) { + while (sp != end_sp) { if (!first) DPRINT(","); first = false; - get_u16_bump(sp); // Skip over the size. + walk(align); } - DPRINT(">"); + DPRINT(")"); } void @@ -328,7 +347,8 @@ public: const data_pair &tag_variants); void walk_struct(bool align, const uint8_t *end_sp); void walk_res(bool align, const rust_fn *dtor, uint16_t n_ty_params, - const uint8_t *ty_params_sp); + const uint8_t *ty_params_sp, const uint8_t *end_sp, + const data_pair &live); void walk_variant(bool align, tag_info &tinfo, uint32_t variant_id, const std::pair variant_ptr_and_end); @@ -380,7 +400,8 @@ cmp::walk_struct(bool align, const uint8_t *end_sp) { void cmp::walk_res(bool align, const rust_fn *dtor, uint16_t n_ty_params, - const uint8_t *ty_params_sp) { + const uint8_t *ty_params_sp, const uint8_t *end_sp, + const data_pair &live) { abort(); // TODO } @@ -480,6 +501,28 @@ log::walk_variant(bool align, tag_info &tinfo, uint32_t variant_id, out << ")"; } +void +log::walk_res(bool align, const rust_fn *dtor, uint16_t n_ty_params, + const uint8_t *ty_params_sp, const uint8_t *end_sp, + bool live) { + out << "res"; + + if (this->sp == end_sp) + return; + + out << "("; + + bool first = true; + while (sp != end_sp) { + if (!first) + out << ", "; + walk(align); + align = true, first = false; + } + + out << ")"; +} + } // end namespace shape extern "C" void diff --git a/src/rt/rust_shape.h b/src/rt/rust_shape.h index d8bb6b64c8ff..c2b551f65bc5 100644 --- a/src/rt/rust_shape.h +++ b/src/rt/rust_shape.h @@ -453,7 +453,8 @@ ctxt::walk_res(bool align) { uint16_t sp_size = get_u16_bump(sp); const uint8_t *end_sp = sp + sp_size; - static_cast(this)->walk_res(align, dtor, n_ty_params, ty_params_sp); + static_cast(this)->walk_res(align, dtor, n_ty_params, ty_params_sp, + end_sp); sp = end_sp; } @@ -479,7 +480,7 @@ public: void walk_tag(bool align, tag_info &tinfo); void walk_struct(bool align, const uint8_t *end_sp); void walk_res(bool align, const rust_fn *dtor, uint16_t n_ty_params, - const uint8_t *ty_params_sp); + const uint8_t *ty_params_sp, const uint8_t *end_sp); void walk_var(bool align, uint8_t param); void walk_evec(bool align, bool is_pod, uint16_t sp_size) { @@ -559,7 +560,7 @@ public: } void walk_res(bool align, const rust_fn *dtor, uint16_t n_ty_params, - const uint8_t *ty_params_sp) { + const uint8_t *ty_params_sp, const uint8_t *end_sp) { abort(); // TODO } @@ -788,10 +789,11 @@ public: } void walk_res(bool align, const rust_fn *dtor, uint16_t n_ty_params, - const uint8_t *ty_params_sp) { + const uint8_t *ty_params_sp, const uint8_t *end_sp) { + typename U::template data::t live = bump_dp(dp); // Delegate to the implementation. static_cast(this)->walk_res(align, dtor, n_ty_params, - ty_params_sp); + ty_params_sp, end_sp, live); } void walk_var(bool align, uint8_t param_index) { @@ -957,8 +959,6 @@ private: : data(other.task, other.sp, other.params, other.tables, in_dp), out(other.out) {} - void walk_string(const std::pair &data); - void walk_evec(bool align, bool is_pod, uint16_t sp_size) { walk_vec(align, is_pod, get_evec_data_range(dp)); } @@ -991,11 +991,6 @@ private: void walk_chan(bool align) { out << "chan"; } void walk_task(bool align) { out << "task"; } - void walk_res(bool align, const rust_fn *dtor, uint16_t n_ty_params, - const uint8_t *ty_params_sp) { - out << "res"; // TODO - } - void walk_subcontext(bool align, log &sub) { sub.walk(align); } void walk_box_contents(bool align, log &sub, ptr &ref_count_dp) { @@ -1010,6 +1005,10 @@ private: void walk_variant(bool align, tag_info &tinfo, uint32_t variant_id, const std::pair variant_ptr_and_end); + void walk_string(const std::pair &data); + void walk_res(bool align, const rust_fn *dtor, uint16_t n_ty_params, + const uint8_t *ty_params_sp, const uint8_t *end_sp, + bool live); template void walk_number() { out << get_dp(dp); }