From 2c54b464080f0f4cb42fd712e10657a1d100735f Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Sat, 20 Aug 2011 10:19:45 -0700 Subject: [PATCH] Revert "Shuffle around definitions in rust_shape.h" This reverts commit d09b421d55d3772516181cfa5b791be485389876. --- src/rt/rust_shape.h | 220 ++++++++++++++++++++++---------------------- 1 file changed, 110 insertions(+), 110 deletions(-) diff --git a/src/rt/rust_shape.h b/src/rt/rust_shape.h index f21e6d68ca7..d0e72005a34 100644 --- a/src/rt/rust_shape.h +++ b/src/rt/rust_shape.h @@ -244,116 +244,6 @@ struct type_param { }; -// Pointer wrappers for data traversals - -class ptr { -private: - uint8_t *p; - -public: - template - struct data { typedef T t; }; - - ptr(uint8_t *in_p) - : p(in_p) {} - - ptr(uintptr_t in_p) - : p((uint8_t *)in_p) {} - - inline ptr operator+(const size_t amount) const { - return make(p + amount); - } - inline ptr &operator+=(const size_t amount) { p += amount; return *this; } - inline bool operator<(const ptr other) { return p < other.p; } - inline ptr operator++() { ptr rv(*this); p++; return rv; } - inline uint8_t operator*() { return *p; } - - template - inline operator T *() { return (T *)p; } - - inline operator uintptr_t() { return (uintptr_t)p; } - - static inline ptr make(uint8_t *in_p) { - ptr self(in_p); - return self; - } -}; - -template -static inline T -bump_dp(ptr &dp) { - T x = *((T *)dp); - dp += sizeof(T); - return x; -} - -template -static inline T -get_dp(ptr dp) { - return *((T *)dp); -} - - -// Pointer pairs for structural comparison - -template -class data_pair { -public: - T fst, snd; - - data_pair() {} - data_pair(T &in_fst, T &in_snd) : fst(in_fst), snd(in_snd) {} - - inline void operator=(const T rhs) { fst = snd = rhs; } - - static data_pair make(T &fst, T &snd) { - data_pair data(fst, snd); - return data; - } -}; - -class ptr_pair { -public: - uint8_t *fst, *snd; - - template - struct data { typedef data_pair t; }; - - ptr_pair(uint8_t *in_fst, uint8_t *in_snd) : fst(in_fst), snd(in_snd) {} - - ptr_pair(data_pair &other) : fst(other.fst), snd(other.snd) {} - - inline void operator=(uint8_t *rhs) { fst = snd = rhs; } - - inline ptr_pair operator+(size_t n) const { - return make(fst + n, snd + n); - } - - inline ptr_pair operator+=(size_t n) { - fst += n; snd += n; - return *this; - } - - inline ptr_pair operator-(size_t n) const { - return make(fst - n, snd - n); - } - - inline bool operator<(const ptr_pair &other) const { - return fst < other.fst && snd < other.snd; - } - - static inline ptr_pair make(uint8_t *fst, uint8_t *snd) { - ptr_pair self(fst, snd); - return self; - } - - static inline ptr_pair make(const data_pair &pair) { - ptr_pair self(pair.fst, pair.snd); - return self; - } -}; - - // Traversals #define WALK_NUMBER(c_type) \ @@ -665,6 +555,116 @@ public: } }; + +// Pointer wrappers for data traversals + +class ptr { +private: + uint8_t *p; + +public: + template + struct data { typedef T t; }; + + ptr(uint8_t *in_p) + : p(in_p) {} + + ptr(uintptr_t in_p) + : p((uint8_t *)in_p) {} + + inline ptr operator+(const size_t amount) const { + return make(p + amount); + } + inline ptr &operator+=(const size_t amount) { p += amount; return *this; } + inline bool operator<(const ptr other) { return p < other.p; } + inline ptr operator++() { ptr rv(*this); p++; return rv; } + inline uint8_t operator*() { return *p; } + + template + inline operator T *() { return (T *)p; } + + inline operator uintptr_t() { return (uintptr_t)p; } + + static inline ptr make(uint8_t *in_p) { + ptr self(in_p); + return self; + } +}; + +template +static inline T +bump_dp(ptr &dp) { + T x = *((T *)dp); + dp += sizeof(T); + return x; +} + +template +static inline T +get_dp(ptr dp) { + return *((T *)dp); +} + + +// Pointer pairs for structural comparison + +template +class data_pair { +public: + T fst, snd; + + data_pair() {} + data_pair(T &in_fst, T &in_snd) : fst(in_fst), snd(in_snd) {} + + inline void operator=(const T rhs) { fst = snd = rhs; } + + static data_pair make(T &fst, T &snd) { + data_pair data(fst, snd); + return data; + } +}; + +class ptr_pair { +public: + uint8_t *fst, *snd; + + template + struct data { typedef data_pair t; }; + + ptr_pair(uint8_t *in_fst, uint8_t *in_snd) : fst(in_fst), snd(in_snd) {} + + ptr_pair(data_pair &other) : fst(other.fst), snd(other.snd) {} + + inline void operator=(uint8_t *rhs) { fst = snd = rhs; } + + inline ptr_pair operator+(size_t n) const { + return make(fst + n, snd + n); + } + + inline ptr_pair operator+=(size_t n) { + fst += n; snd += n; + return *this; + } + + inline ptr_pair operator-(size_t n) const { + return make(fst - n, snd - n); + } + + inline bool operator<(const ptr_pair &other) const { + return fst < other.fst && snd < other.snd; + } + + static inline ptr_pair make(uint8_t *fst, uint8_t *snd) { + ptr_pair self(fst, snd); + return self; + } + + static inline ptr_pair make(const data_pair &pair) { + ptr_pair self(pair.fst, pair.snd); + return self; + } +}; + } // end namespace shape