Changeset 36016 in webkit for trunk/JavaScriptCore/kjs/JSObject.cpp
- Timestamp:
- Sep 1, 2008, 2:22:54 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/JSObject.cpp
r35830 r36016 57 57 #endif 58 58 59 JSValue* prototype = m_prototype; 60 if (!prototype->marked()) 61 prototype->mark(); 62 59 m_structureID->mark(); 63 60 m_propertyMap.mark(); 64 61 … … 87 84 88 85 // ECMA 8.6.2.2 89 void JSObject::put(ExecState* exec, const Identifier& propertyName, JSValue* value )86 void JSObject::put(ExecState* exec, const Identifier& propertyName, JSValue* value, PutPropertySlot& slot) 90 87 { 91 88 ASSERT(value); … … 114 111 JSValue* prototype; 115 112 for (JSObject* obj = this; !obj->m_propertyMap.hasGetterSetterProperties(); obj = static_cast<JSObject*>(prototype)) { 116 prototype = obj-> m_prototype;113 prototype = obj->prototype(); 117 114 if (prototype == jsNull()) { 118 m_propertyMap.put(propertyName, value, 0, true);115 putDirect(propertyName, value, 0, true, slot); 119 116 return; 120 117 } … … 126 123 127 124 for (JSObject* obj = this; ; obj = static_cast<JSObject*>(prototype)) { 128 if (JSValue* gs = obj->m_propertyMap.get(propertyName , attributes)) {129 if ( attributes & IsGetterSetter) {125 if (JSValue* gs = obj->m_propertyMap.get(propertyName)) { 126 if (gs->isGetterSetter()) { 130 127 JSObject* setterFunc = static_cast<GetterSetter*>(gs)->setter(); 131 128 if (!setterFunc) { … … 147 144 } 148 145 149 prototype = obj-> m_prototype;146 prototype = obj->prototype(); 150 147 if (prototype == jsNull()) 151 148 break; 152 149 } 153 154 m_propertyMap.put(propertyName, value, 0, true); 150 151 putDirect(propertyName, value, 0, true, slot); 152 return; 155 153 } 156 154 157 155 void JSObject::put(ExecState* exec, unsigned propertyName, JSValue* value) 158 156 { 159 put(exec, Identifier::from(exec, propertyName), value); 157 PutPropertySlot slot; 158 put(exec, Identifier::from(exec, propertyName), value, slot); 160 159 } 161 160 … … 190 189 if ((attributes & DontDelete)) 191 190 return false; 192 m_propertyMap.remove(propertyName); 193 if (attributes & IsGetterSetter) 194 m_propertyMap.setHasGetterSetterProperties(m_propertyMap.containsGettersOrSetters()); 191 removeDirect(propertyName); 195 192 return true; 196 193 } 197 194 198 195 // Look in the static hashtable of properties 199 196 const HashEntry* entry = findPropertyHashEntry(exec, propertyName); … … 249 246 { 250 247 // Must call toString first for Date objects. 251 if ((hint == PreferString) || (hint != PreferNumber && m_prototype== exec->lexicalGlobalObject()->datePrototype())) {248 if ((hint == PreferString) || (hint != PreferNumber && prototype() == exec->lexicalGlobalObject()->datePrototype())) { 252 249 if (JSValue* value = callDefaultValueFunction(exec, this, exec->propertyNames().toString)) 253 250 return value; … … 279 276 void JSObject::defineGetter(ExecState* exec, const Identifier& propertyName, JSObject* getterFunction) 280 277 { 278 GetterSetter* getterSetter; 279 PutPropertySlot slot; 280 281 281 JSValue* object = getDirect(propertyName); 282 GetterSetter* getterSetter;283 282 if (object && object->isGetterSetter()) 284 283 getterSetter = static_cast<GetterSetter*>(object); 285 284 else { 286 285 getterSetter = new (exec) GetterSetter; 287 putDirect(propertyName, getterSetter, IsGetterSetter); 286 putDirect(propertyName, getterSetter, None, true, slot); 287 } 288 289 // putDirect will change our StructureID if we add a new property. For 290 // getters and setters, though, we also need to change our StructureID 291 // if we override an existing non-getter or non-setter. 292 if (slot.type() != PutPropertySlot::NewProperty) { 293 if (!m_structureID->isDictionary()) { 294 RefPtr<StructureID> structureID = StructureID::getterSetterTransition(m_structureID); 295 setStructureID(structureID.release()); 296 } 288 297 } 289 298 … … 294 303 void JSObject::defineSetter(ExecState* exec, const Identifier& propertyName, JSObject* setterFunction) 295 304 { 305 GetterSetter* getterSetter; 306 PutPropertySlot slot; 307 296 308 JSValue* object = getDirect(propertyName); 297 GetterSetter* getterSetter;298 309 if (object && object->isGetterSetter()) 299 310 getterSetter = static_cast<GetterSetter*>(object); 300 311 else { 301 312 getterSetter = new (exec) GetterSetter; 302 putDirect(propertyName, getterSetter, IsGetterSetter); 303 } 304 313 putDirect(propertyName, getterSetter, None, true, slot); 314 } 315 316 // putDirect will change our StructureID if we add a new property. For 317 // getters and setters, though, we also need to change our StructureID 318 // if we override an existing non-getter or non-setter. 319 if (slot.type() != PutPropertySlot::NewProperty) { 320 if (!m_structureID->isDictionary()) { 321 RefPtr<StructureID> structureID = StructureID::getterSetterTransition(m_structureID); 322 setStructureID(structureID.release()); 323 } 324 } 325 305 326 m_propertyMap.setHasGetterSetterProperties(true); 306 327 getterSetter->setSetter(setterFunction); … … 413 434 } 414 435 415 if ( m_prototype->isObject())416 static_cast<JSObject*>( m_prototype)->getPropertyNames(exec, propertyNames);436 if (prototype()->isObject()) 437 static_cast<JSObject*>(prototype())->getPropertyNames(exec, propertyNames); 417 438 } 418 439 … … 456 477 { 457 478 m_propertyMap.remove(propertyName); 479 if (!m_structureID->isDictionary()) { 480 RefPtr<StructureID> structureID = StructureID::dictionaryTransition(m_structureID); 481 setStructureID(structureID.release()); 482 } 458 483 } 459 484 … … 471 496 } 472 497 498 PassRefPtr<StructureID> JSObject::createInheritorID() 499 { 500 m_inheritorID = StructureID::create(this); 501 return m_inheritorID; 502 } 503 473 504 bool JSObject::isObject() const 474 505 {
Note:
See TracChangeset
for help on using the changeset viewer.