From e5531504c9309126eb486c6d1cd4437e343c63fa Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Mon, 8 Aug 2011 17:29:21 -0700 Subject: rt: Align when comparing the insides of boxes --- src/rt/rust_shape.cpp | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'src/rt/rust_shape.cpp') diff --git a/src/rt/rust_shape.cpp b/src/rt/rust_shape.cpp index 551cf547a2e..dfc4d20f496 100644 --- a/src/rt/rust_shape.cpp +++ b/src/rt/rust_shape.cpp @@ -910,7 +910,9 @@ class copy : public data { class cmp : public data { private: template - int cmp_number(ptr_pair &ptrs); + void cmp_number(const data_pair &nums) { + result = (nums.fst < nums.snd) ? -1 : (nums.fst == nums.snd) ? 0 : 1; + } public: int result; @@ -933,12 +935,12 @@ public: void walk_box(bool align); void walk_struct(bool align, const uint8_t *end_sp); void walk_tag(bool align, tag_info &tinfo, - data_pair &tag_variants); + const data_pair &tag_variants); void walk_res(bool align, const rust_fn *dtor, uint16_t n_ty_params, const uint8_t *ty_params_sp); template - void walk_number() { result = cmp_number(dp); } + void walk_number() { cmp_number(bump_dp(dp)); } }; void @@ -946,7 +948,7 @@ cmp::walk_box(bool align) { data_pair subdp = bump_dp(dp); cmp subcx(*this, ptr_pair::make(subdp)); subcx.dp += sizeof(uint32_t); // Skip over the reference count. - subcx.walk(false); + subcx.walk(true); result = subcx.result; } @@ -960,7 +962,10 @@ cmp::walk_struct(bool align, const uint8_t *end_sp) { void cmp::walk_tag(bool align, tag_info &tinfo, - data_pair &tag_variants) { + const data_pair &tag_variants) { + cmp_number(tag_variants); + if (result != 0) + return; abort(); // TODO } @@ -970,14 +975,6 @@ cmp::walk_res(bool align, const rust_fn *dtor, uint16_t n_ty_params, abort(); // TODO } -template -int -cmp::cmp_number(ptr_pair &ptrs) { - T a = *(reinterpret_cast(dp.fst)); - T b = *(reinterpret_cast(dp.snd)); - return (a < b) ? -1 : (a == b) ? 0 : 1; -} - } // end namespace shape extern "C" void -- cgit 1.4.1-3-g733a5