Ignore:
Timestamp:
Aug 8, 2003, 8:21:12 AM (22 years ago)
Author:
darin
Message:

Reviewed by John Sullivan.

  • fixed 3365527 -- subscripting JavaScript strings does not work (leads to hang at www.newmagna.com.au)

The JavaScript specification says nothing about this, but other browsers seem to give
read-only access to the characters in a string as if the string was an array of characters.

  • kjs/array_object.cpp: (ArrayInstanceImp::get): Update to use a public toArrayIndex function instead of our own getArrayIndex function, so we can share with string. (ArrayInstanceImp::put): Ditto. (ArrayInstanceImp::hasProperty): Ditto. (ArrayInstanceImp::setLength): Ditto.
  • kjs/ustring.h: Add toArrayIndex.
  • kjs/ustring.cpp: (UString::toArrayIndex): Added. Implements the rule from array.
  • kjs/identifier.h: Add a forwarding function so we can use toArrayIndex.
  • kjs/string_object.cpp: (StringInstanceImp::get): Return a single character string if the property name is an array index. (StringInstanceImp::hasProperty): Return true for property names that are suitable array indices.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/identifier.h

    r4631 r4792  
    5454        uint32_t toUInt32(bool *ok) const { return _ustring.toUInt32(ok); }
    5555        uint32_t toStrictUInt32(bool *ok) const { return _ustring.toStrictUInt32(ok); }
     56        unsigned toArrayIndex(bool *ok) const { return _ustring.toArrayIndex(ok); }
    5657        double toDouble() const { return _ustring.toDouble(); }
    5758       
Note: See TracChangeset for help on using the changeset viewer.