Changeset 34355 in webkit for trunk/JavaScriptCore/kjs/object.h
- Timestamp:
- Jun 3, 2008, 5:40:47 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/object.h
r34334 r34355 103 103 104 104 private: 105 // Object operations, with the toObject operation included. 106 virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&); 107 virtual bool getOwnPropertySlot(ExecState*, unsigned index, PropertySlot&); 108 virtual void put(ExecState*, const Identifier& propertyName, JSValue*); 109 virtual void put(ExecState*, unsigned propertyName, JSValue*); 110 virtual JSObject* toThisObject(ExecState*) const; 111 105 112 JSObject *getter; 106 113 JSObject *setter; … … 526 533 inline JSValue *JSObject::get(ExecState *exec, const Identifier &propertyName) const 527 534 { 528 PropertySlot slot ;535 PropertySlot slot(const_cast<JSObject *>(this)); 529 536 530 537 if (const_cast<JSObject *>(this)->getPropertySlot(exec, propertyName, slot)) 531 return slot.getValue(exec, const_cast<JSObject *>(this),propertyName);538 return slot.getValue(exec, propertyName); 532 539 533 540 return jsUndefined(); … … 536 543 inline JSValue *JSObject::get(ExecState *exec, unsigned propertyName) const 537 544 { 538 PropertySlot slot ;545 PropertySlot slot(const_cast<JSObject *>(this)); 539 546 if (const_cast<JSObject *>(this)->getPropertySlot(exec, propertyName, slot)) 540 return slot.getValue(exec, const_cast<JSObject *>(this),propertyName);547 return slot.getValue(exec, propertyName); 541 548 542 549 return jsUndefined(); … … 588 595 fillGetterPropertySlot(slot, location); 589 596 } else 590 slot.setValueSlot( this,location);597 slot.setValueSlot(location); 591 598 return true; 592 599 } … … 594 601 // non-standard Netscape extension 595 602 if (propertyName == exec->propertyNames().underscoreProto) { 596 slot.setValueSlot( this,&_proto);603 slot.setValueSlot(&_proto); 597 604 slotIsWriteable = false; 598 605 return true; … … 611 618 fillGetterPropertySlot(slot, location); 612 619 else 613 slot.setValueSlot( this,location);620 slot.setValueSlot(location); 614 621 return true; 615 622 } … … 617 624 // non-standard Netscape extension 618 625 if (propertyName == exec->propertyNames().underscoreProto) { 619 slot.setValueSlot( this,&_proto);626 slot.setValueSlot(&_proto); 620 627 return true; 621 628 } … … 639 646 } 640 647 648 inline JSValue* JSValue::get(ExecState* exec, const Identifier& propertyName) const 649 { 650 if (UNLIKELY(JSImmediate::isImmediate(this))) { 651 JSObject* object = JSImmediate::toObject(this, exec); 652 PropertySlot slot(object); 653 if (!object->getPropertySlot(exec, propertyName, slot)) 654 return jsUndefined(); 655 return slot.getValue(exec, propertyName); 656 } 657 JSCell* cell = static_cast<JSCell*>(const_cast<JSValue*>(this)); 658 PropertySlot slot(cell); 659 while (true) { 660 if (cell->getOwnPropertySlot(exec, propertyName, slot)) 661 return slot.getValue(exec, propertyName); 662 ASSERT(cell->isObject()); 663 JSValue* proto = static_cast<JSObject*>(cell)->prototype(); 664 if (!proto->isObject()) 665 return jsUndefined(); 666 cell = static_cast<JSCell*>(proto); 667 } 668 } 669 670 inline JSValue* JSValue::get(ExecState* exec, unsigned propertyName) const 671 { 672 if (UNLIKELY(JSImmediate::isImmediate(this))) { 673 JSObject* object = JSImmediate::toObject(this, exec); 674 PropertySlot slot(object); 675 if (!object->getPropertySlot(exec, propertyName, slot)) 676 return jsUndefined(); 677 return slot.getValue(exec, propertyName); 678 } 679 JSCell* cell = const_cast<JSCell*>(asCell()); 680 PropertySlot slot(cell); 681 while (true) { 682 if (cell->getOwnPropertySlot(exec, propertyName, slot)) 683 return slot.getValue(exec, propertyName); 684 ASSERT(cell->isObject()); 685 JSValue* proto = static_cast<JSObject*>(cell)->prototype(); 686 if (!proto->isObject()) 687 return jsUndefined(); 688 cell = static_cast<JSCell*>(proto); 689 } 690 } 691 692 inline void JSValue::put(ExecState* exec, const Identifier& propertyName, JSValue* value) 693 { 694 if (UNLIKELY(JSImmediate::isImmediate(this))) { 695 JSImmediate::toObject(this, exec)->put(exec, propertyName, value); 696 return; 697 } 698 asCell()->put(exec, propertyName, value); 699 } 700 701 inline void JSValue::put(ExecState* exec, unsigned propertyName, JSValue* value) 702 { 703 if (UNLIKELY(JSImmediate::isImmediate(this))) { 704 JSImmediate::toObject(this, exec)->put(exec, propertyName, value); 705 return; 706 } 707 asCell()->put(exec, propertyName, value); 708 } 709 710 inline JSObject* PropertySlot::slotBase() const 711 { 712 ASSERT(m_slotBase); 713 // It's be nice to assert that m_slotBase is an object here, but that's a bit 714 // too slow, even for debug builds. 715 return static_cast<JSObject*>(m_slotBase); 716 } 717 641 718 } // namespace 642 719
Note:
See TracChangeset
for help on using the changeset viewer.