KJS::SimpleNumber on 64 bit machines
Maciej Stachowiak
mjs at apple.com
Wed Oct 1 16:16:54 CEST 2003
On Oct 1, 2003, at 1:21 PM, Maciej Stachowiak wrote:
> Index: kjs/simple_number.h
> ===================================================================
> RCS file:
> /local/home/cvs/Labyrinth/JavaScriptCore/kjs/simple_number.h,v
> retrieving revision 1.7
> diff -u -p -r1.7 kjs/simple_number.h
> --- kjs/simple_number.h 2003/01/22 00:11:44 1.7
> +++ kjs/simple_number.h 2003/10/01 20:17:59
> @@ -31,17 +31,17 @@ namespace KJS {
>
> class SimpleNumber {
> public:
> - enum { tag = 1, shift = 2, mask = (1 << shift) - 1, sign = 1 << 31,
> max = (1 << (31 - shift)) - 1, min = -max - 1 };
> + enum { tag = 1, shift = 2, mask = (1 << shift) - 1, sign = 1 <<
> (sizeof(long) * 8 - 1), max = (1 << ((sizeof(long) * 8 - 1) - shift))
> - 1, min = -max - 1 };
>
> - static inline bool is(const ValueImp *imp) { return ((int)imp &
> mask) == tag; }
> - static inline int value(const ValueImp *imp) { return ((int)imp >>
> shift) | (((int)imp & sign) ? ~max : 0); }
> + static inline bool is(const ValueImp *imp) { return ((long)imp &
> mask) == tag; }
> + static inline int value(const ValueImp *imp) { return ((long)imp >>
> shift) | (((long)imp & sign) ? ~max : 0); }
Darin pointed out that value() should be returning a long (an oversight
on my part).
>
> static inline bool fits(int i) { return i <= max && i >= min; }
> static inline bool fits(unsigned i) { return i <= (unsigned)max; }
> static inline bool fits(long i) { return i <= max && i >= min; }
> static inline bool fits(unsigned long i) { return i <=
> (unsigned)max; }
> static inline bool fits(double d) { return d <= max && d >= min && d
> == (double)(int)d; }
> - static inline ValueImp *make(int i) { return (ValueImp *)((i <<
> shift) | tag); }
> + static inline ValueImp *make(long i) { return (ValueImp *)((i <<
> shift) | tag); }
> };
> }
>
> _______________________________________________
> Khtml-devel at mail.kde.org
> http://mail.kde.org/mailman/listinfo/khtml-devel
More information about the Khtml-devel
mailing list