Changeset 10744 in webkit for trunk/JavaScriptCore/kjs
- Timestamp:
- Oct 5, 2005, 1:05:44 AM (20 years ago)
- Location:
- trunk/JavaScriptCore/kjs
- Files:
-
- 2 added
- 5 deleted
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/array_instance.h
r10084 r10744 40 40 virtual bool deleteProperty(ExecState *exec, const Identifier &propertyName); 41 41 virtual bool deleteProperty(ExecState *exec, unsigned propertyName); 42 virtual ReferenceList propList(ExecState *exec, bool recursive);42 virtual void getPropertyNames(ExecState *exec, IdentifierSequencedSet& propertyNames); 43 43 44 44 virtual void mark(); -
trunk/JavaScriptCore/kjs/array_object.cpp
r10701 r10744 29 29 #include "object.h" 30 30 #include "operations.h" 31 #include "reference_list.h"32 31 #include "types.h" 33 32 #include "value.h" 33 #include "IdentifierSequencedSet.h" 34 34 35 35 #include "array_object.lut.h" … … 186 186 } 187 187 188 ReferenceList ArrayInstanceImp::propList(ExecState *exec, bool recursive) 189 { 190 ReferenceList properties = ObjectImp::propList(exec,recursive); 191 188 void ArrayInstanceImp::getPropertyNames(ExecState *exec, IdentifierSequencedSet& propertyNames) 189 { 192 190 // avoid fetching this every time through the loop 193 191 ValueImp *undefined = jsUndefined(); … … 195 193 for (unsigned i = 0; i < storageLength; ++i) { 196 194 ValueImp *imp = storage[i]; 197 if (imp && imp != undefined) {198 propert ies.append(Reference(this,i));199 200 } 201 return properties;195 if (imp && imp != undefined) 196 propertyNames.insert(Identifier::from(i)); 197 } 198 199 ObjectImp::getPropertyNames(exec, propertyNames); 202 200 } 203 201 … … 231 229 232 230 if (newLength < length) { 233 ReferenceList sparseProperties; 234 235 _prop.addSparseArrayPropertiesToReferenceList(sparseProperties, this); 236 237 ReferenceListIterator it = sparseProperties.begin(); 238 while (it != sparseProperties.end()) { 239 Reference ref = it++; 231 IdentifierSequencedSet sparseProperties; 232 233 _prop.getSparseArrayPropertyNames(sparseProperties); 234 235 IdentifierSequencedSetIterator end = sparseProperties.end(); 236 237 for (IdentifierSequencedSetIterator it = sparseProperties.begin(); it != end; ++it) { 238 Identifier name = *it; 240 239 bool ok; 241 unsigned index = ref.getPropertyName(exec).toArrayIndex(&ok); 242 if (ok && index > newLength) { 243 ref.deleteValue(exec); 244 } 240 unsigned index = name.toArrayIndex(&ok); 241 if (ok && index > newLength) 242 deleteProperty(exec, name); 245 243 } 246 244 } … … 349 347 } 350 348 351 ReferenceList sparseProperties;352 _prop. addSparseArrayPropertiesToReferenceList(sparseProperties, this);353 unsigned newLength = o + sparseProperties. length();354 355 if (newLength > storageLength) {349 IdentifierSequencedSet sparseProperties; 350 _prop.getSparseArrayPropertyNames(sparseProperties); 351 unsigned newLength = o + sparseProperties.size(); 352 353 if (newLength > storageLength) 356 354 resizeStorage(newLength); 357 } 358 359 ReferenceListIterator it = sparseProperties.begin(); 360 while (it != sparseProperties.end()) { 361 Reference ref = it++; 362 storage[o] = ref.getValue(exec); 363 ObjectImp::deleteProperty(exec, ref.getPropertyName(exec)); 355 356 IdentifierSequencedSetIterator end = sparseProperties.end(); 357 for (IdentifierSequencedSetIterator it = sparseProperties.begin(); it != end; ++it) { 358 Identifier name = *it; 359 storage[o] = get(exec, name); 360 ObjectImp::deleteProperty(exec, name); 364 361 o++; 365 362 } -
trunk/JavaScriptCore/kjs/nodes.cpp
r10701 r10744 44 44 #include "operations.h" 45 45 #include "ustring.h" 46 #include " reference_list.h"46 #include "IdentifierSequencedSet.h" 47 47 48 48 using namespace KJS; … … 1781 1781 ObjectImp *v; 1782 1782 Completion c; 1783 ReferenceList propList;1783 IdentifierSequencedSet propertyNames; 1784 1784 1785 1785 if (varDecl) { … … 1800 1800 KJS_CHECKEXCEPTION 1801 1801 v = e->toObject(exec); 1802 propList = v->propList(exec); 1803 1804 ReferenceListIterator propIt = propList.begin(); 1805 1806 while (propIt != propList.end()) { 1807 Identifier name = propIt->getPropertyName(exec); 1808 if (!v->hasProperty(exec, name)) { 1809 propIt++; 1802 v->getPropertyNames(exec, propertyNames); 1803 1804 IdentifierSequencedSetIterator end = propertyNames.end(); 1805 for (IdentifierSequencedSetIterator it = propertyNames.begin(); it != end; ++it) { 1806 const Identifier &name = *it; 1807 if (!v->hasProperty(exec, name)) 1810 1808 continue; 1811 }1812 1809 1813 1810 ValueImp *str = jsString(name.ustring()); … … 1871 1868 } 1872 1869 } 1873 1874 propIt++;1875 1870 } 1876 1871 -
trunk/JavaScriptCore/kjs/nodes.h
r10701 r10744 35 35 class PropertyNode; 36 36 class PropertyValueNode; 37 class Reference;38 37 class RegExp; 39 38 class SourceElementsNode; -
trunk/JavaScriptCore/kjs/object.cpp
r10728 r10744 29 29 #include "interpreter.h" 30 30 #include "lookup.h" 31 #include " reference_list.h"31 #include "IdentifierSequencedSet.h" 32 32 33 33 #include <assert.h> … … 375 375 } 376 376 377 ReferenceList ObjectImp::propList(ExecState *exec, bool recursive) 378 { 379 ReferenceList list; 380 if (_proto->isObject() && recursive) 381 list = static_cast<ObjectImp*>(_proto)->propList(exec,recursive); 382 383 _prop.addEnumerablesToReferenceList(list, this); 377 void ObjectImp::getPropertyNames(ExecState *exec, IdentifierSequencedSet &propertyNames) 378 { 379 _prop.getEnumerablePropertyNames(propertyNames); 384 380 385 381 // Add properties from the static hashtable of properties … … 390 386 const HashEntry *e = info->propHashTable->entries; 391 387 for (int i = 0; i < size; ++i, ++e) { 392 if ( e->s && !(e->attr & DontEnum))393 list.append(Reference(this, e->s)); /// ######### check for duplicates with the propertymap388 if (e->s && !(e->attr & DontEnum)) 389 propertyNames.insert(e->s); 394 390 } 395 391 } … … 397 393 } 398 394 399 return list; 395 if (_proto->isObject()) 396 static_cast<ObjectImp*>(_proto)->getPropertyNames(exec, propertyNames); 400 397 } 401 398 -
trunk/JavaScriptCore/kjs/object.h
r10207 r10744 48 48 class HashEntry; 49 49 class ListImp; 50 class IdentifierSequencedSet; 50 51 51 52 // ECMA 262-3 8.6.1 … … 423 424 * 424 425 * @param exec The current execution state 425 * @param recursive Whether or not properties in the object's prototype 426 * chain should be 427 * included in the list. 428 * @return A List of References to properties of the object. 426 * @param propertyNames A list of property names to be filled in by this call 429 427 **/ 430 virtual ReferenceList propList(ExecState *exec, bool recursive = true);428 virtual void getPropertyNames(ExecState *exec, IdentifierSequencedSet& propertyNames); 431 429 432 430 /** -
trunk/JavaScriptCore/kjs/property_map.cpp
r10701 r10744 26 26 #include "object.h" 27 27 #include "protect.h" 28 #include " reference_list.h"28 #include "IdentifierSequencedSet.h" 29 29 30 30 #include <algorithm> … … 75 75 76 76 // lastIndexUsed is an ever-increasing index used to identify the order items 77 // were inserted into the property map. It's vital that addEnumerablesToReferenceList77 // were inserted into the property map. It's vital that getEnumerablePropertyNames 78 78 // return the properties in the order they were added for compatibility with other 79 79 // browsers' JavaScript implementations. … … 567 567 } 568 568 569 void PropertyMap:: addEnumerablesToReferenceList(ReferenceList &list, ObjectImp *base) const569 void PropertyMap::getEnumerablePropertyNames(IdentifierSequencedSet& propertyNames) const 570 570 { 571 571 if (!_table) { … … 573 573 UString::Rep *key = _singleEntry.key; 574 574 if (key && !(_singleEntry.attributes & DontEnum)) 575 list.append(Reference(base, Identifier(key)));575 propertyNames.insert(Identifier(key)); 576 576 #endif 577 577 return; … … 599 599 qsort(sortedEnumerables, p - sortedEnumerables, sizeof(sortedEnumerables[0]), comparePropertyMapEntryIndices); 600 600 601 // Put the keys of the sorted entries into the referencelist.601 // Put the keys of the sorted entries into the list. 602 602 Entry **q = sortedEnumerables; 603 while (q != p) 604 list.append(Reference(base, Identifier((*q++)->key))); 603 while (q != p) { 604 propertyNames.insert(Identifier(q[0]->key)); 605 ++q; 606 } 605 607 606 608 // Deallocate the buffer. … … 609 611 } 610 612 611 void PropertyMap:: addSparseArrayPropertiesToReferenceList(ReferenceList &list, ObjectImp *base) const613 void PropertyMap::getSparseArrayPropertyNames(IdentifierSequencedSet& propertyNames) const 612 614 { 613 615 if (!_table) { … … 619 621 k.toUInt32(&fitsInUInt32); 620 622 if (fitsInUInt32) 621 list.append(Reference(base, Identifier(key)));623 propertyNames.insert(Identifier(key)); 622 624 } 623 625 #endif … … 634 636 k.toUInt32(&fitsInUInt32); 635 637 if (fitsInUInt32) 636 list.append(Reference(base, Identifier(key)));638 propertyNames.insert(Identifier(key)); 637 639 } 638 640 } -
trunk/JavaScriptCore/kjs/property_map.h
r10180 r10744 28 28 namespace KJS { 29 29 30 class IdentifierSequencedSet; 30 31 class ObjectImp; 31 class ReferenceList;32 32 class ValueImp; 33 33 … … 82 82 83 83 void mark() const; 84 void addEnumerablesToReferenceList(ReferenceList &, ObjectImp *) const;85 void addSparseArrayPropertiesToReferenceList(ReferenceList &, ObjectImp *) const;84 void getEnumerablePropertyNames(IdentifierSequencedSet&) const; 85 void getSparseArrayPropertyNames(IdentifierSequencedSet&) const; 86 86 87 87 void save(SavedProperties &) const; -
trunk/JavaScriptCore/kjs/protect.h
r10563 r10744 25 25 #define _KJS_PROTECT_H_ 26 26 27 #include "reference.h"28 27 #include "value.h" 29 28 #include "protected_values.h" -
trunk/JavaScriptCore/kjs/ustring.h
r10701 r10744 241 241 242 242 public: 243 typedef Rep Impl; 244 243 245 /** 244 246 * Constructs a null string. … … 462 464 static void globalClear(); 463 465 #endif 466 467 Impl *impl() const { return rep; } 464 468 private: 465 469 UString(Rep *r) { attach(r); }
Note:
See TracChangeset
for help on using the changeset viewer.