diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2011-08-08 17:29:21 -0700 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2011-08-08 17:30:21 -0700 |
| commit | e5531504c9309126eb486c6d1cd4437e343c63fa (patch) | |
| tree | d2c383143ad3a0c86e9af5c36a238ba9ccc56fa3 /src/rt/rust_shape.cpp | |
| parent | 0459e38bde043cff95f026df6ca5482a93f287cc (diff) | |
| download | rust-e5531504c9309126eb486c6d1cd4437e343c63fa.tar.gz rust-e5531504c9309126eb486c6d1cd4437e343c63fa.zip | |
rt: Align when comparing the insides of boxes
Diffstat (limited to 'src/rt/rust_shape.cpp')
| -rw-r--r-- | src/rt/rust_shape.cpp | 23 |
1 files changed, 10 insertions, 13 deletions
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<copy,uint8_t *> { class cmp : public data<cmp,ptr_pair> { private: template<typename T> - int cmp_number(ptr_pair &ptrs); + void cmp_number(const data_pair<T> &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<uint32_t> &tag_variants); + const data_pair<uint32_t> &tag_variants); void walk_res(bool align, const rust_fn *dtor, uint16_t n_ty_params, const uint8_t *ty_params_sp); template<typename T> - void walk_number() { result = cmp_number<T>(dp); } + void walk_number() { cmp_number(bump_dp<T>(dp)); } }; void @@ -946,7 +948,7 @@ cmp::walk_box(bool align) { data_pair<uint8_t *> subdp = bump_dp<uint8_t *>(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<uint32_t> &tag_variants) { + const data_pair<uint32_t> &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<typename T> -int -cmp::cmp_number(ptr_pair &ptrs) { - T a = *(reinterpret_cast<T *>(dp.fst)); - T b = *(reinterpret_cast<T *>(dp.snd)); - return (a < b) ? -1 : (a == b) ? 0 : 1; -} - } // end namespace shape extern "C" void |
