Changeset 36483 in webkit for trunk/JavaScriptCore/kjs/operations.cpp
- Timestamp:
- Sep 15, 2008, 11:08:51 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/operations.cpp
r36263 r36483 102 102 bool strictEqual(JSValue* v1, JSValue* v2) 103 103 { 104 if (JSImmediate::areBothImmediate(v1, v2)) 105 return v1 == v2; 106 107 if (JSImmediate::isEitherImmediate(v1, v2) & v1 != JSImmediate::from(0) & v2 != JSImmediate::from(0)) 108 return false; 109 110 return strictEqualSlowCase(v1, v2); 111 } 112 113 bool strictEqualSlowCase(JSValue* v1, JSValue* v2) 114 { 115 ASSERT(!JSImmediate::areBothImmediate(v1, v2)); 116 104 117 if (JSImmediate::isEitherImmediate(v1, v2)) { 105 if (v1 == v2) 106 return true; 118 // pointers can't be equal since one is immediate and one isn't 119 ASSERT(v1 != v2); 120 ASSERT(v1 == JSImmediate::zeroImmediate() || v2 == JSImmediate::zeroImmediate()); 107 121 108 122 // The reason we can't just return false here is that 0 === -0, 109 123 // and while the former is an immediate number, the latter is not. 110 if (v1 == JSImmediate::from(0)) 111 return !JSImmediate::isImmediate(v2) 112 && static_cast<JSCell*>(v2)->isNumber() 113 && static_cast<JSNumberCell*>(v2)->value() == 0; 114 return v2 == JSImmediate::from(0) 115 && !JSImmediate::isImmediate(v1) 116 && static_cast<JSCell*>(v1)->isNumber() 117 && static_cast<JSNumberCell*>(v1)->value() == 0; 124 if (v1 == JSImmediate::zeroImmediate()) 125 return static_cast<JSCell*>(v2)->isNumber() && static_cast<JSNumberCell*>(v2)->value() == 0; 126 return static_cast<JSCell*>(v1)->isNumber() && static_cast<JSNumberCell*>(v1)->value() == 0; 118 127 } 119 128 120 if (static_cast<JSCell*>(v1)->isNumber()) 129 if (static_cast<JSCell*>(v1)->isNumber()) { 121 130 return static_cast<JSCell*>(v2)->isNumber() 122 131 && static_cast<JSNumberCell*>(v1)->value() == static_cast<JSNumberCell*>(v2)->value(); 132 } 123 133 124 if (static_cast<JSCell*>(v1)->isString()) 134 if (static_cast<JSCell*>(v1)->isString()) { 125 135 return static_cast<JSCell*>(v2)->isString() 126 136 && static_cast<JSString*>(v1)->value() == static_cast<JSString*>(v2)->value(); 137 } 127 138 128 139 return v1 == v2;
Note:
See TracChangeset
for help on using the changeset viewer.