Changeset 2766 in webkit for trunk/JavaScriptCore/kjs


Ignore:
Timestamp:
Nov 19, 2002, 3:45:44 PM (23 years ago)
Author:
darin
Message:

JavaScriptCore:

  • next step towards atomic identifiers; Identifier is no longer derived from UString
  • kjs/identifier.h: Remove base class and add _ustring member.
  • kjs/identifier.cpp: Add null and an == that works with const char *.
  • kjs/property_map.cpp: Get rep through _ustring.
  • kjs/function.cpp: (FunctionImp::parameterString): Call ustring().
  • kjs/function_object.cpp: (FunctionProtoFuncImp::call): Ditto.
  • kjs/nodes.cpp: (PropertyNode::evaluate): Ditto. (VarDeclNode::evaluate): Ditto. (ForInNode::execute): Ditto.
  • kjs/nodes2string.cpp: (SourceStream::operator<<): Add overload for Identifier.
  • kjs/reference.cpp: (Reference::getValue): Call ustring().
  • kjs/regexp_object.cpp: (RegExpObjectImp::get): Call ustring().

WebCore:

  • next step towards atomic identifiers; Identifier is no longer derived from UString
  • khtml/ecma/kjs_binding.cpp: (Identifier::string): Added. (Identifier::qstring): Added.
  • khtml/ecma/kjs_binding.h:
  • khtml/ecma/kjs_css.cpp: (jsNameToProp): (DOMCSSStyleDeclaration::tryPut): (DOMStyleSheet::tryPut): (DOMStyleSheetList::tryGet): (DOMMediaList::tryGet): (DOMCSSRuleList::tryGet): (DOMCSSValueList::tryGet):
  • khtml/ecma/kjs_dom.cpp: (DOMNodeList::hasProperty): (DOMNodeList::tryGet): (DOMNodeListFunc::DOMNodeListFunc): (DOMElement::tryGet): (DOMNamedNodeMap::hasProperty): (DOMNamedNodeMap::tryGet): (DOMNamedNodesCollection::tryGet):
  • khtml/ecma/kjs_html.cpp: (KJS::HTMLDocument::tryGet): (HTMLElementFunction::HTMLElementFunction): (KJS::HTMLElement::putValue): (KJS::HTMLCollection::hasProperty): (KJS::HTMLCollection::tryGet): (KJS::HTMLSelectCollection::tryPut): (OptionConstructorImp::OptionConstructorImp):
  • khtml/ecma/kjs_navigator.cpp: (Plugins::get): (MimeTypes::get): (Plugin::get):
  • khtml/ecma/kjs_window.cpp: (WindowFunc::tryCall): (FrameArray::get): Use lengthPropertyName instead of "length" for better speed.
Location:
trunk/JavaScriptCore/kjs
Files:
9 edited

