Changeset 43121 in webkit for trunk/JavaScriptCore/runtime
- Timestamp:
- May 1, 2009, 2:20:11 PM (16 years ago)
- Location:
- trunk/JavaScriptCore/runtime
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp
r42989 r43121 307 307 if (isnan(d) || isinf(d)) 308 308 return jsNaN(&exec->globalData()); 309 return js 0();309 return jsNumber(exec, 0); 310 310 } 311 311 -
trunk/JavaScriptCore/runtime/JSImmediate.h
r40046 r43121 43 43 class UString; 44 44 45 JSValuePtr js0();46 JSValuePtr jsNull();47 JSValuePtr jsBoolean(bool b);48 JSValuePtr jsUndefined();49 JSValuePtr jsImpossibleValue();50 45 JSValuePtr jsNumber(ExecState* exec, double d); 51 46 JSValuePtr jsNumber(ExecState*, char i); … … 161 156 friend class JSValuePtr; 162 157 friend class JSFastMath; 163 friend JSValuePtr js0();164 friend JSValuePtr jsNull();165 friend JSValuePtr jsBoolean(bool b);166 friend JSValuePtr jsUndefined();167 friend JSValuePtr jsImpossibleValue();168 158 friend JSValuePtr jsNumber(ExecState* exec, double d); 169 159 friend JSValuePtr jsNumber(ExecState*, char i); … … 578 568 } 579 569 580 inline JSValuePtr js0()581 {582 return JSImmediate::zeroImmediate();583 }584 585 inline JSValuePtr jsNull()586 {587 return JSImmediate::nullImmediate();588 }589 590 inline JSValuePtr jsBoolean(bool b)591 {592 return b ? JSImmediate::trueImmediate() : JSImmediate::falseImmediate();593 }594 595 inline JSValuePtr jsUndefined()596 {597 return JSImmediate::undefinedImmediate();598 }599 600 inline JSValuePtr jsImpossibleValue()601 {602 return JSImmediate::impossibleValue();603 }604 605 570 // These are identical logic to the JSValue functions above, and faster than jsNumber(number).toInt32(). 606 571 int32_t toInt32(double); … … 609 574 uint32_t toUInt32SlowCase(double, bool& ok); 610 575 611 inline bool JSValuePtr::isUndefined() const 612 { 613 return asValue() == jsUndefined(); 614 } 615 616 inline bool JSValuePtr::isNull() const 617 { 618 return asValue() == jsNull(); 576 inline JSValuePtr::JSValuePtr(ImpossibleValueTag) 577 { 578 *this = JSImmediate::impossibleValue(); 579 } 580 581 inline JSValuePtr::JSValuePtr(JSNullTag) 582 { 583 *this = JSImmediate::nullImmediate(); 584 } 585 586 inline JSValuePtr::JSValuePtr(JSUndefinedTag) 587 { 588 *this = JSImmediate::undefinedImmediate(); 589 } 590 591 inline JSValuePtr::JSValuePtr(JSTrueTag) 592 { 593 *this = JSImmediate::trueImmediate(); 594 } 595 596 inline JSValuePtr::JSValuePtr(JSFalseTag) 597 { 598 *this = JSImmediate::falseImmediate(); 619 599 } 620 600 -
trunk/JavaScriptCore/runtime/JSValue.h
r43103 r43121 62 62 63 63 public: 64 JSValuePtr() 65 : m_ptr(0) 66 { 67 } 68 69 JSValuePtr(JSCell* ptr) 70 : m_ptr(ptr) 71 { 72 } 73 74 JSValuePtr(const JSCell* ptr) 75 : m_ptr(const_cast<JSCell*>(ptr)) 76 { 77 } 78 79 operator bool() const 80 { 81 return m_ptr; 82 } 83 84 bool operator==(const JSValuePtr other) const 85 { 86 return m_ptr == other.m_ptr; 87 } 88 89 bool operator!=(const JSValuePtr other) const 90 { 91 return m_ptr != other.m_ptr; 92 } 93 94 static EncodedJSValuePtr encode(JSValuePtr value) 95 { 96 return reinterpret_cast<EncodedJSValuePtr>(value.m_ptr); 97 } 98 99 static JSValuePtr decode(EncodedJSValuePtr ptr) 100 { 101 return JSValuePtr(reinterpret_cast<JSCell*>(ptr)); 102 } 64 enum ImpossibleValueTag { ImpossibleValue }; 65 enum JSNullTag { JSNull }; 66 enum JSUndefinedTag { JSUndefined }; 67 enum JSTrueTag { JSTrue }; 68 enum JSFalseTag { JSFalse }; 69 70 static EncodedJSValuePtr encode(JSValuePtr value); 71 static JSValuePtr decode(EncodedJSValuePtr ptr); 72 73 JSValuePtr(); 74 JSValuePtr(ImpossibleValueTag); 75 JSValuePtr(JSNullTag); 76 JSValuePtr(JSUndefinedTag); 77 JSValuePtr(JSTrueTag); 78 JSValuePtr(JSFalseTag); 79 JSValuePtr(JSCell* ptr); 80 JSValuePtr(const JSCell* ptr); 81 82 operator bool() const; 83 bool operator==(const JSValuePtr other) const; 84 bool operator!=(const JSValuePtr other) const; 103 85 104 86 // Querying the type. … … 207 189 }; 208 190 191 // Stand-alone helper functions. 209 192 inline JSValuePtr noValue() 210 193 { 211 194 return JSValuePtr(); 195 } 196 197 inline JSValuePtr jsImpossibleValue() 198 { 199 return JSValuePtr(JSValuePtr::ImpossibleValue); 200 } 201 202 inline JSValuePtr jsNull() 203 { 204 return JSValuePtr(JSValuePtr::JSNull); 205 } 206 207 inline JSValuePtr jsUndefined() 208 { 209 return JSValuePtr(JSValuePtr::JSUndefined); 210 } 211 212 inline JSValuePtr jsBoolean(bool b) 213 { 214 return b ? JSValuePtr(JSValuePtr::JSTrue) : JSValuePtr(JSValuePtr::JSFalse); 212 215 } 213 216 … … 218 221 inline bool operator!=(const JSCell* a, const JSValuePtr b) { return JSValuePtr(a) != b; } 219 222 223 // JSValuePtr member functions. 224 inline EncodedJSValuePtr JSValuePtr::encode(JSValuePtr value) 225 { 226 return reinterpret_cast<EncodedJSValuePtr>(value.m_ptr); 227 } 228 229 inline JSValuePtr JSValuePtr::decode(EncodedJSValuePtr ptr) 230 { 231 return JSValuePtr(reinterpret_cast<JSCell*>(ptr)); 232 } 233 234 inline JSValuePtr::JSValuePtr() 235 : m_ptr(0) 236 { 237 } 238 239 inline JSValuePtr::JSValuePtr(JSCell* ptr) 240 : m_ptr(ptr) 241 { 242 } 243 244 inline JSValuePtr::JSValuePtr(const JSCell* ptr) 245 : m_ptr(const_cast<JSCell*>(ptr)) 246 { 247 } 248 249 inline JSValuePtr::operator bool() const 250 { 251 return m_ptr; 252 } 253 254 inline bool JSValuePtr::operator==(const JSValuePtr other) const 255 { 256 return m_ptr == other.m_ptr; 257 } 258 259 inline bool JSValuePtr::operator!=(const JSValuePtr other) const 260 { 261 return m_ptr != other.m_ptr; 262 } 263 264 inline bool JSValuePtr::isUndefined() const 265 { 266 return asValue() == jsUndefined(); 267 } 268 269 inline bool JSValuePtr::isNull() const 270 { 271 return asValue() == jsNull(); 272 } 273 220 274 } // namespace JSC 221 275
Note:
See TracChangeset
for help on using the changeset viewer.