Ignore:
Timestamp:
Oct 5, 2005, 1:05:44 AM (20 years ago)
Author:
mjs
Message:

JavaScriptCore:

Reviewed by Eric.

  • fixed <rdar://problem/4260481> Remove Reference type from JavaScriptCore

Also fixed some bugs with for..in enumeration while I was at it. object
properties now come before prototype properties and duplicates
between object and prototype are listed only once.

  • JavaScriptCore.xcodeproj/project.pbxproj:
  • kjs/IdentifierSequencedSet.cpp: Added. (KJS::IdentifierSequencedSet::IdentifierSequencedSet): (KJS::IdentifierSequencedSet::deallocateVector): (KJS::IdentifierSequencedSet::~IdentifierSequencedSet): (KJS::IdentifierSequencedSet::insert):
  • kjs/IdentifierSequencedSet.h: Added. (KJS::IdentifierSequencedSetIterator::IdentifierSequencedSetIterator): (KJS::IdentifierSequencedSetIterator::operator*): (KJS::IdentifierSequencedSetIterator::operator->): (KJS::IdentifierSequencedSetIterator::operator++): (KJS::IdentifierSequencedSetIterator::operator==): (KJS::IdentifierSequencedSetIterator::operator!=): (KJS::IdentifierSequencedSet::begin): (KJS::IdentifierSequencedSet::end): (KJS::IdentifierSequencedSet::size):
  • kjs/array_instance.h:
  • kjs/array_object.cpp: (ArrayInstanceImp::getPropertyNames): (ArrayInstanceImp::setLength): (ArrayInstanceImp::pushUndefinedObjectsToEnd):
  • kjs/nodes.cpp: (ForInNode::execute):
  • kjs/nodes.h:
  • kjs/object.cpp: (KJS::ObjectImp::getPropertyNames):
  • kjs/object.h:
  • kjs/property_map.cpp: (KJS::PropertyMap::getEnumerablePropertyNames): (KJS::PropertyMap::getSparseArrayPropertyNames):
  • kjs/property_map.h:
  • kjs/protect.h:
  • kjs/protected_reference.h: Removed.
  • kjs/reference.cpp: Removed.
  • kjs/reference.h: Removed.
  • kjs/reference_list.cpp: Removed.
  • kjs/reference_list.h: Removed.
  • kjs/ustring.h: (KJS::UString::impl):
  • kxmlcore/HashSet.h:

LayoutTests:

Reviewed by Eric.

  • test case for some fixes I made to for..in enumeration. object properties now come before prototype properties and duplicates between object and prototype are listed only once.
  • fast/js/for-in-expected.txt: Added.
  • fast/js/for-in.html: Added.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/array_object.cpp

    r10701 r10744  
    2929#include "object.h"
    3030#include "operations.h"
    31 #include "reference_list.h"
    3231#include "types.h"
    3332#include "value.h"
     33#include "IdentifierSequencedSet.h"
    3434
    3535#include "array_object.lut.h"
     
    186186}
    187187
    188 ReferenceList ArrayInstanceImp::propList(ExecState *exec, bool recursive)
    189 {
    190   ReferenceList properties = ObjectImp::propList(exec,recursive);
    191 
     188void ArrayInstanceImp::getPropertyNames(ExecState *exec, IdentifierSequencedSet& propertyNames)
     189{
    192190  // avoid fetching this every time through the loop
    193191  ValueImp *undefined = jsUndefined();
     
    195193  for (unsigned i = 0; i < storageLength; ++i) {
    196194    ValueImp *imp = storage[i];
    197     if (imp && imp != undefined) {
    198       properties.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);
    202200}
    203201
     
    231229
    232230  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;
    240239      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);
    245243    }
    246244  }
     
    349347    }
    350348   
    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)
    356354      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);
    364361      o++;
    365362    }
Note: See TracChangeset for help on using the changeset viewer.