Legend:

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

    r2760 r2766  
    174174    if (!s.isEmpty())
    175175        s += ", ";
    176     s += (*p)->name;
     176    s += (*p)->name.ustring();
    177177    p = &(*p)->next;
    178178  }
  • trunk/JavaScriptCore/kjs/function_object.cpp

    r2760 r2766  
    9595       DeclaredFunctionImp *fi = static_cast<DeclaredFunctionImp*>
    9696                                 (thisObj.imp());
    97        return String("function " + fi->name() + "(" +
     97       return String("function " + fi->name().ustring() + "(" +
    9898         fi->parameterString() + ") " + fi->body->toString());
    9999    } else if (thisObj.inherits(&FunctionImp::info) &&
    100100        !static_cast<FunctionImp*>(thisObj.imp())->name().isNull()) {
    101       result = String("function " + static_cast<FunctionImp*>(thisObj.imp())->name() + "()");
     101      result = String("function " + static_cast<FunctionImp*>(thisObj.imp())->name().ustring() + "()");
    102102    }
    103103    else {
  • trunk/JavaScriptCore/kjs/identifier.cpp

    r2760 r2766  
    2222#include "identifier.h"
    2323
     24namespace KJS {
     25
     26Identifier Identifier::null;
     27
     28bool operator==(const Identifier &a, const char *b)
     29{
     30    return a._ustring == b;
     31}
     32
     33} // namespace KJS
  • trunk/JavaScriptCore/kjs/identifier.h

    r2760 r2766  
    2727namespace KJS {
    2828
    29   class Identifier : public UString {
    30   public:
    31     Identifier() { }
    32     Identifier(const char *s) : UString(s) { }
    33     Identifier(const UString &s) : UString(s) { }
    34   };
     29    class Identifier {
     30        friend class PropertyMap;
     31    public:
     32        Identifier() { }
     33        Identifier(const char *s) : _ustring(s) { }
     34        Identifier(const UString &s) : _ustring(s) { }
     35       
     36        const UString &ustring() const { return _ustring; }
     37        DOM::DOMString string() const;
     38        QString qstring() const;
     39       
     40        const UChar *data() const { return _ustring.data(); }
     41        int size() const { return _ustring.size(); }
     42       
     43        const char *ascii() const { return _ustring.ascii(); }
     44       
     45        static Identifier from(unsigned y) { return UString::from(y); }
     46       
     47        bool isNull() const { return _ustring.isNull(); }
     48        bool isEmpty() const { return _ustring.isEmpty(); }
     49       
     50        unsigned long toULong(bool *ok) const { return _ustring.toULong(ok); }
     51        double toDouble() const { return _ustring.toDouble(); }
     52       
     53        static Identifier null;
     54       
     55        friend bool operator==(const Identifier &, const Identifier &);
     56        friend bool operator!=(const Identifier &, const Identifier &);
     57
     58        friend bool operator==(const Identifier &, const char *);
     59   
     60    private:
     61        UString _ustring;
     62    };
     63   
     64    inline bool operator==(const Identifier &a, const Identifier &b)
     65    {
     66        return a._ustring == b._ustring;
     67    }
     68
     69    inline bool operator!=(const Identifier &a, const Identifier &b)
     70    {
     71        return a._ustring != b._ustring;
     72    }
    3573
    3674}
  • trunk/JavaScriptCore/kjs/nodes.cpp

    r2760 r2766  
    461461  if (str.isNull()) {
    462462    s = String(UString::from(numeric));
    463   } else
    464     s = String(str);
     463  } else {
     464    s = String(str.ustring());
     465  }
    465466
    466467  return s;
     
    16371638  variable.put(exec, ident, val, DontDelete | Internal);
    16381639
    1639   return String(ident);
     1640  return String(ident.ustring());
    16401641}
    16411642
     
    20992100    Reference ref = lexpr->evaluateReference(exec);
    21002101    KJS_CHECKEXCEPTION
    2101     ref.putValue(exec,String(name));
     2102    ref.putValue(exec, String(name.ustring()));
    21022103
    21032104    c = statement->execute(exec);
  • trunk/JavaScriptCore/kjs/nodes2string.cpp

    r1799 r2766  
    3434
    3535    UString toString() const { return str; }
    36     SourceStream& operator<<(const KJS::UString &);
     36    SourceStream& operator<<(const Identifier &);
     37    SourceStream& operator<<(const UString &);
     38    SourceStream& operator<<(const char *);
    3739    SourceStream& operator<<(char);
    3840    SourceStream& operator<<(Format f);
     
    5254}
    5355
    54 SourceStream& SourceStream::operator<<(const KJS::UString &s)
     56SourceStream& SourceStream::operator<<(const char *s)
     57{
     58  str += UString(s);
     59  return *this;
     60}
     61
     62SourceStream& SourceStream::operator<<(const UString &s)
    5563{
    5664  str += s;
     65  return *this;
     66}
     67
     68SourceStream& SourceStream::operator<<(const Identifier &s)
     69{
     70  str += s.ustring();
    5771  return *this;
    5872}
  • trunk/JavaScriptCore/kjs/property_map.cpp

    r2760 r2766  
    9898    if (!_table) {
    9999        UString::Rep *key = _singleEntry.key;
    100         if (key && keysMatch(name.rep, key)) {
     100        if (key && keysMatch(name._ustring.rep, key)) {
    101101            attributes = _singleEntry.attributes;
    102102            return _singleEntry.value;
     
    105105    }
    106106   
    107     int i = hash(name.rep);
     107    int i = hash(name._ustring.rep);
    108108    while (UString::Rep *key = _table[i].key) {
    109         if (keysMatch(name.rep, key)) {
     109        if (keysMatch(name._ustring.rep, key)) {
    110110            attributes = _table[i].attributes;
    111111            return _table[i].value;
     
    120120    if (!_table) {
    121121        UString::Rep *key = _singleEntry.key;
    122         if (key && keysMatch(name.rep, key))
     122        if (key && keysMatch(name._ustring.rep, key))
    123123            return _singleEntry.value;
    124124        return 0;
    125125    }
    126126   
    127     int i = hash(name.rep);
     127    int i = hash(name._ustring.rep);
    128128    while (UString::Rep *key = _table[i].key) {
    129         if (keysMatch(name.rep, key))
     129        if (keysMatch(name._ustring.rep, key))
    130130            return _table[i].value;
    131131        i = (i + 1) & _tableSizeHashMask;
     
    139139        UString::Rep *key = _singleEntry.key;
    140140        if (key) {
    141             if (keysMatch(name.rep, key)) {
     141            if (keysMatch(name._ustring.rep, key)) {
    142142                _singleEntry.value = value;
    143143                return;
    144144            }
    145145        } else {
    146             name.rep->ref();
    147             _singleEntry.key = name.rep;
     146            name._ustring.rep->ref();
     147            _singleEntry.key = name._ustring.rep;
    148148            _singleEntry.value = value;
    149149            _singleEntry.attributes = attributes;
     
    156156        expand();
    157157   
    158     int i = hash(name.rep);
     158    int i = hash(name._ustring.rep);
    159159    while (UString::Rep *key = _table[i].key) {
    160         if (keysMatch(name.rep, key)) {
     160        if (keysMatch(name._ustring.rep, key)) {
    161161            // Put a new value in an existing hash table entry.
    162162            _table[i].value = value;
     
    168168   
    169169    // Create a new hash table entry.
    170     name.rep->ref();
    171     _table[i].key = name.rep;
     170    name._ustring.rep->ref();
     171    _table[i].key = name._ustring.rep;
    172172    _table[i].value = value;
    173173    _table[i].attributes = attributes;
     
    216216    if (!_table) {
    217217        key = _singleEntry.key;
    218         if (key && keysMatch(name.rep, key)) {
     218        if (key && keysMatch(name._ustring.rep, key)) {
    219219            key->deref();
    220220            _singleEntry.key = 0;
     
    225225
    226226    // Find the thing to remove.
    227     int i = hash(name.rep);
     227    int i = hash(name._ustring.rep);
    228228    while ((key = _table[i].key)) {
    229         if (keysMatch(name.rep, key))
     229        if (keysMatch(name._ustring.rep, key))
    230230            break;
    231231        i = (i + 1) & _tableSizeHashMask;
  • trunk/JavaScriptCore/kjs/reference.cpp

    r2760 r2766  
    106106
    107107  if (o.isNull() || o.type() == NullType) {
    108     UString m = I18N_NOOP("Can't find variable: ") + getPropertyName(exec);
     108    UString m = I18N_NOOP("Can't find variable: ") + getPropertyName(exec).ustring();
    109109    Object err = Error::create(exec, ReferenceError, m.ascii());
    110110    exec->setException(err);
  • trunk/JavaScriptCore/kjs/regexp_object.cpp

    r2760 r2766  
    196196Value RegExpObjectImp::get(ExecState *exec, const Identifier &p) const
    197197{
    198   if (p[0] == '$' && lastOvector)
     198  UString s = p.ustring();
     199  if (s[0] == '$' && lastOvector)
    199200  {
    200201    bool ok;
    201     unsigned long i = p.substr(1).toULong(&ok);
     202    unsigned long i = s.substr(1).toULong(&ok);
    202203    if (ok)
    203204    {
Note: See TracChangeset for help on using the changeset viewer.