Changeset 75884 in webkit for trunk/Source/JavaScriptCore/runtime/JSObject.cpp
- Timestamp:
- Jan 15, 2011, 3:39:36 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/runtime/JSObject.cpp
r69516 r75884 589 589 } 590 590 591 static bool putDescriptor(ExecState* exec, JSObject* target, const Identifier& propertyName, PropertyDescriptor& descriptor, unsigned attributes, JSValue oldValue)591 static bool putDescriptor(ExecState* exec, JSObject* target, const Identifier& propertyName, PropertyDescriptor& descriptor, unsigned attributes, const PropertyDescriptor& oldDescriptor) 592 592 { 593 593 if (descriptor.isGenericDescriptor() || descriptor.isDataDescriptor()) { 594 target->putWithAttributes(exec, propertyName, descriptor.value() ? descriptor.value() : oldValue, attributes & ~(Getter | Setter)); 594 if (descriptor.isGenericDescriptor() && oldDescriptor.isAccessorDescriptor()) { 595 GetterSetter* accessor = new (exec) GetterSetter(exec); 596 if (oldDescriptor.getter()) { 597 attributes |= Getter; 598 accessor->setGetter(asObject(oldDescriptor.getter())); 599 } 600 if (oldDescriptor.setter()) { 601 attributes |= Setter; 602 accessor->setSetter(asObject(oldDescriptor.setter())); 603 } 604 target->putWithAttributes(exec, propertyName, accessor, attributes); 605 return true; 606 } 607 JSValue newValue = jsUndefined(); 608 if (descriptor.value()) 609 newValue = descriptor.value(); 610 else if (oldDescriptor.value()) 611 newValue = oldDescriptor.value(); 612 target->putWithAttributes(exec, propertyName, newValue, attributes & ~(Getter | Setter)); 595 613 return true; 596 614 } … … 609 627 // If we have a new property we can just put it on normally 610 628 PropertyDescriptor current; 611 if (!getOwnPropertyDescriptor(exec, propertyName, current)) 612 return putDescriptor(exec, this, propertyName, descriptor, descriptor.attributes(), jsUndefined()); 629 if (!getOwnPropertyDescriptor(exec, propertyName, current)) { 630 PropertyDescriptor oldDescriptor; 631 oldDescriptor.setValue(jsUndefined()); 632 return putDescriptor(exec, this, propertyName, descriptor, descriptor.attributes(), oldDescriptor); 633 } 613 634 614 635 if (descriptor.isEmpty()) … … 636 657 if (!current.attributesEqual(descriptor)) { 637 658 deleteProperty(exec, propertyName); 638 putDescriptor(exec, this, propertyName, descriptor, current.attributesWithOverride(descriptor), current .value());659 putDescriptor(exec, this, propertyName, descriptor, current.attributesWithOverride(descriptor), current); 639 660 } 640 661 return true; … … 649 670 } 650 671 deleteProperty(exec, propertyName); 651 return putDescriptor(exec, this, propertyName, descriptor, current.attributesWithOverride(descriptor), current .value() ? current.value() : jsUndefined());672 return putDescriptor(exec, this, propertyName, descriptor, current.attributesWithOverride(descriptor), current); 652 673 } 653 674 … … 677 698 } 678 699 deleteProperty(exec, propertyName); 679 return putDescriptor(exec, this, propertyName, descriptor, current.attributesWithOverride(descriptor), current .value());700 return putDescriptor(exec, this, propertyName, descriptor, current.attributesWithOverride(descriptor), current); 680 701 } 681 702
Note:
See TracChangeset
for help on using the changeset viewer.