Changeset 5239 in webkit for trunk/JavaScriptCore/kjs
- Timestamp:
- Oct 22, 2003, 2:31:46 PM (22 years ago)
- Location:
- trunk/JavaScriptCore/kjs
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/internal.cpp
r4909 r5239 283 283 return (double)uint32 == val; 284 284 } 285 286 double SimpleNumber::negZero = -0.0; 285 287 286 288 // ------------------------------ LabelStack ----------------------------------- -
trunk/JavaScriptCore/kjs/simple_number.h
r3373 r5239 26 26 #include <limits.h> 27 27 #include <math.h> 28 #include <string.h> 29 30 #define IS_NEGATIVE_ZERO(num) (num == 0.0 && !memcmp(&num,&SimpleNumber::negZero,sizeof(double))) 28 31 29 32 namespace KJS { … … 32 35 class SimpleNumber { 33 36 public: 34 enum { tag = 1, shift = 2, mask = (1 << shift) - 1, sign = 1 << 31, max = (1 << (31 - shift)) - 1, min = -max - 1 };37 enum { tag = 1, shift = 2, mask = (1 << shift) - 1, sign = 1L << (sizeof(long) * 8 - 1 ), max = (1L << ((sizeof(long) * 8 - 1) - shift)) - 1, min = -max - 1, imax = (1L << ((sizeof(int) * 8 - 1) - shift)) - 1, imin = -imax - 1 }; 35 38 36 static inline bool is(const ValueImp *imp) { return (( int)imp & mask) == tag; }37 static inline int value(const ValueImp *imp) { return ((int)imp >> shift) | (((int)imp & sign) ? ~max : 0); }39 static inline bool is(const ValueImp *imp) { return ((long)imp & mask) == tag; } 40 static inline long value(const ValueImp *imp) { return ((long)imp >> shift) | (((long)imp & sign) ? ~max : 0); } 38 41 39 static inline bool fits(int i) { return i <= max && i >=min; }42 static inline bool fits(int i) { return i <= imax && i >= imin; } 40 43 static inline bool fits(unsigned i) { return i <= (unsigned)max; } 41 44 static inline bool fits(long i) { return i <= max && i >= min; } 42 45 static inline bool fits(unsigned long i) { return i <= (unsigned)max; } 43 static inline bool fits(double d) { return d <= max && d >= min && d == (double)(int)d; } 44 static inline ValueImp *make(int i) { return (ValueImp *)((i << shift) | tag); } 46 static inline bool fits(double d) { return d <= max && d >= min && d == (double)(long)d && 47 !IS_NEGATIVE_ZERO(d); } 48 static inline ValueImp *make(long i) { return (ValueImp *)((i << shift) | tag); } 45 49 }; 46 50 }
Note:
See TracChangeset
for help on using the changeset viewer.