Changeset 33979 in webkit for trunk/JavaScriptCore/kjs/object.h
- Timestamp:
- May 21, 2008, 6:20:45 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/object.h
r33038 r33979 235 235 * @return The specified property, or Undefined 236 236 */ 237 JSValue *get(ExecState *exec, const Identifier &propertyName) const;238 JSValue *get(ExecState *exec, unsigned propertyName) const;239 240 bool getPropertySlot(ExecState 241 bool getPropertySlot(ExecState 242 243 virtual bool getOwnPropertySlot(ExecState 244 virtual bool getOwnPropertySlot(ExecState 237 JSValue* get(ExecState* exec, const Identifier& propertyName) const; 238 JSValue* get(ExecState* exec, unsigned propertyName) const; 239 240 bool getPropertySlot(ExecState*, const Identifier&, PropertySlot&); 241 bool getPropertySlot(ExecState*, unsigned, PropertySlot&); 242 243 virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&); 244 virtual bool getOwnPropertySlot(ExecState*, unsigned index, PropertySlot&); 245 245 246 246 /** … … 315 315 */ 316 316 virtual JSValue *defaultValue(ExecState *exec, JSType hint) const; 317 318 /**319 * Whether or not the object implements the construct() method. If this320 * returns false you should not call the construct() method on this321 * object (typically, an assertion will fail to indicate this).322 *323 * @return true if this object implements the construct() method, otherwise324 * false325 */326 virtual bool implementsConstruct() const;327 317 328 318 /** … … 343 333 * Under some circumstances, the exception object may also be returned. 344 334 * 345 * Note: This function should not be called if implementsConstruct() returns346 * false, in which case it will result in an assertion failure.335 * Note: This function should not be called if getConstructData() returns 336 * ConstructTypeNone, in which case it will result in an assertion failure. 347 337 * 348 338 * @param exec The current execution state … … 356 346 virtual JSObject* construct(ExecState* exec, const List& args); 357 347 virtual JSObject* construct(ExecState* exec, const List& args, const Identifier& functionName, const UString& sourceURL, int lineNumber); 358 359 /**360 * Whether or not the object implements the call() method. If this returns361 * false you should not call the call() method on this object (typically,362 * an assertion will fail to indicate this).363 *364 * @return true if this object implements the call() method, otherwise365 * false366 */367 virtual bool implementsCall() const;368 348 369 349 /** … … 384 364 * @return The return value from the function 385 365 */ 366 bool implementsCall(); 386 367 JSValue *call(ExecState *exec, JSObject *thisObj, const List &args); 368 387 369 virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args); 388 370 … … 432 414 JSValue **getDirectLocation(const Identifier& propertyName) 433 415 { return _prop.getLocation(propertyName); } 416 JSValue **getDirectLocation(const Identifier& propertyName, bool& isWriteable) 417 { return _prop.getLocation(propertyName, isWriteable); } 434 418 void putDirect(const Identifier &propertyName, JSValue *value, int attr = 0); 435 419 void putDirect(const Identifier &propertyName, int value, int attr = 0); … … 452 436 protected: 453 437 PropertyMap _prop; 438 bool getOwnPropertySlotForWrite(ExecState*, const Identifier&, PropertySlot&, bool& slotIsWriteable); 454 439 455 440 private: … … 541 526 } 542 527 528 inline JSValue *JSObject::get(ExecState *exec, const Identifier &propertyName) const 529 { 530 PropertySlot slot; 531 532 if (const_cast<JSObject *>(this)->getPropertySlot(exec, propertyName, slot)) 533 return slot.getValue(exec, const_cast<JSObject *>(this), propertyName); 534 535 return jsUndefined(); 536 } 537 538 inline JSValue *JSObject::get(ExecState *exec, unsigned propertyName) const 539 { 540 PropertySlot slot; 541 if (const_cast<JSObject *>(this)->getPropertySlot(exec, propertyName, slot)) 542 return slot.getValue(exec, const_cast<JSObject *>(this), propertyName); 543 544 return jsUndefined(); 545 } 546 543 547 // It may seem crazy to inline a function this large but it makes a big difference 544 548 // since this is function very hot in variable lookup … … 556 560 object = static_cast<JSObject *>(proto); 557 561 } 562 } 563 564 inline bool JSObject::getPropertySlot(ExecState *exec, unsigned propertyName, PropertySlot& slot) 565 { 566 JSObject *imp = this; 567 568 while (true) { 569 if (imp->getOwnPropertySlot(exec, propertyName, slot)) 570 return true; 571 572 JSValue *proto = imp->_proto; 573 if (!proto->isObject()) 574 break; 575 576 imp = static_cast<JSObject *>(proto); 577 } 578 579 return false; 580 } 581 582 // It may seem crazy to inline a function this large, especially a virtual function, 583 // but it makes a big difference to property lookup that derived classes can inline their 584 // base class call to this. 585 ALWAYS_INLINE bool JSObject::getOwnPropertySlotForWrite(ExecState* exec, const Identifier& propertyName, PropertySlot& slot, bool& slotIsWriteable) 586 { 587 if (JSValue **location = getDirectLocation(propertyName, slotIsWriteable)) { 588 if (_prop.hasGetterSetterProperties() && location[0]->type() == GetterSetterType) { 589 slotIsWriteable = false; 590 fillGetterPropertySlot(slot, location); 591 } else 592 slot.setValueSlot(this, location); 593 return true; 594 } 595 596 // non-standard Netscape extension 597 if (propertyName == exec->propertyNames().underscoreProto) { 598 slot.setValueSlot(this, &_proto); 599 slotIsWriteable = true; 600 return true; 601 } 602 603 return false; 558 604 } 559 605 … … 580 626 } 581 627 582 inline void ScopeChain::release() 583 { 584 // This function is only called by deref(), 585 // Deref ensures these conditions are true. 586 ASSERT(_node && _node->refCount == 0); 587 ScopeChainNode *n = _node; 588 do { 589 ScopeChainNode *next = n->next; 590 delete n; 591 n = next; 592 } while (n && --n->refCount == 0); 628 inline void JSObject::putDirect(const Identifier &propertyName, JSValue *value, int attr) 629 { 630 _prop.put(propertyName, value, attr); 631 } 632 633 inline void JSObject::putDirect(const Identifier &propertyName, int value, int attr) 634 { 635 _prop.put(propertyName, jsNumber(value), attr); 593 636 } 594 637
Note:
See TracChangeset
for help on using the changeset viewer.