rt: Fix logging of type-parametric resources

This commit is contained in:
Patrick Walton 2011-08-30 15:56:42 -07:00
parent 05d96f155f
commit b722dc36a5
3 changed files with 31 additions and 31 deletions

View File

@ -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));
}

View File

@ -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)

View File

@ -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); }