Changeset 10857 in webkit for trunk/JavaScriptCore/kjs
- Timestamp:
- Oct 15, 2005, 5:46:25 PM (20 years ago)
- Location:
- trunk/JavaScriptCore/kjs
- Files:
-
- 5 added
- 2 deleted
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/array_instance.h
r10744 r10857 40 40 virtual bool deleteProperty(ExecState *exec, const Identifier &propertyName); 41 41 virtual bool deleteProperty(ExecState *exec, unsigned propertyName); 42 virtual void getPropertyNames(ExecState *exec, IdentifierSequencedSet& propertyNames);42 virtual ReferenceList propList(ExecState *exec, bool recursive); 43 43 44 44 virtual void mark(); -
trunk/JavaScriptCore/kjs/array_object.cpp
r10744 r10857 29 29 #include "object.h" 30 30 #include "operations.h" 31 #include "reference_list.h" 31 32 #include "types.h" 32 33 #include "value.h" 33 #include "IdentifierSequencedSet.h"34 34 35 35 #include "array_object.lut.h" … … 186 186 } 187 187 188 void ArrayInstanceImp::getPropertyNames(ExecState *exec, IdentifierSequencedSet& propertyNames) 189 { 188 ReferenceList ArrayInstanceImp::propList(ExecState *exec, bool recursive) 189 { 190 ReferenceList properties = ObjectImp::propList(exec,recursive); 191 190 192 // avoid fetching this every time through the loop 191 193 ValueImp *undefined = jsUndefined(); … … 193 195 for (unsigned i = 0; i < storageLength; ++i) { 194 196 ValueImp *imp = storage[i]; 195 if (imp && imp != undefined) 196 propert yNames.insert(Identifier::from(i));197 }198 199 ObjectImp::getPropertyNames(exec, propertyNames);197 if (imp && imp != undefined) { 198 properties.append(Reference(this, i)); 199 } 200 } 201 return properties; 200 202 } 201 203 … … 229 231 230 232 if (newLength < length) { 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; 233 ReferenceList sparseProperties; 234 235 _prop.addSparseArrayPropertiesToReferenceList(sparseProperties, this); 236 237 ReferenceListIterator it = sparseProperties.begin(); 238 while (it != sparseProperties.end()) { 239 Reference ref = it++; 239 240 bool ok; 240 unsigned index = name.toArrayIndex(&ok); 241 if (ok && index > newLength) 242 deleteProperty(exec, name); 241 unsigned index = ref.getPropertyName(exec).toArrayIndex(&ok); 242 if (ok && index > newLength) { 243 ref.deleteValue(exec); 244 } 243 245 } 244 246 } … … 347 349 } 348 350 349 IdentifierSequencedSet sparseProperties;350 _prop. getSparseArrayPropertyNames(sparseProperties);351 unsigned newLength = o + sparseProperties. size();352 353 if (newLength > storageLength) 351 ReferenceList sparseProperties; 352 _prop.addSparseArrayPropertiesToReferenceList(sparseProperties, this); 353 unsigned newLength = o + sparseProperties.length(); 354 355 if (newLength > storageLength) { 354 356 resizeStorage(newLength); 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); 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)); 361 364 o++; 362 365 } -
trunk/JavaScriptCore/kjs/nodes.cpp
r10757 r10857 44 44 #include "operations.h" 45 45 #include "ustring.h" 46 #include " IdentifierSequencedSet.h"46 #include "reference_list.h" 47 47 48 48 using namespace KJS; … … 1770 1770 ObjectImp *v; 1771 1771 Completion c; 1772 IdentifierSequencedSet propertyNames;1772 ReferenceList propList; 1773 1773 1774 1774 if (varDecl) { … … 1789 1789 KJS_CHECKEXCEPTION 1790 1790 v = e->toObject(exec); 1791 v->getPropertyNames(exec, propertyNames); 1792 1793 IdentifierSequencedSetIterator end = propertyNames.end(); 1794 for (IdentifierSequencedSetIterator it = propertyNames.begin(); it != end; ++it) { 1795 const Identifier &name = *it; 1796 if (!v->hasProperty(exec, name)) 1791 propList = v->propList(exec); 1792 1793 ReferenceListIterator propIt = propList.begin(); 1794 1795 while (propIt != propList.end()) { 1796 Identifier name = propIt->getPropertyName(exec); 1797 if (!v->hasProperty(exec, name)) { 1798 propIt++; 1797 1799 continue; 1800 } 1798 1801 1799 1802 ValueImp *str = jsString(name.ustring()); … … 1857 1860 } 1858 1861 } 1862 1863 propIt++; 1859 1864 } 1860 1865 -
trunk/JavaScriptCore/kjs/nodes.h
r10744 r10857 35 35 class PropertyNode; 36 36 class PropertyValueNode; 37 class Reference; 37 38 class RegExp; 38 39 class SourceElementsNode; -
trunk/JavaScriptCore/kjs/object.cpp
r10744 r10857 29 29 #include "interpreter.h" 30 30 #include "lookup.h" 31 #include " IdentifierSequencedSet.h"31 #include "reference_list.h" 32 32 33 33 #include <assert.h> … … 375 375 } 376 376 377 void ObjectImp::getPropertyNames(ExecState *exec, IdentifierSequencedSet &propertyNames) 378 { 379 _prop.getEnumerablePropertyNames(propertyNames); 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); 380 384 381 385 // Add properties from the static hashtable of properties … … 386 390 const HashEntry *e = info->propHashTable->entries; 387 391 for (int i = 0; i < size; ++i, ++e) { 388 if ( e->s && !(e->attr & DontEnum))389 propertyNames.insert(e->s);392 if ( e->s && !(e->attr & DontEnum) ) 393 list.append(Reference(this, e->s)); /// ######### check for duplicates with the propertymap 390 394 } 391 395 } … … 393 397 } 394 398 395 if (_proto->isObject()) 396 static_cast<ObjectImp*>(_proto)->getPropertyNames(exec, propertyNames); 399 return list; 397 400 } 398 401 -
trunk/JavaScriptCore/kjs/object.h
r10744 r10857 48 48 class HashEntry; 49 49 class ListImp; 50 class IdentifierSequencedSet;51 50 52 51 // ECMA 262-3 8.6.1 … … 424 423 * 425 424 * @param exec The current execution state 426 * @param propertyNames A list of property names to be filled in by this call 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. 427 429 **/ 428 virtual void getPropertyNames(ExecState *exec, IdentifierSequencedSet& propertyNames);430 virtual ReferenceList propList(ExecState *exec, bool recursive = true); 429 431 430 432 /** -
trunk/JavaScriptCore/kjs/property_map.cpp
r10744 r10857 26 26 #include "object.h" 27 27 #include "protect.h" 28 #include " IdentifierSequencedSet.h"28 #include "reference_list.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 getEnumerablePropertyNames77 // were inserted into the property map. It's vital that addEnumerablesToReferenceList 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:: getEnumerablePropertyNames(IdentifierSequencedSet& propertyNames) const569 void PropertyMap::addEnumerablesToReferenceList(ReferenceList &list, ObjectImp *base) const 570 570 { 571 571 if (!_table) { … … 573 573 UString::Rep *key = _singleEntry.key; 574 574 if (key && !(_singleEntry.attributes & DontEnum)) 575 propertyNames.insert(Identifier(key));575 list.append(Reference(base, 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 list.601 // Put the keys of the sorted entries into the reference list. 602 602 Entry **q = sortedEnumerables; 603 while (q != p) { 604 propertyNames.insert(Identifier(q[0]->key)); 605 ++q; 606 } 603 while (q != p) 604 list.append(Reference(base, Identifier((*q++)->key))); 607 605 608 606 // Deallocate the buffer. … … 611 609 } 612 610 613 void PropertyMap:: getSparseArrayPropertyNames(IdentifierSequencedSet& propertyNames) const611 void PropertyMap::addSparseArrayPropertiesToReferenceList(ReferenceList &list, ObjectImp *base) const 614 612 { 615 613 if (!_table) { … … 621 619 k.toUInt32(&fitsInUInt32); 622 620 if (fitsInUInt32) 623 propertyNames.insert(Identifier(key));621 list.append(Reference(base, Identifier(key))); 624 622 } 625 623 #endif … … 636 634 k.toUInt32(&fitsInUInt32); 637 635 if (fitsInUInt32) 638 propertyNames.insert(Identifier(key));636 list.append(Reference(base, Identifier(key))); 639 637 } 640 638 } -
trunk/JavaScriptCore/kjs/property_map.h
r10744 r10857 28 28 namespace KJS { 29 29 30 class IdentifierSequencedSet;31 30 class ObjectImp; 31 class ReferenceList; 32 32 class ValueImp; 33 33 … … 82 82 83 83 void mark() const; 84 void getEnumerablePropertyNames(IdentifierSequencedSet&) const;85 void getSparseArrayPropertyNames(IdentifierSequencedSet&) const;84 void addEnumerablesToReferenceList(ReferenceList &, ObjectImp *) const; 85 void addSparseArrayPropertiesToReferenceList(ReferenceList &, ObjectImp *) const; 86 86 87 87 void save(SavedProperties &) const; -
trunk/JavaScriptCore/kjs/protect.h
r10744 r10857 25 25 #define _KJS_PROTECT_H_ 26 26 27 #include "reference.h" 27 28 #include "value.h" 28 29 #include "protected_values.h" -
trunk/JavaScriptCore/kjs/ustring.h
r10744 r10857 241 241 242 242 public: 243 typedef Rep Impl;244 245 243 /** 246 244 * Constructs a null string. … … 464 462 static void globalClear(); 465 463 #endif 466 467 Impl *impl() const { return rep; }468 464 private: 469 465 UString(Rep *r) { attach(r); }
Note:
See TracChangeset
for help on using the changeset viewer.