Changeset 6025 in webkit for trunk/JavaScriptCore/kjs/value.cpp
- Timestamp:
- Feb 2, 2004, 1:23:17 PM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/value.cpp
r3373 r6025 94 94 95 95 // ECMA 9.4 96 intValueImp::toInteger(ExecState *exec) const97 { 98 u nsignedi;96 double ValueImp::toInteger(ExecState *exec) const 97 { 98 uint32_t i; 99 99 if (dispatchToUInt32(i)) 100 return (int)i;101 return int(roundValue(exec, Value(const_cast<ValueImp*>(this))));102 } 103 104 int ValueImp::toInt32(ExecState *exec) const105 { 106 u nsignedi;100 return i; 101 return roundValue(exec, Value(const_cast<ValueImp*>(this))); 102 } 103 104 int32_t ValueImp::toInt32(ExecState *exec) const 105 { 106 uint32_t i; 107 107 if (dispatchToUInt32(i)) 108 return (int)i;108 return i; 109 109 110 110 double d = roundValue(exec, Value(const_cast<ValueImp*>(this))); 111 if (isNaN(d) || isInf(d)) 112 return 0; 111 113 double d32 = fmod(d, D32); 112 114 113 115 if (d32 >= D32 / 2.0) 114 116 d32 -= D32; 115 116 return static_cast<int>(d32); 117 } 118 119 unsigned int ValueImp::toUInt32(ExecState *exec) const 120 { 121 unsigned i; 117 else if (d32 < -D32 / 2.0) 118 d32 += D32; 119 120 return static_cast<int32_t>(d32); 121 } 122 123 uint32_t ValueImp::toUInt32(ExecState *exec) const 124 { 125 uint32_t i; 122 126 if (dispatchToUInt32(i)) 123 127 return i; 124 128 125 129 double d = roundValue(exec, Value(const_cast<ValueImp*>(this))); 130 if (isNaN(d) || isInf(d)) 131 return 0; 126 132 double d32 = fmod(d, D32); 127 133 128 return static_cast<unsigned int>(d32); 129 } 130 131 unsigned short ValueImp::toUInt16(ExecState *exec) const 132 { 133 unsigned i; 134 if (d32 < 0) 135 d32 += D32; 136 137 return static_cast<uint32_t>(d32); 138 } 139 140 uint16_t ValueImp::toUInt16(ExecState *exec) const 141 { 142 uint32_t i; 134 143 if (dispatchToUInt32(i)) 135 return (unsigned short)i;144 return i; 136 145 137 146 double d = roundValue(exec, Value(const_cast<ValueImp*>(this))); 147 if (isNaN(d) || isInf(d)) 148 return 0; 138 149 double d16 = fmod(d, D16); 139 150 140 return static_cast<unsigned short>(d16); 151 if (d16 < 0) 152 d16 += D16; 153 154 return static_cast<uint16_t>(d16); 141 155 } 142 156 … … 186 200 } 187 201 188 bool ValueImp::dispatchToUInt32(u nsigned& result) const202 bool ValueImp::dispatchToUInt32(uint32_t& result) const 189 203 { 190 204 if (SimpleNumber::is(this)) { … … 192 206 if (i < 0) 193 207 return false; 194 result = (unsigned)i;208 result = i; 195 209 return true; 196 210 }
Note:
See TracChangeset
for help on using the changeset viewer.