diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2011-08-30 13:50:48 -0700 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2011-08-30 13:50:48 -0700 |
| commit | 05d96f155f8bc6eec0e9f3485b47698fb858aa72 (patch) | |
| tree | 4814c9ecf2134338210e1010d337231aade4699d | |
| parent | 7bbe8d2e8c61165d539a9e4d916566a57f59d708 (diff) | |
| download | rust-05d96f155f8bc6eec0e9f3485b47698fb858aa72.tar.gz rust-05d96f155f8bc6eec0e9f3485b47698fb858aa72.zip | |
rustc: Allow non-type-parametric resources to be logged
| -rw-r--r-- | src/rt/rust_shape.cpp | 59 | ||||
| -rw-r--r-- | src/rt/rust_shape.h | 23 |
2 files changed, 62 insertions, 20 deletions
diff --git a/src/rt/rust_shape.cpp b/src/rt/rust_shape.cpp index e80512b92a0..71a11a7d758 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<uint32_t> &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<uintptr_t> &live); void walk_variant(bool align, tag_info &tinfo, uint32_t variant_id, const std::pair<const uint8_t *,const uint8_t *> 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<uintptr_t> &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 d8bb6b64c8f..c2b551f65bc 100644 --- a/src/rt/rust_shape.h +++ b/src/rt/rust_shape.h @@ -453,7 +453,8 @@ ctxt<T>::walk_res(bool align) { uint16_t sp_size = get_u16_bump(sp); const uint8_t *end_sp = sp + sp_size; - static_cast<T *>(this)->walk_res(align, dtor, n_ty_params, ty_params_sp); + static_cast<T *>(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<uintptr_t>::t live = bump_dp<uintptr_t>(dp); // Delegate to the implementation. static_cast<T *>(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<log,ptr>(other.task, other.sp, other.params, other.tables, in_dp), out(other.out) {} - void walk_string(const std::pair<ptr,ptr> &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<const uint8_t *,const uint8_t *> variant_ptr_and_end); + void walk_string(const std::pair<ptr,ptr> &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<typename T> void walk_number() { out << get_dp<T>(dp); } |
