about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2011-08-30 15:56:42 -0700
committerPatrick Walton <pcwalton@mimiga.net>2011-08-30 15:56:42 -0700
commitb722dc36a5b3db7e3b8445103644d1a23c85796d (patch)
treedf54a16bf95533c5fccd5bc6b93ee5c195649474
parent05d96f155f8bc6eec0e9f3485b47698fb858aa72 (diff)
rt: Fix logging of type-parametric resources
-rw-r--r--src/comp/middle/shape.rs6
-rw-r--r--src/rt/rust_shape.cpp22
-rw-r--r--src/rt/rust_shape.h34
3 files changed, 31 insertions, 31 deletions
diff --git a/src/comp/middle/shape.rs b/src/comp/middle/shape.rs
index 3c74e829e9d..5fe85200564 100644
--- a/src/comp/middle/shape.rs
+++ b/src/comp/middle/shape.rs
@@ -395,11 +395,7 @@ fn shape_of(ccx: &@crate_ctxt, t: ty::t) -> [u8] {
         s += [shape_res];
         add_u16(s, id as u16);
         add_u16(s, vec::len(tps) as u16);
-
-        let sub = [];
-        for tp: ty::t in tps { add_substr(s, sub); }
-        add_substr(s, sub);
-
+        for tp: ty::t in tps { add_substr(s, shape_of(ccx, tp)); }
         add_substr(s, shape_of(ccx, subt));
 
       }
diff --git a/src/rt/rust_shape.cpp b/src/rt/rust_shape.cpp
index 71a11a7d758..091dd8e2d36 100644
--- a/src/rt/rust_shape.cpp
+++ b/src/rt/rust_shape.cpp
@@ -110,21 +110,22 @@ 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 *end_sp) {
+print::walk_res(bool align, const rust_fn *dtor, unsigned n_params,
+                const type_param *params, const uint8_t *end_sp) {
     DPRINT("res@%p", dtor);
 
     // Print type parameters.
-    if (n_ty_params) {
+    if (n_params) {
         DPRINT("<");
 
         bool first = true;
-        for (uint16_t i = 0; i < n_ty_params; i++) {
+        for (uint16_t i = 0; i < n_params; i++) {
             if (!first)
                 DPRINT(",");
             first = false;
-            get_u16_bump(sp);   // Skip over the size.
-            walk(align);
+
+            ctxt<print> sub(*this, params[i].shape);
+            sub.walk(align);
         }
 
         DPRINT(">");
@@ -347,7 +348,7 @@ 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 *end_sp,
+                  const type_param *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 *>
@@ -400,7 +401,7 @@ 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 *end_sp,
+              const type_param *ty_params_sp, const uint8_t *end_sp,
               const data_pair<uintptr_t> &live) {
     abort();    // TODO
 }
@@ -502,9 +503,8 @@ log::walk_variant(bool align, tag_info &tinfo, uint32_t variant_id,
 }
 
 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) {
+log::walk_res(bool align, const rust_fn *dtor, unsigned n_params,
+              const type_param *params, const uint8_t *end_sp, bool live) {
     out << "res";
 
     if (this->sp == end_sp)
diff --git a/src/rt/rust_shape.h b/src/rt/rust_shape.h
index c2b551f65bc..e871900d65f 100644
--- a/src/rt/rust_shape.h
+++ b/src/rt/rust_shape.h
@@ -446,14 +446,19 @@ ctxt<T>::walk_res(bool align) {
 
     uint16_t n_ty_params = get_u16_bump(sp);
 
-    uint16_t ty_params_size = get_u16_bump(sp);
-    const uint8_t *ty_params_sp = sp;
-    sp += ty_params_size;
+    // Read in the tag type parameters.
+    type_param params[n_ty_params];
+    for (uint16_t i = 0; i < n_ty_params; i++) {
+        uint16_t ty_param_len = get_u16_bump(sp);
+        const uint8_t *next_sp = sp + ty_param_len;
+        params[i].set(this);
+        sp = next_sp;
+    }
 
     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, params,
                                      end_sp);
 
     sp = end_sp;
@@ -479,8 +484,8 @@ 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 *end_sp);
+    void walk_res(bool align, const rust_fn *dtor, unsigned n_params,
+                  const type_param *params, 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,8 +564,8 @@ public:
         sa = sub.sa;
     }
 
-    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) {
+    void walk_res(bool align, const rust_fn *dtor, unsigned n_params,
+                  const type_param *params, const uint8_t *end_sp) {
         abort();    // TODO
     }
 
@@ -788,12 +793,12 @@ public:
         dp = next_dp;
     }
 
-    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) {
+    void walk_res(bool align, const rust_fn *dtor, unsigned n_params,
+                  const type_param *params, 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, end_sp, live);
+        static_cast<T *>(this)->walk_res(align, dtor, n_params, params,
+                                         end_sp, live);
     }
 
     void walk_var(bool align, uint8_t param_index) {
@@ -1006,9 +1011,8 @@ private:
                       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);
+    void walk_res(bool align, const rust_fn *dtor, unsigned n_params,
+                  const type_param *params, const uint8_t *end_sp, bool live);
 
     template<typename T>
     void walk_number() { out << get_dp<T>(dp); }