Changeset 1799 in webkit for trunk/JavaScriptCore/kjs


Ignore:
Timestamp:
Aug 12, 2002, 1:14:02 PM (23 years ago)
Author:
darin
Message:

top level:

  • Tests/WebFoundation-Misc/ifnsurlextensions-test.m: (TestURLCommon): Add tests for the new WebNSURLExtras methods.
  • Tests/libiftest/IFCheckLeaks.c: (IFCheckLeaksAtExit): Remove workaround for CFPreferences race condition; it's now in WebFoundation.

JavaScriptCore:

Speed improvements. 19% faster on cvs-js-performance, 1% on cvs-static-urls.

Use global string objects for length and other common property names rather
than constantly making and destroying them. Use integer versions of get() and
other related calls rather than always making a string.

Also get rid of many unneeded constructors, destructors, copy constructors, and
assignment operators. And make some functions non-virtual.

  • kjs/internal.h:
  • kjs/internal.cpp: (NumberImp::toUInt32): Implement. (ReferenceImp::ReferenceImp): Special case for numeric property names. (ReferenceImp::getPropertyName): Moved guts here from ValueImp. Handle numeric case. (ReferenceImp::getValue): Moved guts here from ValueImp. Handle numeric case. (ReferenceImp::putValue): Moved guts here from ValueImp. Handle numeric case. (ReferenceImp::deleteValue): Added. Handle numeric case.
  • kjs/array_object.h:
  • kjs/array_object.cpp: All-new array implementation that stores the elements in a C++ array rather than in a property map. (ArrayInstanceImp::ArrayInstanceImp): Allocate the C++ array. (ArrayInstanceImp::~ArrayInstanceImp): Delete the C++ array. (ArrayInstanceImp::get): Implement both the old version and the new overload that takes an unsigned index for speed. (ArrayInstanceImp::put): Implement both the old version and the new overload that takes an unsigned index for speed. (ArrayInstanceImp::hasProperty): Implement both the old version and the new overload that takes an unsigned index for speed. (ArrayInstanceImp::deleteProperty): Implement both the old version and the new overload that takes an unsigned index for speed. (ArrayInstanceImp::setLength): Added. Used by the above to resize the array. (ArrayInstanceImp::mark): Mark the elements of the array too. (ArrayPrototypeImp::ArrayPrototypeImp): Pass the length to the array instance constructor.
  • kjs/bool_object.cpp:
  • kjs/date_object.cpp:
  • kjs/error_object.cpp:
  • kjs/function.cpp:
  • kjs/function_object.cpp:
  • kjs/math_object.cpp:
  • kjs/nodes.cpp:
  • kjs/nodes.h:
  • kjs/number_object.cpp:
  • kjs/object_object.cpp:
  • kjs/regexp_object.cpp:
  • kjs/string_object.cpp:
  • kjs/nodes2string.cpp: (SourceStream::operator<<): Add a special case for char now that you can't create a UString from a char implicitly.
  • kjs/object.h:
  • kjs/object.cpp: (ObjectImp::get): Call through to the string version if the numeric version is not implemented. (ObjectImp::put): Call through to the string version if the numeric version is not implemented. (ObjectImp::hasProperty): Call through to the string version if the numeric version is not implemented. (ObjectImp::deleteProperty): Call through to the string version if the numeric version is not implemented.
  • kjs/types.h:
  • kjs/types.cpp: (Reference::Reference): Added constructors for the numeric property name case.
  • kjs/ustring.h: Made the constructor that turns a character into a string be explicit so we don't get numbers that turn themselves into strings.
  • kjs/ustring.cpp: (UString::UString): Detect the empty string case, and use a shared empty string. (UString::find): Add an overload for single character finds. (UString::rfind): Add an overload for single character finds. (KJS::operator==): Fix bug where it would call strlen(0) if the first string was not null. Also handle non-ASCII characters consistently with the rest of the code by casting to unsigned char just in case.
  • kjs/value.h: Make ValueImp and all subclasses non-copyable and non-assignable.
  • kjs/value.cpp: (ValueImp::toUInt32): New interface, mainly useful so we can detect array indices and not turn them into strings and back. (ValueImp::toInteger): Use the new toUInt32. Probably can use more improvement. (ValueImp::toInt32): Use the new toUInt32. Probably can use more improvement. (ValueImp::toUInt16): Use the new toUInt32. Probably can use more improvement. (ValueImp::getBase): Remove handling of the Reference case. That's in ReferenceImp now. (ValueImp::getPropertyName): Remove handling of the Reference case. That's in ReferenceImp now. (ValueImp::getValue): Remove handling of the Reference case. That's in ReferenceImp now. (ValueImp::putValue): Remove handling of the Reference case. That's in ReferenceImp now. (ValueImp::deleteValue): Added. Used so we can do delete the same way we do put.

WebFoundation:

  • CacheLoader.subproj/WebHTTPResourceLoader.m: (-[WebHTTPProtocolHandler createWFLoadRequest]): Fix handling of paths with queries and some other subtle path and port number handling issues by using _web_hostWithPort and _web_pathWithQuery.
  • Misc.subproj/WebNSURLExtras.h:
  • Misc.subproj/WebNSURLExtras.m: (-[NSURL _web_hostWithPort]): Added. (-[NSURL _web_pathWithQuery]): Added.
  • CacheLoader.subproj/WebResourceLoad.m: (initLoader): Get some random preference before creating threads. This makes it impossible to run into the CFPreferences race condition.

WebCore:

  • force-clean-timestamp: Need a full build because of KJS changes.
  • khtml/ecma/kjs_window.h: Need to store an Object, not an ObjectImp, because there's no way to copy an ObjectImp. KJS changes caught this mistake.
Location:
trunk/JavaScriptCore/kjs
Files:
25 edited

Legend:

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

    r1623 r1799  
    4040const ClassInfo ArrayInstanceImp::info = {"Array", 0, 0, 0};
    4141
    42 ArrayInstanceImp::ArrayInstanceImp(const Object &proto)
     42ArrayInstanceImp::ArrayInstanceImp(const Object &proto, unsigned initialLength)
    4343  : ObjectImp(proto)
    44 {
     44  , length(initialLength)
     45  , capacity(length)
     46  , storage(length ? new Undefined[length] : 0)
     47{
     48}
     49
     50ArrayInstanceImp::ArrayInstanceImp(const Object &proto, const List &list)
     51  : ObjectImp(proto)
     52  , length(list.size())
     53  , capacity(length)
     54  , storage(length ? new Undefined[length] : 0)
     55{
     56  ListIterator it = list.begin();
     57  const unsigned l = length;
     58  for (unsigned i = 0; i < l; ++i) {
     59    storage[i] = it++;
     60  }
     61}
     62
     63ArrayInstanceImp::~ArrayInstanceImp()
     64{
     65  delete [] storage;
     66}
     67
     68Value ArrayInstanceImp::get(ExecState *exec, const UString &propertyName) const
     69{
     70  if (propertyName == lengthPropertyName)
     71    return Number(length);
     72
     73  bool ok;
     74  unsigned index = propertyName.toULong(&ok);
     75  if (ok) {
     76    if (index >= length)
     77      return Undefined();
     78    return storage[index];
     79  }
     80
     81  return ObjectImp::get(exec, propertyName);
     82}
     83
     84Value ArrayInstanceImp::get(ExecState *exec, unsigned index) const
     85{
     86  if (index >= length)
     87    return Undefined();
     88  return storage[index];
    4589}
    4690
     
    4892void ArrayInstanceImp::put(ExecState *exec, const UString &propertyName, const Value &value, int attr)
    4993{
    50   if ((attr == None || attr == DontDelete) && !canPut(exec,propertyName))
     94  if (propertyName == lengthPropertyName) {
     95    setLength(value.toUInt32(exec));
    5196    return;
    52 
    53   if (hasProperty(exec,propertyName)) {
    54     if (propertyName == "length") {
    55       Value len = get(exec,"length");
    56       unsigned int oldLen = len.toUInt32(exec);
    57       unsigned int newLen = value.toUInt32(exec);
    58       // shrink array
    59       for (unsigned int u = newLen; u < oldLen; u++) {
    60         UString p = UString::from(u);
    61         if (hasOwnProperty(exec, p))
    62           deleteProperty(exec, p);
    63       }
    64       ObjectImp::put(exec, "length", Number(newLen), DontEnum | DontDelete);
    65       return;
    66     }
    67     //    put(p, v);
    68   } //  } else
    69     ObjectImp::put(exec, propertyName, value, attr);
    70 
    71   // array index ?
    72   unsigned int idx;
    73   if (!sscanf(propertyName.cstring().c_str(), "%u", &idx)) /* TODO */
     97  }
     98 
     99  bool ok;
     100  unsigned index = propertyName.toULong(&ok);
     101  if (ok) {
     102    setLength(index + 1);
     103    storage[index] = value;
    74104    return;
    75 
    76   // do we need to update/create the length property ?
    77   if (hasOwnProperty(exec, "length")) {
    78     Value len = get(exec, "length");
    79     if (idx < len.toUInt32(exec))
    80       return;
    81   }
    82 
    83   ObjectImp::put(exec, "length", Number(idx+1), DontDelete | DontEnum);
    84 }
    85 
    86 void ArrayInstanceImp::putDirect(ExecState *exec, const UString &propertyName, const Value &value, int attr)
    87 {
    88   ObjectImp::put(exec,propertyName,value,attr);
    89 }
    90 
    91 bool ArrayInstanceImp::hasOwnProperty(ExecState *exec,
    92                                       const UString &propertyName)
    93 {
    94   // disable this object's prototype temporarily for the hasProperty() call
    95   Value protoBackup = prototype();
    96   setPrototype(Undefined());
    97   bool b = hasProperty(exec, propertyName);
    98   setPrototype(protoBackup);
    99   return b;
     105  }
     106 
     107  ObjectImp::put(exec, propertyName, value, attr);
     108}
     109
     110void ArrayInstanceImp::put(ExecState *exec, unsigned index, const Value &value, int attr)
     111{
     112  setLength(index + 1);
     113  storage[index] = value;
     114}
     115
     116bool ArrayInstanceImp::hasProperty(ExecState *exec, const UString &propertyName) const
     117{
     118  if (propertyName == lengthPropertyName)
     119    return true;
     120 
     121  bool ok;
     122  unsigned index = propertyName.toULong(&ok);
     123  if (ok) {
     124    if (index >= length)
     125      return false;
     126    return !storage[index].isA(UndefinedType);
     127  }
     128 
     129  return ObjectImp::hasProperty(exec, propertyName);
     130}
     131
     132bool ArrayInstanceImp::hasProperty(ExecState *exec, unsigned index) const
     133{
     134  if (index >= length)
     135    return false;
     136  return !storage[index].isA(UndefinedType);
     137}
     138
     139bool ArrayInstanceImp::deleteProperty(ExecState *exec, const UString &propertyName)
     140{
     141  if (propertyName == lengthPropertyName)
     142    return false;
     143 
     144  bool ok;
     145  unsigned index = propertyName.toULong(&ok);
     146  if (ok) {
     147    if (index >= length)
     148      return true;
     149    storage[index] = Undefined();
     150    return true;
     151  }
     152 
     153  return ObjectImp::deleteProperty(exec, propertyName);
     154}
     155
     156bool ArrayInstanceImp::deleteProperty(ExecState *exec, unsigned index)
     157{
     158  if (index >= length)
     159    return true;
     160  storage[index] = Undefined();
     161  return true;
     162}
     163
     164void ArrayInstanceImp::setLength(unsigned newLength)
     165{
     166  if (newLength < length) {
     167    const unsigned l = length;
     168    for (unsigned i = newLength; i < l; ++i)
     169      storage[i] = Undefined();
     170  }
     171  if (newLength > capacity) {
     172    unsigned newCapacity = (newLength * 3 + 1) / 2;
     173    Value *newStorage = new Undefined [newCapacity];
     174    const unsigned l = length;
     175    for (unsigned i = 0; i < l; ++i)
     176      newStorage[i] = storage[i];
     177    delete [] storage;
     178    storage = newStorage;
     179    capacity = newCapacity;
     180  }
     181  length = newLength;
     182}
     183
     184void ArrayInstanceImp::mark()
     185{
     186  ObjectImp::mark();
     187  const unsigned l = length;
     188  for (unsigned i = 0; i < l; ++i) {
     189    ValueImp *imp = storage[i].imp();
     190    if (!imp->marked())
     191      imp->mark();
     192  }
    100193}
    101194
     
    124217ArrayPrototypeImp::ArrayPrototypeImp(ExecState *exec,
    125218                                     ObjectPrototypeImp *objProto)
    126   : ArrayInstanceImp(Object(objProto))
     219  : ArrayInstanceImp(Object(objProto), 0)
    127220{
    128221  Value protect(this);
    129222  setInternalValue(Null());
    130 
    131   // The constructor will be added later, by InterpreterImp, once ArrayObjectImp has been constructed.
    132   put(exec,"length", Number(0), DontEnum | DontDelete);
    133223}
    134224
     
    147237{
    148238  Value protect(this);
    149   put(exec,"length",Number(len),DontDelete|ReadOnly|DontEnum);
     239  put(exec,lengthPropertyName,Number(len),DontDelete|ReadOnly|DontEnum);
    150240}
    151241
     
    158248Value ArrayProtoFuncImp::call(ExecState *exec, Object &thisObj, const List &args)
    159249{
    160   unsigned int length = thisObj.get(exec,"length").toUInt32(exec);
     250  unsigned int length = thisObj.get(exec,lengthPropertyName).toUInt32(exec);
    161251
    162252  Value result;
     
    184274      if (k >= 1)
    185275        str += separator;
    186       Value element = thisObj.get(exec,UString::from(k));
     276      Value element = thisObj.get(exec,k);
    187277      if (element.type() != UndefinedType && element.type() != NullType)
    188278        str += element.toString(exec);
     
    202292        unsigned int k = 0;
    203293        if (n > 0)
    204           length = curObj.get(exec,"length").toUInt32(exec);
     294          length = curObj.get(exec,lengthPropertyName).toUInt32(exec);
    205295        while (k < length) {
    206           UString p = UString::from(k);
    207           if (curObj.hasProperty(exec,p))
    208             arr.put(exec,UString::from(n), curObj.get(exec,p));
     296          if (curObj.hasProperty(exec,k))
     297            arr.put(exec, n, curObj.get(exec, k));
    209298          n++;
    210299          k++;
    211300        }
    212301      } else {
    213         arr.put(exec,UString::from(n), curArg);
     302        arr.put(exec, n, curArg);
    214303        n++;
    215304      }
     
    219308      curObj = Object::dynamicCast(it++); // may be 0
    220309    }
    221     arr.put(exec,"length", Number(n), DontEnum | DontDelete);
     310    arr.put(exec,lengthPropertyName, Number(n), DontEnum | DontDelete);
    222311
    223312    result = arr;
     
    225314  }
    226315  case Pop:{
    227 
    228316    if (length == 0) {
    229       thisObj.put(exec, "length", Number(length), DontEnum | DontDelete);
     317      thisObj.put(exec, lengthPropertyName, Number(length), DontEnum | DontDelete);
    230318      result = Undefined();
    231319    } else {
    232       UString str = UString::from(length - 1);
    233       result = thisObj.get(exec,str);
    234       thisObj.deleteProperty(exec, str);
    235       thisObj.put(exec, "length", Number(length - 1), DontEnum | DontDelete);
     320      result = thisObj.get(exec, length - 1);
     321      thisObj.put(exec, lengthPropertyName, Number(length - 1), DontEnum | DontDelete);
    236322    }
    237323    break;
     
    239325  case Push: {
    240326    for (int n = 0; n < args.size(); n++)
    241       thisObj.put(exec,UString::from(length + n), args[n]);
     327      thisObj.put(exec, length + n, args[n]);
    242328    length += args.size();
    243     thisObj.put(exec,"length", Number(length), DontEnum | DontDelete);
     329    thisObj.put(exec,lengthPropertyName, Number(length), DontEnum | DontDelete);
    244330    result = Number(length);
    245331    break;
     
    250336
    251337    for (unsigned int k = 0; k < middle; k++) {
    252       UString str = UString::from(k);
    253       UString str2 = UString::from(length - k - 1);
    254       Value obj = thisObj.get(exec,str);
    255       Value obj2 = thisObj.get(exec,str2);
    256       if (thisObj.hasProperty(exec,str2)) {
    257         if (thisObj.hasProperty(exec,str)) {
    258           thisObj.put(exec, str, obj2);
    259           thisObj.put(exec, str2, obj);
     338      unsigned lk1 = length - k - 1;
     339      Value obj = thisObj.get(exec,k);
     340      Value obj2 = thisObj.get(exec,lk1);
     341      if (thisObj.hasProperty(exec,lk1)) {
     342        if (thisObj.hasProperty(exec,k)) {
     343          thisObj.put(exec, k, obj2);
     344          thisObj.put(exec, lk1, obj);
    260345        } else {
    261           thisObj.put(exec, str, obj2);
    262           thisObj.deleteProperty(exec, str2);
     346          thisObj.put(exec, k, obj2);
     347          thisObj.deleteProperty(exec, lk1);
    263348        }
    264349      } else {
    265         if (thisObj.hasProperty(exec, str)) {
    266           thisObj.deleteProperty(exec, str);
    267           thisObj.put(exec, str2, obj);
     350        if (thisObj.hasProperty(exec, k)) {
     351          thisObj.deleteProperty(exec, k);
     352          thisObj.put(exec, lk1, obj);
    268353        } else {
    269354          // why delete something that's not there ? Strange.
    270           thisObj.deleteProperty(exec, str);
    271           thisObj.deleteProperty(exec, str2);
     355          thisObj.deleteProperty(exec, k);
     356          thisObj.deleteProperty(exec, lk1);
    272357        }
    273358      }
     
    278363  case Shift: {
    279364    if (length == 0) {
    280       thisObj.put(exec, "length", Number(length), DontEnum | DontDelete);
     365      thisObj.put(exec, lengthPropertyName, Number(length), DontEnum | DontDelete);
    281366      result = Undefined();
    282367    } else {
    283       result = thisObj.get(exec, "0");
     368      result = thisObj.get(exec, 0);
    284369      for(unsigned int k = 1; k < length; k++) {
    285         UString str = UString::from(k);
    286         UString str2 = UString::from(k-1);
    287         if (thisObj.hasProperty(exec, str)) {
    288           Value obj = thisObj.get(exec, str);
    289           thisObj.put(exec, str2, obj);
     370        if (thisObj.hasProperty(exec, k)) {
     371          Value obj = thisObj.get(exec, k);
     372          thisObj.put(exec, k-1, obj);
    290373        } else
    291           thisObj.deleteProperty(exec, str2);
    292       }
    293       thisObj.deleteProperty(exec, UString::from(length - 1));
    294       thisObj.put(exec, "length", Number(length - 1), DontEnum | DontDelete);
     374          thisObj.deleteProperty(exec, k-1);
     375      }
     376      thisObj.deleteProperty(exec, length - 1);
     377      thisObj.put(exec, lengthPropertyName, Number(length - 1), DontEnum | DontDelete);
    295378    }
    296379    break;
     
    319402    //printf( "Slicing from %d to %d \n", begin, end );
    320403    for(unsigned int k = 0; k < (unsigned int) end-begin; k++) {
    321       UString str = UString::from(k+begin);
    322       if (thisObj.hasProperty(exec,str)) {
    323         UString str2 = UString::from(k);
    324         Value obj = thisObj.get(exec, str);
    325         resObj.put(exec, str2, obj);
    326       }
    327     }
    328     resObj.put(exec, "length", Number(end - begin), DontEnum | DontDelete);
     404      if (thisObj.hasProperty(exec,k+begin)) {
     405        Value obj = thisObj.get(exec, k+begin);
     406        resObj.put(exec, k, obj);
     407      }
     408    }
     409    resObj.put(exec, lengthPropertyName, Number(end - begin), DontEnum | DontDelete);
    329410    break;
    330411  }
     
    333414    printf("KJS Array::Sort length=%d\n", length);
    334415    for ( unsigned int i = 0 ; i<length ; ++i )
    335       printf("KJS Array::Sort: %d: %s\n", i, thisObj.get(UString::from(i)).toString().value().ascii() );
     416      printf("KJS Array::Sort: %d: %s\n", i, thisObj.get(i).toString().value().ascii() );
    336417#endif
    337418    Object sortFunction;
     
    345426
    346427    if (length == 0) {
    347       thisObj.put(exec, "length", Number(0), DontEnum | DontDelete);
     428      thisObj.put(exec, lengthPropertyName, Number(0), DontEnum | DontDelete);
    348429      result = Undefined();
    349430      break;
     
    354435    for ( unsigned int i = 0 ; i<length-1 ; ++i )
    355436      {
    356         Value iObj = thisObj.get(exec,UString::from(i));
     437        Value iObj = thisObj.get(exec,i);
    357438        unsigned int themin = i;
    358439        Value minObj = iObj;
    359440        for ( unsigned int j = i+1 ; j<length ; ++j )
    360441          {
    361             Value jObj = thisObj.get(exec,UString::from(j));
     442            Value jObj = thisObj.get(exec,j);
    362443            int cmp;
    363444            if (jObj.type() == UndefinedType) {
     
    384465          {
    385466            //printf("KJS Array::Sort: swapping %d and %d\n", i, themin );
    386             thisObj.put( exec, UString::from(i), minObj );
    387             thisObj.put( exec, UString::from(themin), iObj );
     467            thisObj.put( exec, i, minObj );
     468            thisObj.put( exec, themin, iObj );
    388469          }
    389470      }
     
    391472    printf("KJS Array::Sort -- Resulting array:\n");
    392473    for ( unsigned int i = 0 ; i<length ; ++i )
    393       printf("KJS Array::Sort: %d: %s\n", i, thisObj.get(UString::from(i)).toString().value().ascii() );
     474      printf("KJS Array::Sort: %d: %s\n", i, thisObj.get(i).toString().value().ascii() );
    394475#endif
    395476    result = thisObj;
     
    409490    //printf( "Splicing from %d, deleteCount=%d \n", begin, deleteCount );
    410491    for(unsigned int k = 0; k < deleteCount; k++) {
    411       UString str = UString::from(k+begin);
    412       if (thisObj.hasProperty(exec,str)) {
    413         UString str2 = UString::from(k);
    414         Value obj = thisObj.get(exec, str);
    415         resObj.put(exec, str2, obj);
    416       }
    417     }
    418     resObj.put(exec, "length", Number(deleteCount), DontEnum | DontDelete);
     492      if (thisObj.hasProperty(exec,k+begin)) {
     493        Value obj = thisObj.get(exec, k+begin);
     494        resObj.put(exec, k, obj);
     495      }
     496    }
     497    resObj.put(exec, lengthPropertyName, Number(deleteCount), DontEnum | DontDelete);
    419498
    420499    unsigned int additionalArgs = maxInt( args.size() - 2, 0 );
     
    425504        for ( unsigned int k = begin; k < length - deleteCount; ++k )
    426505        {
    427           UString str = UString::from(k+deleteCount);
    428           UString str2 = UString::from(k+additionalArgs);
    429           if (thisObj.hasProperty(exec,str)) {
    430             Value obj = thisObj.get(exec, str);
    431             thisObj.put(exec, str2, obj);
     506          if (thisObj.hasProperty(exec,k+deleteCount)) {
     507            Value obj = thisObj.get(exec, k+deleteCount);
     508            thisObj.put(exec, k+additionalArgs, obj);
    432509          }
    433510          else
    434             thisObj.deleteProperty(exec, str2);
     511            thisObj.deleteProperty(exec, k+additionalArgs);
    435512        }
    436513        for ( unsigned int k = length ; k > length - deleteCount + additionalArgs; --k )
    437           thisObj.deleteProperty(exec, UString::from(k-1));
     514          thisObj.deleteProperty(exec, k-1);
    438515      }
    439516      else
     
    441518        for ( unsigned int k = length - deleteCount; (int)k > begin; --k )
    442519        {
    443           UString str = UString::from(k+deleteCount-1);
    444           UString str2 = UString::from(k+additionalArgs-1);
    445           if (thisObj.hasProperty(exec,str)) {
    446             Value obj = thisObj.get(exec, str);
    447             thisObj.put(exec, str2, obj);
     520          if (thisObj.hasProperty(exec,k+deleteCount-1)) {
     521            Value obj = thisObj.get(exec, k+deleteCount-1);
     522            thisObj.put(exec, k+additionalArgs-1, obj);
    448523          }
    449524          else
    450             thisObj.deleteProperty(exec, str2);
     525            thisObj.deleteProperty(exec, k+additionalArgs-1);
    451526        }
    452527      }
     
    454529    for ( unsigned int k = 0; k < additionalArgs; ++k )
    455530    {
    456       thisObj.put(exec, UString::from(k+begin), args[k+2]);
    457     }
    458     thisObj.put(exec, "length", Number(length - deleteCount + additionalArgs), DontEnum | DontDelete);
     531      thisObj.put(exec, k+begin, args[k+2]);
     532    }
     533    thisObj.put(exec, lengthPropertyName, Number(length - deleteCount + additionalArgs), DontEnum | DontDelete);
    459534    break;
    460535  }
     
    463538    for ( unsigned int k = length; k > 0; --k )
    464539    {
    465       UString str = UString::from(k-1);
    466       UString str2 = UString::from(k+nrArgs-1);
    467       if (thisObj.hasProperty(exec,str)) {
    468         Value obj = thisObj.get(exec, str);
    469         thisObj.put(exec, str2, obj);
     540      if (thisObj.hasProperty(exec,k-1)) {
     541        Value obj = thisObj.get(exec, k-1);
     542        thisObj.put(exec, k+nrArgs-1, obj);
    470543      } else {
    471         thisObj.deleteProperty(exec, str2);
     544        thisObj.deleteProperty(exec, k+nrArgs-1);
    472545      }
    473546    }
    474547    for ( unsigned int k = 0; k < nrArgs; ++k )
    475       thisObj.put(exec, UString::from(k), args[k]);
     548      thisObj.put(exec, k, args[k]);
    476549    result = Number(length + nrArgs);
    477     thisObj.put(exec, "length", result, DontEnum | DontDelete);
     550    thisObj.put(exec, lengthPropertyName, result, DontEnum | DontDelete);
    478551    break;
    479552  }
     
    494567  Value protect(this);
    495568  // ECMA 15.4.3.1 Array.prototype
    496   put(exec,"prototype", Object(arrayProto), DontEnum|DontDelete|ReadOnly);
     569  put(exec,prototypePropertyName, Object(arrayProto), DontEnum|DontDelete|ReadOnly);
    497570
    498571  // no. of arguments for constructor
    499   put(exec,"length", Number(1), ReadOnly|DontDelete|DontEnum);
     572  put(exec,lengthPropertyName, Number(1), ReadOnly|DontDelete|DontEnum);
    500573}
    501574
     
    508581Object ArrayObjectImp::construct(ExecState *exec, const List &args)
    509582{
    510   Object result(new ArrayInstanceImp(exec->interpreter()->builtinArrayPrototype()));
    511 
    512   unsigned int len;
    513   ListIterator it = args.begin();
    514   // a single argument might denote the array size
    515   if (args.size() == 1 && it->type() == NumberType)
    516     len = it->toUInt32(exec);
    517   else {
    518     // initialize array
    519     len = args.size();
    520     for (unsigned int u = 0; it != args.end(); it++, u++)
    521       result.put(exec, UString::from(u), *it);
    522   }
    523 
    524   // array size
    525   result.put(exec, "length", Number(len), DontEnum | DontDelete);
    526   static_cast<ArrayInstanceImp*>(result.imp())->putDirect(exec, "length", Number(len), DontEnum | DontDelete);
    527 
    528   return result;
     583  // a single numeric argument denotes the array size (!)
     584  if (args.size() == 1 && args[0].type() == NumberType)
     585    return Object(new ArrayInstanceImp(exec->interpreter()->builtinArrayPrototype(), args[0].toUInt32(exec)));
     586
     587  // otherwise the array is constructed with the arguments in it
     588  return Object(new ArrayInstanceImp(exec->interpreter()->builtinArrayPrototype(), args));
    529589}
    530590
  • trunk/JavaScriptCore/kjs/array_object.h

    r1024 r1799  
    3030  class ArrayInstanceImp : public ObjectImp {
    3131  public:
    32     ArrayInstanceImp(const Object &proto);
     32    ArrayInstanceImp(const Object &proto, unsigned initialLength);
     33    ArrayInstanceImp(const Object &proto, const List &initialValues);
     34    ~ArrayInstanceImp();
    3335
     36    virtual Value get(ExecState *exec, const UString &propertyName) const;
     37    virtual Value get(ExecState *exec, unsigned propertyName) const;
    3438    virtual void put(ExecState *exec, const UString &propertyName, const Value &value, int attr = None);
    35     virtual void putDirect(ExecState *exec, const UString &propertyName, const Value &value, int attr = None);
    36     /**
    37      * A shallow hasProperty() variant that doesn't look at the prototype's
    38      * properties.
    39      */
    40     virtual bool hasOwnProperty(ExecState *exec, const UString &propertyName);
     39    virtual void put(ExecState *exec, unsigned propertyName, const Value &value, int attr = None);
     40    virtual bool hasProperty(ExecState *exec, const UString &propertyName) const;
     41    virtual bool hasProperty(ExecState *exec, unsigned propertyName) const;
     42    virtual bool deleteProperty(ExecState *exec, const UString &propertyName);
     43    virtual bool deleteProperty(ExecState *exec, unsigned propertyName);
     44
     45    virtual void mark();
    4146
    4247    virtual const ClassInfo *classInfo() const { return &info; }
    4348    static const ClassInfo info;
     49   
     50    unsigned getLength() const { return length; }
     51   
     52  private:
     53    void setLength(unsigned newLength);
     54   
     55    unsigned length;
     56    unsigned capacity;
     57    Value *storage;
    4458  };
    4559
  • trunk/JavaScriptCore/kjs/bool_object.cpp

    r798 r1799  
    5353  // The constructor will be added later by InterpreterImp::InterpreterImp()
    5454
    55   put(exec,"toString", Object(new BooleanProtoFuncImp(exec,funcProto,BooleanProtoFuncImp::ToString,0)), DontEnum);
    56   put(exec,"valueOf",  Object(new BooleanProtoFuncImp(exec,funcProto,BooleanProtoFuncImp::ValueOf,0)),  DontEnum);
     55  put(exec,toStringPropertyName, Object(new BooleanProtoFuncImp(exec,funcProto,BooleanProtoFuncImp::ToString,0)), DontEnum);
     56  put(exec,valueOfPropertyName,  Object(new BooleanProtoFuncImp(exec,funcProto,BooleanProtoFuncImp::ValueOf,0)),  DontEnum);
    5757  setInternalValue(Boolean(false));
    5858}
     
    6666{
    6767  Value protect(this);
    68   put(exec,"length",Number(len),DontDelete|ReadOnly|DontEnum);
     68  put(exec,lengthPropertyName,Number(len),DontDelete|ReadOnly|DontEnum);
    6969}
    7070
     
    105105{
    106106  Value protect(this);
    107   put(exec,"prototype", Object(booleanProto),DontEnum|DontDelete|ReadOnly);
     107  put(exec,prototypePropertyName, Object(booleanProto),DontEnum|DontDelete|ReadOnly);
    108108
    109109  // no. of arguments for constructor
    110   put(exec,"length", Number(1), ReadOnly|DontDelete|DontEnum);
     110  put(exec,lengthPropertyName, Number(1), ReadOnly|DontDelete|DontEnum);
    111111}
    112112
  • trunk/JavaScriptCore/kjs/date_object.cpp

    r1326 r1799  
    148148{
    149149  Value protect(this);
    150   put(exec,"length",Number(len),DontDelete|ReadOnly|DontEnum);
     150  put(exec,lengthPropertyName,Number(len),DontDelete|ReadOnly|DontEnum);
    151151}
    152152
     
    322322  Value protect(this);
    323323  // ECMA 15.9.4.1 Date.prototype
    324   put(exec,"prototype", Object(dateProto), DontEnum|DontDelete|ReadOnly);
     324  put(exec,prototypePropertyName, Object(dateProto), DontEnum|DontDelete|ReadOnly);
    325325
    326326  put(exec,"parse", Object(new DateObjectFuncImp(exec,funcProto,DateObjectFuncImp::Parse, 1)), DontEnum);
     
    328328
    329329  // no. of arguments for constructor
    330   put(exec,"length", Number(7), ReadOnly|DontDelete|DontEnum);
     330  put(exec,lengthPropertyName, Number(7), ReadOnly|DontDelete|DontEnum);
    331331}
    332332
     
    417417{
    418418  Value protect(this);
    419   put(exec,"length",Number(len),DontDelete|ReadOnly|DontEnum);
     419  put(exec,lengthPropertyName,Number(len),DontDelete|ReadOnly|DontEnum);
    420420}
    421421
  • trunk/JavaScriptCore/kjs/error_object.cpp

    r798 r1799  
    4444  put(exec, "name",     String("Error"), DontEnum);
    4545  put(exec, "message",  String("Unknown error"), DontEnum);
    46   put(exec, "toString", Object(new ErrorProtoFuncImp(exec,funcProto)), DontEnum);
     46  put(exec, toStringPropertyName, Object(new ErrorProtoFuncImp(exec,funcProto)), DontEnum);
    4747}
    4848
     
    5353{
    5454  Value protect(this);
    55   put(exec,"length",Number(0),DontDelete|ReadOnly|DontEnum);
     55  put(exec,lengthPropertyName,Number(0),DontDelete|ReadOnly|DontEnum);
    5656}
    5757
     
    8787  Value protect(this);
    8888  // ECMA 15.11.3.1 Error.prototype
    89   put(exec, "prototype", Object(errorProto), DontEnum|DontDelete|ReadOnly);
     89  put(exec, prototypePropertyName, Object(errorProto), DontEnum|DontDelete|ReadOnly);
    9090  //put(exec, "name", String(n));
    9191}
     
    144144  proto = static_cast<ObjectImp*>(prot.imp());
    145145
    146   put(exec,"length",Number(1),DontDelete|ReadOnly|DontEnum); // ECMA 15.11.7.5
    147   put(exec,"prototype",prot);
     146  put(exec,lengthPropertyName,Number(1),DontDelete|ReadOnly|DontEnum); // ECMA 15.11.7.5
     147  put(exec,prototypePropertyName,prot);
    148148}
    149149
  • trunk/JavaScriptCore/kjs/function.cpp

    r1623 r1799  
    275275{
    276276  Object proto;
    277   Value p = get(exec,"prototype");
     277  Value p = get(exec,prototypePropertyName);
    278278  if (p.type() == ObjectType)
    279279    proto = Object(static_cast<ObjectImp*>(p.imp()));
     
    315315  Value protect(this);
    316316  put(exec,"callee", Object(func), DontEnum);
    317   put(exec,"length", Number(args.size()), DontEnum);
     317  put(exec,lengthPropertyName, Number(args.size()), DontEnum);
    318318  if (!args.isEmpty()) {
    319319    ListIterator arg = args.begin();
    320320    for (int i = 0; arg != args.end(); arg++, i++) {
    321       put(exec,UString::from(i), *arg, DontEnum);
     321      put(exec,i, *arg, DontEnum);
    322322    }
    323323  }
     
    349349{
    350350  Value protect(this);
    351   put(exec,"length",Number(len),DontDelete|ReadOnly|DontEnum);
     351  put(exec,lengthPropertyName,Number(len),DontDelete|ReadOnly|DontEnum);
    352352}
    353353
  • trunk/JavaScriptCore/kjs/function_object.cpp

    r1024 r1799  
    4141{
    4242  Value protect(this);
    43   put(exec, "toString", Object(new FunctionProtoFuncImp(exec, this, FunctionProtoFuncImp::ToString, 0)), DontEnum);
     43  put(exec, toStringPropertyName, Object(new FunctionProtoFuncImp(exec, this, FunctionProtoFuncImp::ToString, 0)), DontEnum);
    4444  put(exec, "apply",    Object(new FunctionProtoFuncImp(exec, this, FunctionProtoFuncImp::Apply,    2)), DontEnum);
    4545  put(exec, "call",     Object(new FunctionProtoFuncImp(exec, this, FunctionProtoFuncImp::Call,     1)), DontEnum);
     
    6868{
    6969  Value protect(this);
    70   put(exec,"length",Number(len),DontDelete|ReadOnly|DontEnum);
     70  put(exec,lengthPropertyName,Number(len),DontDelete|ReadOnly|DontEnum);
    7171}
    7272
     
    130130
    131131        Object argArrayObj = Object::dynamicCast(argArray);
    132         unsigned int length = argArrayObj.get(exec,"length").toUInt32(exec);
     132        unsigned int length = argArrayObj.get(exec,lengthPropertyName).toUInt32(exec);
    133133        for (unsigned int i = 0; i < length; i++)
    134           applyArgs.append(argArrayObj.get(exec,UString::from(i)));
     134          applyArgs.append(argArrayObj.get(exec,i));
    135135      }
    136136      else {
     
    175175{
    176176  Value protect(this);
    177   put(exec,"prototype", Object(funcProto), DontEnum|DontDelete|ReadOnly);
     177  put(exec,prototypePropertyName, Object(funcProto), DontEnum|DontDelete|ReadOnly);
    178178
    179179  // no. of arguments for constructor
    180   put(exec,"length", Number(1), ReadOnly|DontDelete|DontEnum);
     180  put(exec,lengthPropertyName, Number(1), ReadOnly|DontDelete|DontEnum);
    181181}
    182182
     
    276276  }
    277277
    278   fimp->put(exec,"length", Number(params),ReadOnly|DontDelete|DontEnum);
     278  fimp->put(exec,lengthPropertyName, Number(params),ReadOnly|DontDelete|DontEnum);
    279279  List consArgs;
    280280
     
    283283  prototype.put(exec, "constructor",
    284284                Object(fimp), DontEnum|DontDelete|ReadOnly);
    285   fimp->put(exec,"prototype",prototype,DontEnum|DontDelete|ReadOnly);
     285  fimp->put(exec,prototypePropertyName,prototype,DontEnum|DontDelete|ReadOnly);
    286286  fimp->put(exec,"arguments",Null(),DontEnum|DontDelete|ReadOnly);
    287287  return ret;
  • trunk/JavaScriptCore/kjs/internal.cpp

    r1790 r1799  
    193193// ------------------------------ StringImp ------------------------------------
    194194
    195 StringImp::StringImp(const UString& v)
    196   : val(v)
    197 {
    198 }
    199 
    200195Value StringImp::toPrimitive(ExecState */*exec*/, Type) const
    201196{
     
    221216{
    222217  List args;
    223   args.append(String(const_cast<StringImp*>(this)));
     218  args.append(Value(const_cast<StringImp*>(this)));
    224219  return Object::dynamicCast(exec->interpreter()->builtinString().construct(exec,args));
    225220}
    226221
    227222// ------------------------------ NumberImp ------------------------------------
    228 
    229 NumberImp::NumberImp(double v)
    230   : val(v)
    231 {
    232 }
    233223
    234224Value NumberImp::toPrimitive(ExecState *, Type) const
     
    259249}
    260250
     251bool NumberImp::toUInt32(unsigned& uint32) const
     252{
     253  uint32 = (unsigned)val;
     254  return (double)uint32 == val;
     255}
     256
    261257// ------------------------------ ReferenceImp ---------------------------------
    262258
     259ReferenceImp::ReferenceImp(const Value& v, unsigned p)
     260  : base(v.imp()), propertyNameIsNumber(true), propertyNameAsNumber(p)
     261{
     262}
     263
    263264ReferenceImp::ReferenceImp(const Value& v, const UString& p)
    264   : base(v.imp()), prop(p)
     265  : base(v.imp()), propertyNameIsNumber(false), prop(p)
    265266{
    266267}
     
    306307  assert(false);
    307308  return Object();
     309}
     310
     311UString ReferenceImp::getPropertyName(ExecState *) const
     312{
     313  if (propertyNameIsNumber && prop.isNull())
     314    prop = UString::from(propertyNameAsNumber);
     315  return prop;
     316}
     317
     318Value ReferenceImp::getValue(ExecState *exec) const
     319{
     320  Value o = getBase(exec);
     321
     322  if (o.isNull() || o.type() == NullType) {
     323    UString m = I18N_NOOP("Can't find variable: ") + getPropertyName(exec);
     324    Object err = Error::create(exec, ReferenceError, m.ascii());
     325    exec->setException(err);
     326    return err;
     327  }
     328
     329  if (o.type() != ObjectType) {
     330    UString m = I18N_NOOP("Base is not an object");
     331    Object err = Error::create(exec, ReferenceError, m.ascii());
     332    exec->setException(err);
     333    return err;
     334  }
     335
     336  if (propertyNameIsNumber)
     337    return static_cast<ObjectImp*>(o.imp())->get(exec,propertyNameAsNumber);
     338  return static_cast<ObjectImp*>(o.imp())->get(exec,prop);
     339}
     340
     341void ReferenceImp::putValue(ExecState *exec, const Value& w)
     342{
     343#ifdef KJS_VERBOSE
     344  printInfo(exec,(UString("setting property ")+getPropertyName(exec)).cstring().c_str(),w);
     345#endif
     346  Value o = getBase(exec);
     347  if (o.type() == NullType)
     348    o = exec->interpreter()->globalObject();
     349
     350  if (propertyNameIsNumber)
     351    return static_cast<ObjectImp*>(o.imp())->put(exec,propertyNameAsNumber, w);
     352  return static_cast<ObjectImp*>(o.imp())->put(exec,prop, w);
     353}
     354
     355bool ReferenceImp::deleteValue(ExecState *exec)
     356{
     357  Value b = getBase(exec);
     358
     359  // The spec doesn't mention what to do if the base is null... just return true
     360  if (b.type() != ObjectType) {
     361    assert(b.type() == NullType);
     362    return true;
     363  }
     364
     365  if (propertyNameIsNumber)
     366    return static_cast<ObjectImp*>(b.imp())->deleteProperty(exec,propertyNameAsNumber);
     367  return static_cast<ObjectImp*>(b.imp())->deleteProperty(exec,prop);
    308368}
    309369
     
    11201180    return Boolean(false);
    11211181
    1122   Value prot = get(exec,"prototype");
     1182  Value prot = get(exec,prototypePropertyName);
    11231183  if (prot.type() != ObjectType && prot.type() != NullType) {
    11241184    Object err = Error::create(exec, TypeError, "Invalid prototype encountered "
  • trunk/JavaScriptCore/kjs/internal.h

    r1024 r1799  
    5050  class UndefinedImp : public ValueImp {
    5151  public:
    52     UndefinedImp() {}
    53     virtual ~UndefinedImp() { }
    54 
    5552    Type type() const { return UndefinedType; }
    5653
     
    6461  };
    6562
     63  inline Undefined::Undefined(UndefinedImp *imp) : Value(imp) { }
     64
    6665  class NullImp : public ValueImp {
    6766  public:
    68     NullImp() {}
    69     virtual ~NullImp() { }
    70 
    7167    Type type() const { return NullType; }
    7268
     
    8076  };
    8177
     78  inline Null::Null(NullImp *imp) : Value(imp) { }
     79
    8280  class BooleanImp : public ValueImp {
    8381  public:
    84     virtual ~BooleanImp() { }
    8582    BooleanImp(bool v = false) : val(v) { }
    8683    bool value() const { return val; }
     
    9996    bool val;
    10097  };
     98 
     99  inline Boolean::Boolean(BooleanImp *imp) : Value(imp) { }
    101100
    102101  class StringImp : public ValueImp {
    103102  public:
    104     StringImp(const UString& v);
    105     virtual ~StringImp() { }
     103    StringImp(const UString& v) : val(v) { }
    106104    UString value() const { return val; }
    107105
     
    118116  };
    119117
     118  inline String::String(StringImp *imp) : Value(imp) { }
     119
    120120  class NumberImp : public ValueImp {
    121121  public:
    122     NumberImp(double v);
    123     virtual ~NumberImp() { }
     122    NumberImp(double v) : val(v) { }
    124123    double value() const { return val; }
    125124
     
    132131    Object toObject(ExecState *exec) const;
    133132
     133    virtual bool toUInt32(unsigned&) const;
     134
    134135  private:
    135136    double val;
    136137  };
     138
     139  inline Number::Number(NumberImp *imp) : Value(imp) { }
    137140
    138141  // ---------------------------------------------------------------------------
     
    142145  class ReferenceImp : public ValueImp {
    143146  public:
    144 
    145147    ReferenceImp(const Value& v, const UString& p);
    146     virtual ~ReferenceImp() { }
     148    ReferenceImp(const Value& v, unsigned p);
    147149    virtual void mark();
    148150
     
    153155    Object toObject(ExecState *exec) const;
    154156
    155     Value getBase() const { return Value(base); }
    156     UString getPropertyName() const { return prop; }
     157    Value getBase(ExecState *) const { return Value(base); }
     158    UString getPropertyName(ExecState *) const;
     159    Value getValue(ExecState *exec) const;
     160    void putValue(ExecState *exec, const Value& w);
     161    bool deleteValue(ExecState *exec);
    157162
    158163    Type type() const { return ReferenceType; }
     
    160165  private:
    161166    ValueImp *base;
    162     UString prop;
    163   };
     167    bool propertyNameIsNumber;
     168    unsigned propertyNameAsNumber;
     169    mutable UString prop;
     170  };
     171 
     172  inline Reference::Reference(ReferenceImp *imp) : Value(imp) { }
    164173
    165174  class CompletionImp : public ValueImp {
     
    186195    UString tar;
    187196  };
     197
     198  inline Completion::Completion(CompletionImp *imp) : Value(imp) { }
    188199
    189200  /**
     
    244255    static ListImp *emptyList;
    245256  };
     257 
     258  inline List::List(ListImp *imp) : Value(imp) { }
    246259
    247260  /**
  • trunk/JavaScriptCore/kjs/math_object.cpp

    r1623 r1799  
    131131{
    132132  Value protect(this);
    133   put(exec,"length",Number(l),DontDelete|ReadOnly|DontEnum);
     133  put(exec,lengthPropertyName,Number(l),DontDelete|ReadOnly|DontEnum);
    134134}
    135135
  • trunk/JavaScriptCore/kjs/nodes.cpp

    r1623 r1799  
    118118}
    119119
    120 StatementNode::~StatementNode()
    121 {
    122 }
    123 
    124120void StatementNode::setLoc(int line0, int line1, int sourceId)
    125121{
     
    227223// ------------------------------ GroupNode ------------------------------------
    228224
    229 GroupNode::~GroupNode()
    230 {
    231 }
    232 
    233225void GroupNode::ref()
    234226{
     
    252244
    253245// ------------------------------ ElisionNode ----------------------------------
    254 
    255 ElisionNode::~ElisionNode()
    256 {
    257 }
    258246
    259247void ElisionNode::ref()
     
    281269
    282270// ------------------------------ ElementNode ----------------------------------
    283 
    284 ElementNode::~ElementNode()
    285 {
    286 }
    287271
    288272void ElementNode::ref()
     
    321305    KJS_CHECKEXCEPTIONVALUE
    322306    val = node->evaluate(exec).getValue(exec);
    323     length = array.get(exec,"length").toInt32(exec);
     307    length = array.get(exec,lengthPropertyName).toInt32(exec);
    324308  } else {
    325309    Value newArr = exec->interpreter()->builtinArray().construct(exec,List::empty());
     
    329313  }
    330314
    331   array.put(exec, UString::from(elisionLen + length), val);
     315  array.put(exec, elisionLen + length, val);
    332316
    333317  return array;
     
    335319
    336320// ------------------------------ ArrayNode ------------------------------------
    337 
    338 ArrayNode::~ArrayNode()
    339 {
    340 }
    341321
    342322void ArrayNode::ref()
     
    369349    array = Object(static_cast<ObjectImp*>(element->evaluate(exec).imp()));
    370350    KJS_CHECKEXCEPTIONVALUE
    371     length = opt ? array.get(exec,"length").toInt32(exec) : 0;
     351    length = opt ? array.get(exec,lengthPropertyName).toInt32(exec) : 0;
    372352  } else {
    373353    Value newArr = exec->interpreter()->builtinArray().construct(exec,List::empty());
     
    377357
    378358  if (opt)
    379     array.put(exec,"length", Number(elisionLen + length), DontEnum | DontDelete);
     359    array.put(exec,lengthPropertyName, Number(elisionLen + length), DontEnum | DontDelete);
    380360
    381361  return array;
     
    383363
    384364// ------------------------------ ObjectLiteralNode ----------------------------
    385 
    386 ObjectLiteralNode::~ObjectLiteralNode()
    387 {
    388 }
    389365
    390366void ObjectLiteralNode::ref()
     
    412388
    413389// ------------------------------ PropertyValueNode ----------------------------
    414 
    415 PropertyValueNode::~PropertyValueNode()
    416 {
    417 }
    418390
    419391void PropertyValueNode::ref()
     
    479451// ------------------------------ AccessorNode1 --------------------------------
    480452
    481 AccessorNode1::~AccessorNode1()
    482 {
    483 }
    484 
    485453void AccessorNode1::ref()
    486454{
     
    511479  Value v2 = e2.getValue(exec);
    512480  Object o = v1.toObject(exec);
     481  unsigned i;
     482  if (v2.toUInt32(i))
     483    return Reference(o, i);
    513484  String s = v2.toString(exec);
    514485  return Reference(o, s.value());
     
    516487
    517488// ------------------------------ AccessorNode2 --------------------------------
    518 
    519 AccessorNode2::~AccessorNode2()
    520 {
    521 }
    522489
    523490void AccessorNode2::ref()
     
    553520ArgumentListNode::ArgumentListNode(ArgumentListNode *l, Node *e)
    554521  : list(l), expr(e)
    555 {
    556 }
    557 
    558 ArgumentListNode::~ArgumentListNode()
    559522{
    560523}
     
    608571}
    609572
    610 ArgumentsNode::~ArgumentsNode()
    611 {
    612 }
    613 
    614573void ArgumentsNode::ref()
    615574{
     
    644603
    645604// ECMA 11.2.2
    646 
    647 NewExprNode::~NewExprNode()
    648 {
    649 }
    650605
    651606void NewExprNode::ref()
     
    694649
    695650// ------------------------------ FunctionCallNode -----------------------------
    696 
    697 FunctionCallNode::~FunctionCallNode()
    698 {
    699 }
    700651
    701652void FunctionCallNode::ref()
     
    788739// ------------------------------ PostfixNode ----------------------------------
    789740
    790 PostfixNode::~PostfixNode()
    791 {
    792 }
    793 
    794741void PostfixNode::ref()
    795742{
     
    824771// ------------------------------ DeleteNode -----------------------------------
    825772
    826 DeleteNode::~DeleteNode()
    827 {
    828 }
    829 
    830773void DeleteNode::ref()
    831774{
     
    847790  Value e = expr->evaluate(exec);
    848791  KJS_CHECKEXCEPTIONVALUE
    849   if (e.type() != ReferenceType)
    850     return Boolean(true);
    851   Value b = e.getBase(exec);
    852   UString n = e.getPropertyName(exec);
    853 
    854   // The spec doesn't mention what to do if the base is null... just return true
    855   if (b.type() != ObjectType) {
    856     assert(b.type() == NullType);
    857     return Boolean(true);
    858   }
    859 
    860   Object o = Object(static_cast<ObjectImp*>(b.imp()));
    861 
    862   bool ret = o.deleteProperty(exec,n);
    863 
    864   return Boolean(ret);
     792  return Boolean(e.deleteValue(exec));
    865793}
    866794
    867795// ------------------------------ VoidNode -------------------------------------
    868 
    869 VoidNode::~VoidNode()
    870 {
    871 }
    872796
    873797void VoidNode::ref()
     
    896820
    897821// ------------------------------ TypeOfNode -----------------------------------
    898 
    899 TypeOfNode::~TypeOfNode()
    900 {
    901 }
    902822
    903823void TypeOfNode::ref()
     
    957877// ------------------------------ PrefixNode -----------------------------------
    958878
    959 PrefixNode::~PrefixNode()
    960 {
    961 }
    962 
    963879void PrefixNode::ref()
    964880{
     
    993909// ------------------------------ UnaryPlusNode --------------------------------
    994910
    995 UnaryPlusNode::~UnaryPlusNode()
    996 {
    997 }
    998 
    999911void UnaryPlusNode::ref()
    1000912{
     
    1023935// ------------------------------ NegateNode -----------------------------------
    1024936
    1025 NegateNode::~NegateNode()
    1026 {
    1027 }
    1028 
    1029937void NegateNode::ref()
    1030938{
     
    1056964// ------------------------------ BitwiseNotNode -------------------------------
    1057965
    1058 BitwiseNotNode::~BitwiseNotNode()
    1059 {
    1060 }
    1061 
    1062966void BitwiseNotNode::ref()
    1063967{
     
    1087991// ------------------------------ LogicalNotNode -------------------------------
    1088992
    1089 LogicalNotNode::~LogicalNotNode()
    1090 {
    1091 }
    1092 
    1093993void LogicalNotNode::ref()
    1094994{
     
    11171017
    11181018// ------------------------------ MultNode -------------------------------------
    1119 
    1120 MultNode::~MultNode()
    1121 {
    1122 }
    11231019
    11241020void MultNode::ref()
     
    11561052// ------------------------------ AddNode --------------------------------------
    11571053
    1158 AddNode::~AddNode()
    1159 {
    1160 }
    1161 
    11621054void AddNode::ref()
    11631055{
     
    11931085
    11941086// ------------------------------ ShiftNode ------------------------------------
    1195 
    1196 ShiftNode::~ShiftNode()
    1197 {
    1198 }
    11991087
    12001088void ShiftNode::ref()
     
    12481136
    12491137// ------------------------------ RelationalNode -------------------------------
    1250 
    1251 RelationalNode::~RelationalNode()
    1252 {
    1253 }
    12541138
    12551139void RelationalNode::ref()
     
    13241208// ------------------------------ EqualNode ------------------------------------
    13251209
    1326 EqualNode::~EqualNode()
    1327 {
    1328 }
    1329 
    13301210void EqualNode::ref()
    13311211{
     
    13701250
    13711251// ------------------------------ BitOperNode ----------------------------------
    1372 
    1373 BitOperNode::~BitOperNode()
    1374 {
    1375 }
    13761252
    13771253void BitOperNode::ref()
     
    14171293// ------------------------------ BinaryLogicalNode ----------------------------
    14181294
    1419 BinaryLogicalNode::~BinaryLogicalNode()
    1420 {
    1421 }
    1422 
    14231295void BinaryLogicalNode::ref()
    14241296{
     
    14571329
    14581330// ------------------------------ ConditionalNode ------------------------------
    1459 
    1460 ConditionalNode::~ConditionalNode()
    1461 {
    1462 }
    14631331
    14641332void ConditionalNode::ref()
     
    15021370
    15031371// ------------------------------ AssignNode -----------------------------------
    1504 
    1505 AssignNode::~AssignNode()
    1506 {
    1507 }
    15081372
    15091373void AssignNode::ref()
     
    15971461// ------------------------------ CommaNode ------------------------------------
    15981462
    1599 CommaNode::~CommaNode()
    1600 {
    1601 }
    1602 
    16031463void CommaNode::ref()
    16041464{
     
    16321492
    16331493// ------------------------------ StatListNode ---------------------------------
    1634 
    1635 StatListNode::~StatListNode()
    1636 {
    1637 }
    16381494
    16391495void StatListNode::ref()
     
    16981554// ------------------------------ AssignExprNode -------------------------------
    16991555
    1700 AssignExprNode::~AssignExprNode()
    1701 {
    1702 }
    1703 
    17041556void AssignExprNode::ref()
    17051557{
     
    17261578VarDeclNode::VarDeclNode(const UString *id, AssignExprNode *in)
    17271579    : ident(*id), init(in)
    1728 {
    1729 }
    1730 
    1731 VarDeclNode::~VarDeclNode()
    17321580{
    17331581}
     
    17811629// ------------------------------ VarDeclListNode ------------------------------
    17821630
    1783 VarDeclListNode::~VarDeclListNode()
    1784 {
    1785 }
    1786 
    17871631void VarDeclListNode::ref()
    17881632{
     
    18271671// ------------------------------ VarStatementNode -----------------------------
    18281672
    1829 VarStatementNode::~VarStatementNode()
    1830 {
    1831 }
    1832 
    18331673void VarStatementNode::ref()
    18341674{
     
    18631703// ------------------------------ BlockNode ------------------------------------
    18641704
    1865 BlockNode::~BlockNode()
    1866 {
    1867 }
    1868 
    18691705void BlockNode::ref()
    18701706{
     
    19071743
    19081744// ------------------------------ ExprStatementNode ----------------------------
    1909 
    1910 ExprStatementNode::~ExprStatementNode()
    1911 {
    1912 }
    19131745
    19141746void ExprStatementNode::ref()
     
    19391771
    19401772// ------------------------------ IfNode ---------------------------------------
    1941 
    1942 IfNode::~IfNode()
    1943 {
    1944 }
    19451773
    19461774void IfNode::ref()
     
    19971825
    19981826// ------------------------------ DoWhileNode ----------------------------------
    1999 
    2000 DoWhileNode::~DoWhileNode()
    2001 {
    2002 }
    20031827
    20041828void DoWhileNode::ref()
     
    20551879// ------------------------------ WhileNode ------------------------------------
    20561880
    2057 WhileNode::~WhileNode()
    2058 {
    2059 }
    2060 
    20611881void WhileNode::ref()
    20621882{
     
    21181938
    21191939// ------------------------------ ForNode --------------------------------------
    2120 
    2121 ForNode::~ForNode()
    2122 {
    2123 }
    21241940
    21251941void ForNode::ref()
     
    22122028}
    22132029
    2214 ForInNode::~ForInNode()
    2215 {
    2216 }
    2217 
    22182030void ForInNode::ref()
    22192031{
     
    23332145// ------------------------------ ReturnNode -----------------------------------
    23342146
    2335 ReturnNode::~ReturnNode()
    2336 {
    2337 }
    2338 
    23392147void ReturnNode::ref()
    23402148{
     
    23672175
    23682176// ------------------------------ WithNode -------------------------------------
    2369 
    2370 WithNode::~WithNode()
    2371 {
    2372 }
    23732177
    23742178void WithNode::ref()
     
    24142218// ------------------------------ CaseClauseNode -------------------------------
    24152219
    2416 CaseClauseNode::~CaseClauseNode()
    2417 {
    2418 }
    2419 
    24202220void CaseClauseNode::ref()
    24212221{
     
    24632263// ------------------------------ ClauseListNode -------------------------------
    24642264
    2465 ClauseListNode::~ClauseListNode()
    2466 {
    2467 }
    2468 
    24692265void ClauseListNode::ref()
    24702266{
     
    25122308
    25132309// ------------------------------ CaseBlockNode --------------------------------
    2514 
    2515 CaseBlockNode::~CaseBlockNode()
    2516 {
    2517 }
    25182310
    25192311void CaseBlockNode::ref()
     
    26202412// ------------------------------ SwitchNode -----------------------------------
    26212413
    2622 SwitchNode::~SwitchNode()
    2623 {
    2624 }
    2625 
    26262414void SwitchNode::ref()
    26272415{
     
    26642452
    26652453// ------------------------------ LabelNode ------------------------------------
    2666 
    2667 LabelNode::~LabelNode()
    2668 {
    2669 }
    26702454
    26712455void LabelNode::ref()
     
    27082492// ------------------------------ ThrowNode ------------------------------------
    27092493
    2710 ThrowNode::~ThrowNode()
    2711 {
    2712 }
    2713 
    27142494void ThrowNode::ref()
    27152495{
     
    27422522
    27432523// ------------------------------ CatchNode ------------------------------------
    2744 
    2745 CatchNode::~CatchNode()
    2746 {
    2747 }
    27482524
    27492525void CatchNode::ref()
     
    27912567// ------------------------------ FinallyNode ----------------------------------
    27922568
    2793 FinallyNode::~FinallyNode()
    2794 {
    2795 }
    2796 
    27972569void FinallyNode::ref()
    27982570{
     
    28212593
    28222594// ------------------------------ TryNode --------------------------------------
    2823 
    2824 TryNode::~TryNode()
    2825 {
    2826 }
    28272595
    28282596void TryNode::ref()
     
    28862654// ------------------------------ ParameterNode --------------------------------
    28872655
    2888 ParameterNode::~ParameterNode()
    2889 {
    2890 }
    2891 
    28922656void ParameterNode::ref()
    28932657{
     
    29312695}
    29322696
    2933 FunctionBodyNode::~FunctionBodyNode()
    2934 {
    2935   //fprintf(stderr,"FunctionBodyNode::~FunctionBodyNode %p\n",this);
    2936 }
    2937 
    29382697void FunctionBodyNode::ref()
    29392698{
     
    29772736
    29782737// ------------------------------ FuncDeclNode ---------------------------------
    2979 
    2980 FuncDeclNode::~FuncDeclNode()
    2981 {
    2982 }
    29832738
    29842739void FuncDeclNode::ref()
     
    30122767  List empty;
    30132768  Value proto = exec->interpreter()->builtinObject().construct(exec,empty);
    3014   func.put(exec, "prototype", proto, Internal|DontDelete);
     2769  func.put(exec, prototypePropertyName, proto, Internal|DontDelete);
    30152770
    30162771  int plen = 0;
     
    30182773    fimp->addParameter(p->ident());
    30192774
    3020   func.put(exec, "length", Number(plen), ReadOnly|DontDelete|DontEnum);
     2775  func.put(exec, lengthPropertyName, Number(plen), ReadOnly|DontDelete|DontEnum);
    30212776
    30222777  exec->context().imp()->variableObject().put(exec,ident,func);
     
    30362791// ------------------------------ FuncExprNode ---------------------------------
    30372792
    3038 FuncExprNode::~FuncExprNode()
    3039 {
    3040 }
    3041 
    30422793void FuncExprNode::ref()
    30432794{
     
    30672818  List empty;
    30682819  Value proto = exec->interpreter()->builtinObject().construct(exec,empty);
    3069   fimp->put(exec, "prototype", proto, Internal|DontDelete);
     2820  fimp->put(exec, prototypePropertyName, proto, Internal|DontDelete);
    30702821
    30712822  int plen = 0;
    30722823  for(ParameterNode *p = param; p != 0L; p = p->nextParam(), plen++)
    30732824    fimp->addParameter(p->ident());
    3074   fimp->put(exec,"length", Number(plen), ReadOnly|DontDelete|DontEnum);
     2825  fimp->put(exec,lengthPropertyName, Number(plen), ReadOnly|DontDelete|DontEnum);
    30752826
    30762827  return ret;
     
    30782829
    30792830// ------------------------------ SourceElementNode ----------------------------
    3080 
    3081 SourceElementNode::~SourceElementNode()
    3082 {
    3083 }
    30842831
    30852832void SourceElementNode::ref()
     
    31242871
    31252872// ------------------------------ SourceElementsNode ---------------------------
    3126 
    3127 SourceElementsNode::~SourceElementsNode()
    3128 {
    3129 }
    31302873
    31312874void SourceElementsNode::ref()
     
    31882931    //fprintf(stderr,"ProgramNode::ProgramNode %p\n",this);
    31892932}
    3190 
    3191 ProgramNode::~ProgramNode() {
    3192     //fprintf(stderr,"ProgramNode::~ProgramNode %p\n",this);
    3193 }
  • trunk/JavaScriptCore/kjs/nodes.h

    r1623 r1799  
    112112  public:
    113113    StatementNode();
    114     ~StatementNode();
    115114    void setLoc(int line0, int line1, int sourceId);
    116115    int firstLine() const { return l0; }
     
    197196    virtual void ref();
    198197    virtual bool deref();
    199     virtual ~GroupNode();
    200198    Value evaluate(ExecState *exec);
    201199    virtual void streamTo(SourceStream &s) const { group->streamTo(s); }
     
    209207    virtual void ref();
    210208    virtual bool deref();
    211     virtual ~ElisionNode();
    212209    Value evaluate(ExecState *exec);
    213210    virtual void streamTo(SourceStream &s) const;
     
    223220    virtual void ref();
    224221    virtual bool deref();
    225     virtual ~ElementNode();
    226222    Value evaluate(ExecState *exec);
    227223    virtual void streamTo(SourceStream &s) const;
     
    241237    virtual void ref();
    242238    virtual bool deref();
    243     virtual ~ArrayNode();
    244239    Value evaluate(ExecState *exec);
    245240    virtual void streamTo(SourceStream &s) const;
     
    255250    virtual void ref();
    256251    virtual bool deref();
    257     virtual ~ObjectLiteralNode();
    258252    Value evaluate(ExecState *exec);
    259253    virtual void streamTo(SourceStream &s) const;
     
    268262    virtual void ref();
    269263    virtual bool deref();
    270     virtual ~PropertyValueNode();
    271264    Value evaluate(ExecState *exec);
    272265    virtual void streamTo(SourceStream &s) const;
     
    291284    virtual void ref();
    292285    virtual bool deref();
    293     virtual ~AccessorNode1();
    294286    Value evaluate(ExecState *exec);
    295287    virtual void streamTo(SourceStream &s) const;
     
    304296    virtual void ref();
    305297    virtual bool deref();
    306     virtual ~AccessorNode2();
    307298    Value evaluate(ExecState *exec);
    308299    virtual void streamTo(SourceStream &s) const;
     
    318309    virtual void ref();
    319310    virtual bool deref();
    320     virtual ~ArgumentListNode();
    321311    Value evaluate(ExecState *exec);
    322312    List evaluateList(ExecState *exec);
     
    332322    virtual void ref();
    333323    virtual bool deref();
    334     virtual ~ArgumentsNode();
    335324    Value evaluate(ExecState *exec);
    336325    List evaluateList(ExecState *exec);
     
    346335    virtual void ref();
    347336    virtual bool deref();
    348     virtual ~NewExprNode();
    349337    Value evaluate(ExecState *exec);
    350338    virtual void streamTo(SourceStream &s) const;
     
    359347    virtual void ref();
    360348    virtual bool deref();
    361     virtual ~FunctionCallNode();
    362349    Value evaluate(ExecState *exec);
    363350    virtual void streamTo(SourceStream &s) const;
     
    372359    virtual void ref();
    373360    virtual bool deref();
    374     virtual ~PostfixNode();
    375361    Value evaluate(ExecState *exec);
    376362    virtual void streamTo(SourceStream &s) const;
     
    385371    virtual void ref();
    386372    virtual bool deref();
    387     virtual ~DeleteNode();
    388373    Value evaluate(ExecState *exec);
    389374    virtual void streamTo(SourceStream &s) const;
     
    397382    virtual void ref();
    398383    virtual bool deref();
    399     virtual ~VoidNode();
    400384    Value evaluate(ExecState *exec);
    401385    virtual void streamTo(SourceStream &s) const;
     
    409393    virtual void ref();
    410394    virtual bool deref();
    411     virtual ~TypeOfNode();
    412395    Value evaluate(ExecState *exec);
    413396    virtual void streamTo(SourceStream &s) const;
     
    421404    virtual void ref();
    422405    virtual bool deref();
    423     virtual ~PrefixNode();
    424406    Value evaluate(ExecState *exec);
    425407    virtual void streamTo(SourceStream &s) const;
     
    434416    virtual void ref();
    435417    virtual bool deref();
    436     virtual ~UnaryPlusNode();
    437418    Value evaluate(ExecState *exec);
    438419    virtual void streamTo(SourceStream &s) const;
     
    446427    virtual void ref();
    447428    virtual bool deref();
    448     virtual ~NegateNode();
    449429    Value evaluate(ExecState *exec);
    450430    virtual void streamTo(SourceStream &s) const;
     
    458438    virtual void ref();
    459439    virtual bool deref();
    460     virtual ~BitwiseNotNode();
    461440    Value evaluate(ExecState *exec);
    462441    virtual void streamTo(SourceStream &s) const;
     
    470449    virtual void ref();
    471450    virtual bool deref();
    472     virtual ~LogicalNotNode();
    473451    Value evaluate(ExecState *exec);
    474452    virtual void streamTo(SourceStream &s) const;
     
    482460    virtual void ref();
    483461    virtual bool deref();
    484     virtual ~MultNode();
    485462    Value evaluate(ExecState *exec);
    486463    virtual void streamTo(SourceStream &s) const;
     
    495472    virtual void ref();
    496473    virtual bool deref();
    497     virtual ~AddNode();
    498474    Value evaluate(ExecState *exec);
    499475    virtual void streamTo(SourceStream &s) const;
     
    509485    virtual void ref();
    510486    virtual bool deref();
    511     virtual ~ShiftNode();
    512487    Value evaluate(ExecState *exec);
    513488    virtual void streamTo(SourceStream &s) const;
     
    523498    virtual void ref();
    524499    virtual bool deref();
    525     virtual ~RelationalNode();
    526500    Value evaluate(ExecState *exec);
    527501    virtual void streamTo(SourceStream &s) const;
     
    537511    virtual void ref();
    538512    virtual bool deref();
    539     virtual ~EqualNode();
    540513    Value evaluate(ExecState *exec);
    541514    virtual void streamTo(SourceStream &s) const;
     
    551524    virtual void ref();
    552525    virtual bool deref();
    553     virtual ~BitOperNode();
    554526    Value evaluate(ExecState *exec);
    555527    virtual void streamTo(SourceStream &s) const;
     
    568540    virtual void ref();
    569541    virtual bool deref();
    570     virtual ~BinaryLogicalNode();
    571542    Value evaluate(ExecState *exec);
    572543    virtual void streamTo(SourceStream &s) const;
     
    585556    virtual void ref();
    586557    virtual bool deref();
    587     virtual ~ConditionalNode();
    588558    Value evaluate(ExecState *exec);
    589559    virtual void streamTo(SourceStream &s) const;
     
    597567    virtual void ref();
    598568    virtual bool deref();
    599     virtual ~AssignNode();
    600569    Value evaluate(ExecState *exec);
    601570    virtual void streamTo(SourceStream &s) const;
     
    611580    virtual void ref();
    612581    virtual bool deref();
    613     virtual ~CommaNode();
    614582    Value evaluate(ExecState *exec);
    615583    virtual void streamTo(SourceStream &s) const;
     
    624592    virtual void ref();
    625593    virtual bool deref();
    626     virtual ~StatListNode();
    627594    virtual Completion execute(ExecState *exec);
    628595    virtual void processVarDecls(ExecState *exec);
     
    638605    virtual void ref();
    639606    virtual bool deref();
    640     virtual ~AssignExprNode();
    641607    Value evaluate(ExecState *exec);
    642608    virtual void streamTo(SourceStream &s) const;
     
    650616    virtual void ref();
    651617    virtual bool deref();
    652     virtual ~VarDeclNode();
    653618    Value evaluate(ExecState *exec);
    654619    virtual void processVarDecls(ExecState *exec);
     
    665630    virtual void ref();
    666631    virtual bool deref();
    667     virtual ~VarDeclListNode();
    668632    Value evaluate(ExecState *exec);
    669633    virtual void processVarDecls(ExecState *exec);
     
    679643    virtual void ref();
    680644    virtual bool deref();
    681     virtual ~VarStatementNode();
    682645    virtual Completion execute(ExecState *exec);
    683646    virtual void processVarDecls(ExecState *exec);
     
    692655    virtual void ref();
    693656    virtual bool deref();
    694     virtual ~BlockNode();
    695657    virtual Completion execute(ExecState *exec);
    696658    virtual void processVarDecls(ExecState *exec);
     
    712674    virtual void ref();
    713675    virtual bool deref();
    714     virtual ~ExprStatementNode();
    715676    virtual Completion execute(ExecState *exec);
    716677    virtual void streamTo(SourceStream &s) const;
     
    725686    virtual void ref();
    726687    virtual bool deref();
    727     virtual ~IfNode();
    728688    virtual Completion execute(ExecState *exec);
    729689    virtual void processVarDecls(ExecState *exec);
     
    739699    virtual void ref();
    740700    virtual bool deref();
    741     virtual ~DoWhileNode();
    742701    virtual Completion execute(ExecState *exec);
    743702    virtual void processVarDecls(ExecState *exec);
     
    753712    virtual void ref();
    754713    virtual bool deref();
    755     virtual ~WhileNode();
    756714    virtual Completion execute(ExecState *exec);
    757715    virtual void processVarDecls(ExecState *exec);
     
    768726    virtual void ref();
    769727    virtual bool deref();
    770     virtual ~ForNode();
    771728    virtual Completion execute(ExecState *exec);
    772729    virtual void processVarDecls(ExecState *exec);
     
    783740    virtual void ref();
    784741    virtual bool deref();
    785     virtual ~ForInNode();
    786742    virtual Completion execute(ExecState *exec);
    787743    virtual void processVarDecls(ExecState *exec);
     
    820776    virtual void ref();
    821777    virtual bool deref();
    822     virtual ~ReturnNode();
    823778    virtual Completion execute(ExecState *exec);
    824779    virtual void streamTo(SourceStream &s) const;
     
    832787    virtual void ref();
    833788    virtual bool deref();
    834     virtual ~WithNode();
    835789    virtual Completion execute(ExecState *exec);
    836790    virtual void processVarDecls(ExecState *exec);
     
    846800    virtual void ref();
    847801    virtual bool deref();
    848     virtual ~CaseClauseNode();
    849802    Value evaluate(ExecState *exec);
    850803    Completion evalStatements(ExecState *exec);
     
    861814    virtual void ref();
    862815    virtual bool deref();
    863     virtual ~ClauseListNode();
    864816    ClauseListNode* append(CaseClauseNode *c);
    865817    Value evaluate(ExecState *exec);
     
    879831    virtual void ref();
    880832    virtual bool deref();
    881     virtual ~CaseBlockNode();
    882833    Value evaluate(ExecState *exec);
    883834    Completion evalBlock(ExecState *exec, const Value& input);
     
    895846    virtual void ref();
    896847    virtual bool deref();
    897     virtual ~SwitchNode();
    898848    virtual Completion execute(ExecState *exec);
    899849    virtual void processVarDecls(ExecState *exec);
     
    909859    virtual void ref();
    910860    virtual bool deref();
    911     virtual ~LabelNode();
    912861    virtual Completion execute(ExecState *exec);
    913862    virtual void processVarDecls(ExecState *exec);
     
    923872    virtual void ref();
    924873    virtual bool deref();
    925     virtual ~ThrowNode();
    926874    virtual Completion execute(ExecState *exec);
    927875    virtual void streamTo(SourceStream &s) const;
     
    935883    virtual void ref();
    936884    virtual bool deref();
    937     virtual ~CatchNode();
    938885    virtual Completion execute(ExecState *exec);
    939886    Completion execute(ExecState *exec, const Value &arg);
     
    950897    virtual void ref();
    951898    virtual bool deref();
    952     virtual ~FinallyNode();
    953899    virtual Completion execute(ExecState *exec);
    954900    virtual void processVarDecls(ExecState *exec);
     
    964910    virtual void ref();
    965911    virtual bool deref();
    966     virtual ~TryNode();
    967912    virtual Completion execute(ExecState *exec);
    968913    virtual void processVarDecls(ExecState *exec);
     
    980925    virtual void ref();
    981926    virtual bool deref();
    982     virtual ~ParameterNode();
    983927    Value evaluate(ExecState *exec);
    984928    UString ident() { return id; }
     
    996940    virtual void ref();
    997941    virtual bool deref();
    998     virtual ~FunctionBodyNode();
    999942    Completion execute(ExecState *exec);
    1000943    virtual void processFuncDecl(ExecState *exec);
     
    1011954    virtual void ref();
    1012955    virtual bool deref();
    1013     virtual ~FuncDeclNode();
    1014956    Completion execute(ExecState */*exec*/)
    1015957      { /* empty */ return Completion(); }
     
    1028970    virtual void ref();
    1029971    virtual bool deref();
    1030     virtual ~FuncExprNode();
    1031972    Value evaluate(ExecState *exec);
    1032973    virtual void streamTo(SourceStream &s) const;
     
    1042983    virtual void ref();
    1043984    virtual bool deref();
    1044     virtual ~SourceElementNode();
    1045985    Completion execute(ExecState *exec);
    1046986    virtual void processFuncDecl(ExecState *exec);
     
    10601000    virtual void ref();
    10611001    virtual bool deref();
    1062     virtual ~SourceElementsNode();
    10631002    Completion execute(ExecState *exec);
    10641003    virtual void processFuncDecl(ExecState *exec);
     
    10731012  public:
    10741013    ProgramNode(SourceElementsNode *s);
    1075     ~ProgramNode();
    1076   private:
    1077     // Disallow copy
    1078     ProgramNode(const ProgramNode &other);
    10791014  };
    10801015
  • trunk/JavaScriptCore/kjs/nodes2string.cpp

    r830 r1799  
    3535    UString toString() const { return str; }
    3636    SourceStream& operator<<(const KJS::UString &);
     37    SourceStream& operator<<(char);
    3738    SourceStream& operator<<(Format f);
    3839    SourceStream& operator<<(const Node *);
     
    4445
    4546using namespace KJS;
     47
     48SourceStream& SourceStream::operator<<(char c)
     49{
     50  str += UString(c);
     51  return *this;
     52}
    4653
    4754SourceStream& SourceStream::operator<<(const KJS::UString &s)
  • trunk/JavaScriptCore/kjs/number_object.cpp

    r1024 r1799  
    5555  // The constructor will be added later, after NumberObjectImp has been constructed
    5656
    57   put(exec,"toString",       Object(new NumberProtoFuncImp(exec,funcProto,NumberProtoFuncImp::ToString,       1)), DontEnum);
     57  put(exec,toStringPropertyName,       Object(new NumberProtoFuncImp(exec,funcProto,NumberProtoFuncImp::ToString,       1)), DontEnum);
    5858  put(exec,"toLocaleString", Object(new NumberProtoFuncImp(exec,funcProto,NumberProtoFuncImp::ToLocaleString, 0)), DontEnum);
    59   put(exec,"valueOf",        Object(new NumberProtoFuncImp(exec,funcProto,NumberProtoFuncImp::ValueOf,        0)), DontEnum);
     59  put(exec,valueOfPropertyName,        Object(new NumberProtoFuncImp(exec,funcProto,NumberProtoFuncImp::ValueOf,        0)), DontEnum);
    6060}
    6161
     
    6868{
    6969  Value protect(this);
    70   put(exec,"length",Number(len),DontDelete|ReadOnly|DontEnum);
     70  put(exec,lengthPropertyName,Number(len),DontDelete|ReadOnly|DontEnum);
    7171}
    7272
     
    125125  Value protect(this);
    126126  // Number.Prototype
    127   put(exec,"prototype", Value(numberProto),DontEnum|DontDelete|ReadOnly);
     127  put(exec,prototypePropertyName, Value(numberProto),DontEnum|DontDelete|ReadOnly);
    128128
    129129  // no. of arguments for constructor
    130   put(exec,"length", Number(1), ReadOnly|DontDelete|DontEnum);
     130  put(exec,lengthPropertyName, Number(1), ReadOnly|DontDelete|DontEnum);
    131131}
    132132
  • trunk/JavaScriptCore/kjs/object.cpp

    r1326 r1799  
    3939#include "property_map.h"
    4040
    41 using namespace KJS;
     41namespace KJS {
     42
     43extern const UString lengthPropertyName("length");
     44extern const UString prototypePropertyName("prototype");
     45extern const UString toStringPropertyName("toString");
     46extern const UString valueOfPropertyName("valueOf");
    4247
    4348// ------------------------------ Object ---------------------------------------
    44 
    45 Object::Object() : Value()
    46 {
    47 }
    48 
    49 Object::Object(ObjectImp *v) : Value(v)
    50 {
    51 }
    52 
    53 Object::Object(const Object &v) : Value(v)
    54 {
    55 }
    56 
    57 Object::~Object()
    58 {
    59 }
    60 
    61 Object& Object::operator=(const Object &v)
    62 {
    63   Value::operator=(v);
    64   return *this;
    65 }
    66 
    67 const ClassInfo *Object::classInfo() const
    68 {
    69   return static_cast<ObjectImp*>(rep)->classInfo();
    70 }
    71 
    72 bool Object::inherits(const ClassInfo *cinfo) const
    73 {
    74   return static_cast<ObjectImp*>(rep)->inherits(cinfo);
    75 }
    7649
    7750Object Object::dynamicCast(const Value &v)
     
    8154
    8255  return Object(static_cast<ObjectImp*>(v.imp()));
    83 }
    84 
    85 Value Object::prototype() const
    86 {
    87   return Value(static_cast<ObjectImp*>(rep)->prototype());
    88 }
    89 
    90 UString Object::className() const
    91 {
    92   return static_cast<ObjectImp*>(rep)->className();
    93 }
    94 
    95 Value Object::get(ExecState *exec, const UString &propertyName) const
    96 {
    97   return static_cast<ObjectImp*>(rep)->get(exec,propertyName);
    98 }
    99 
    100 void Object::put(ExecState *exec, const UString &propertyName, const Value &value, int attr)
    101 {
    102   static_cast<ObjectImp*>(rep)->put(exec,propertyName,value,attr);
    103 }
    104 
    105 bool Object::canPut(ExecState *exec, const UString &propertyName) const
    106 {
    107   return static_cast<ObjectImp*>(rep)->canPut(exec,propertyName);
    108 }
    109 
    110 bool Object::hasProperty(ExecState *exec, const UString &propertyName) const
    111 {
    112   return static_cast<ObjectImp*>(rep)->hasProperty(exec, propertyName);
    113 }
    114 
    115 bool Object::deleteProperty(ExecState *exec, const UString &propertyName)
    116 {
    117   return static_cast<ObjectImp*>(rep)->deleteProperty(exec,propertyName);
    118 }
    119 
    120 Value Object::defaultValue(ExecState *exec, Type hint) const
    121 {
    122   return static_cast<ObjectImp*>(rep)->defaultValue(exec,hint);
    123 }
    124 
    125 bool Object::implementsConstruct() const
    126 {
    127   return static_cast<ObjectImp*>(rep)->implementsConstruct();
    128 }
    129 
    130 Object Object::construct(ExecState *exec, const List &args)
    131 {
    132   return static_cast<ObjectImp*>(rep)->construct(exec,args);
    133 }
    134 
    135 bool Object::implementsCall() const
    136 {
    137   return static_cast<ObjectImp*>(rep)->implementsCall();
    138 }
    139 
    140 Value Object::call(ExecState *exec, Object &thisObj, const List &args)
    141 {
    142   return static_cast<ObjectImp*>(rep)->call(exec,thisObj,args);
    143 }
    144 
    145 bool Object::implementsHasInstance() const
    146 {
    147   return static_cast<ObjectImp*>(rep)->implementsHasInstance();
    148 }
    149 
    150 Boolean Object::hasInstance(ExecState *exec, const Value &value)
    151 {
    152   return static_cast<ObjectImp*>(rep)->hasInstance(exec,value);
    153 }
    154 
    155 const List Object::scope() const
    156 {
    157   return static_cast<ObjectImp*>(rep)->scope();
    158 }
    159 
    160 void Object::setScope(const List &s)
    161 {
    162   static_cast<ObjectImp*>(rep)->setScope(s);
    163 }
    164 
    165 List Object::propList(ExecState *exec, bool recursive)
    166 {
    167   return static_cast<ObjectImp*>(rep)->propList(exec,recursive);
    168 }
    169 
    170 Value Object::internalValue() const
    171 {
    172   return static_cast<ObjectImp*>(rep)->internalValue();
    173 }
    174 
    175 void Object::setInternalValue(const Value &v)
    176 {
    177   static_cast<ObjectImp*>(rep)->setInternalValue(v);
    17856}
    17957
     
    294172
    295173  return proto.get(exec,propertyName);
     174}
     175
     176Value ObjectImp::get(ExecState *exec, unsigned propertyName) const
     177{
     178  return get(exec, UString::from(propertyName));
    296179}
    297180
     
    335218}
    336219
     220void ObjectImp::put(ExecState *exec, unsigned propertyName,
     221                     const Value &value, int attr)
     222{
     223  put(exec, UString::from(propertyName), value, attr);
     224}
     225
    337226// ECMA 8.6.2.3
    338227bool ObjectImp::canPut(ExecState *, const UString &propertyName) const
     
    367256  Object proto = Object::dynamicCast(prototype());
    368257  return !proto.isNull() && proto.hasProperty(exec,propertyName);
     258}
     259
     260bool ObjectImp::hasProperty(ExecState *exec, unsigned propertyName) const
     261{
     262  return hasProperty(exec, UString::from(propertyName));
    369263}
    370264
     
    387281}
    388282
     283bool ObjectImp::deleteProperty(ExecState *exec, unsigned propertyName)
     284{
     285  return deleteProperty(exec, UString::from(propertyName));
     286}
     287
    389288void ObjectImp::deleteAllProperties( ExecState * )
    390289{
     
    405304  Value v;
    406305  if (hint == StringType)
    407     v = get(exec,"toString");
     306    v = get(exec,toStringPropertyName);
    408307  else
    409     v = get(exec,"valueOf");
     308    v = get(exec,valueOfPropertyName);
    410309
    411310  if (v.type() == ObjectType) {
     
    424323
    425324  if (hint == StringType)
    426     v = get(exec,"valueOf");
     325    v = get(exec,valueOfPropertyName);
    427326  else
    428     v = get(exec,"toString");
     327    v = get(exec,toStringPropertyName);
    429328
    430329  if (v.type() == ObjectType) {
     
    546445}
    547446
    548 // The following functions simply call the corresponding functions in ValueImp
    549 // but are overridden in case of future needs
    550 
    551447Value ObjectImp::toPrimitive(ExecState *exec, Type preferredType) const
    552448{
     
    565461    return 0.0;
    566462  return prim.toNumber(exec);
    567 }
    568 
    569 int ObjectImp::toInteger(ExecState *exec) const
    570 {
    571   return ValueImp::toInteger(exec);
    572 }
    573 
    574 int ObjectImp::toInt32(ExecState *exec) const
    575 {
    576   return ValueImp::toInt32(exec);
    577 }
    578 
    579 unsigned int ObjectImp::toUInt32(ExecState *exec) const
    580 {
    581   return ValueImp::toUInt32(exec);
    582 }
    583 
    584 unsigned short ObjectImp::toUInt16(ExecState *exec) const
    585 {
    586   return ValueImp::toUInt16(exec);
    587463}
    588464
     
    670546}
    671547
     548} // namespace KJS
  • trunk/JavaScriptCore/kjs/object.h

    r1623 r1799  
    8080  class Object : public Value {
    8181  public:
    82     Object();
     82    Object() { }
    8383    explicit Object(ObjectImp *v);
    84     Object(const Object &v);
    85     virtual ~Object();
    86 
    87     Object& operator=(const Object &v);
    88 
    89     virtual const ClassInfo *classInfo() const;
     84   
     85    ObjectImp *imp() const;
     86
     87    const ClassInfo *classInfo() const;
    9088    bool inherits(const ClassInfo *cinfo) const;
    9189
     
    133131     */
    134132    Value get(ExecState *exec, const UString &propertyName) const;
     133    Value get(ExecState *exec, unsigned propertyName) const;
    135134
    136135    /**
     
    145144    void put(ExecState *exec, const UString &propertyName,
    146145             const Value &value, int attr = None);
     146    void put(ExecState *exec, unsigned propertyName,
     147             const Value &value, int attr = None);
    147148
    148149    /**
     
    169170     */
    170171    bool hasProperty(ExecState *exec, const UString &propertyName) const;
     172    bool hasProperty(ExecState *exec, unsigned propertyName) const;
    171173
    172174    /**
     
    182184     */
    183185    bool deleteProperty(ExecState *exec, const UString &propertyName);
     186    bool deleteProperty(ExecState *exec, unsigned propertyName);
    184187
    185188    /**
     
    350353  };
    351354
     355  inline Object Value::toObject(ExecState *exec) const { return rep->toObject(exec); }
     356 
    352357  class ObjectImp : public ValueImp {
    353358  public:
     
    467472    // [[Get]] - must be implemented by all Objects
    468473    virtual Value get(ExecState *exec, const UString &propertyName) const;
     474    virtual Value get(ExecState *exec, unsigned propertyName) const;
    469475
    470476    /**
     
    476482    virtual void put(ExecState *exec, const UString &propertyName,
    477483                     const Value &value, int attr = None);
     484    virtual void put(ExecState *exec, unsigned propertyName,
     485                     const Value &value, int attr = None);
    478486
    479487    /**
     
    493501    virtual bool hasProperty(ExecState *exec,
    494502                             const UString &propertyName) const;
     503    virtual bool hasProperty(ExecState *exec, unsigned propertyName) const;
    495504
    496505    /**
     
    502511    virtual bool deleteProperty(ExecState *exec,
    503512                                const UString &propertyName);
     513    virtual bool deleteProperty(ExecState *exec, unsigned propertyName);
    504514
    505515    /**
     
    560570    bool toBoolean(ExecState *exec) const;
    561571    double toNumber(ExecState *exec) const;
    562     int toInteger(ExecState *exec) const;
    563     int toInt32(ExecState *exec) const;
    564     unsigned int toUInt32(ExecState *exec) const;
    565     unsigned short toUInt16(ExecState *exec) const;
    566572    UString toString(ExecState *exec) const;
    567573    Object toObject(ExecState *exec) const;
     
    613619  };
    614620
     621  inline Object::Object(ObjectImp *v) : Value(v) { }
     622
     623  inline ObjectImp *Object::imp() const { return static_cast<ObjectImp*>(rep); }
     624
     625  inline const ClassInfo *Object::classInfo() const
     626    { return imp()->classInfo(); }
     627
     628  inline bool Object::inherits(const ClassInfo *cinfo) const
     629    { return imp()->inherits(cinfo); }
     630
     631  inline Value Object::prototype() const
     632    { return Value(imp()->prototype()); }
     633
     634  inline UString Object::className() const
     635    { return imp()->className(); }
     636
     637  inline Value Object::get(ExecState *exec, const UString &propertyName) const
     638    { return imp()->get(exec,propertyName); }
     639
     640  inline Value Object::get(ExecState *exec, unsigned propertyName) const
     641    { return imp()->get(exec,propertyName); }
     642
     643  inline void Object::put(ExecState *exec, const UString &propertyName, const Value &value, int attr)
     644    { imp()->put(exec,propertyName,value,attr); }
     645
     646  inline void Object::put(ExecState *exec, unsigned propertyName, const Value &value, int attr)
     647    { imp()->put(exec,propertyName,value,attr); }
     648
     649  inline bool Object::canPut(ExecState *exec, const UString &propertyName) const
     650    { return imp()->canPut(exec,propertyName); }
     651
     652  inline bool Object::hasProperty(ExecState *exec, const UString &propertyName) const
     653    { return imp()->hasProperty(exec, propertyName); }
     654
     655  inline bool Object::hasProperty(ExecState *exec, unsigned propertyName) const
     656    { return imp()->hasProperty(exec, propertyName); }
     657
     658  inline bool Object::deleteProperty(ExecState *exec, const UString &propertyName)
     659    { return imp()->deleteProperty(exec,propertyName); }
     660
     661  inline bool Object::deleteProperty(ExecState *exec, unsigned propertyName)
     662    { return imp()->deleteProperty(exec,propertyName); }
     663
     664  inline Value Object::defaultValue(ExecState *exec, Type hint) const
     665    { return imp()->defaultValue(exec,hint); }
     666
     667  inline bool Object::implementsConstruct() const
     668    { return imp()->implementsConstruct(); }
     669
     670  inline Object Object::construct(ExecState *exec, const List &args)
     671    { return imp()->construct(exec,args); }
     672
     673  inline bool Object::implementsCall() const
     674    { return imp()->implementsCall(); }
     675
     676  inline Value Object::call(ExecState *exec, Object &thisObj, const List &args)
     677    { return imp()->call(exec,thisObj,args); }
     678
     679  inline bool Object::implementsHasInstance() const
     680    { return imp()->implementsHasInstance(); }
     681
     682  inline Boolean Object::hasInstance(ExecState *exec, const Value &value)
     683    { return imp()->hasInstance(exec,value); }
     684
     685  inline const List Object::scope() const
     686    { return imp()->scope(); }
     687
     688  inline void Object::setScope(const List &s)
     689    { imp()->setScope(s); }
     690
     691  inline List Object::propList(ExecState *exec, bool recursive)
     692    { return imp()->propList(exec,recursive); }
     693
     694  inline Value Object::internalValue() const
     695    { return imp()->internalValue(); }
     696
     697  inline void Object::setInternalValue(const Value &v)
     698    { imp()->setInternalValue(v); }
     699
     700  extern const UString lengthPropertyName;
     701  extern const UString prototypePropertyName;
     702  extern const UString toStringPropertyName;
     703  extern const UString valueOfPropertyName;
     704
    615705}; // namespace
    616706
  • trunk/JavaScriptCore/kjs/object_object.cpp

    r1024 r1799  
    3939{
    4040  Value protect(this);
    41   put(exec,"toString", Object(new ObjectProtoFuncImp(exec,funcProto,ObjectProtoFuncImp::ToString, 0)), DontEnum);
    42   put(exec,"valueOf",  Object(new ObjectProtoFuncImp(exec,funcProto,ObjectProtoFuncImp::ValueOf,  0)), DontEnum);
     41  put(exec,toStringPropertyName, Object(new ObjectProtoFuncImp(exec,funcProto,ObjectProtoFuncImp::ToString, 0)), DontEnum);
     42  put(exec,valueOfPropertyName,  Object(new ObjectProtoFuncImp(exec,funcProto,ObjectProtoFuncImp::ValueOf,  0)), DontEnum);
    4343}
    4444
     
    5252{
    5353  Value protect(this);
    54   put(exec,"length",Number(len),DontDelete|ReadOnly|DontEnum);
     54  put(exec,lengthPropertyName,Number(len),DontDelete|ReadOnly|DontEnum);
    5555}
    5656
     
    8080  Value protect(this);
    8181  // ECMA 15.2.3.1
    82   put(exec,"prototype", Object(objProto), DontEnum|DontDelete|ReadOnly);
     82  put(exec,prototypePropertyName, Object(objProto), DontEnum|DontDelete|ReadOnly);
    8383
    8484  // no. of arguments for constructor
    85   put(exec,"length", Number(1), ReadOnly|DontDelete|DontEnum);
     85  put(exec,lengthPropertyName, Number(1), ReadOnly|DontDelete|DontEnum);
    8686}
    8787
  • trunk/JavaScriptCore/kjs/regexp_object.cpp

    r1623 r1799  
    5050  put(exec, "exec",     Object(new RegExpProtoFuncImp(exec,funcProto,RegExpProtoFuncImp::Exec,     0)), DontEnum);
    5151  put(exec, "test",     Object(new RegExpProtoFuncImp(exec,funcProto,RegExpProtoFuncImp::Test,     0)), DontEnum);
    52   put(exec, "toString", Object(new RegExpProtoFuncImp(exec,funcProto,RegExpProtoFuncImp::ToString, 0)), DontEnum);
     52  put(exec, toStringPropertyName, Object(new RegExpProtoFuncImp(exec,funcProto,RegExpProtoFuncImp::ToString, 0)), DontEnum);
    5353}
    5454
     
    6060{
    6161  Value protect(this);
    62   put(exec,"length",Number(len),DontDelete|ReadOnly|DontEnum);
     62  put(exec,lengthPropertyName,Number(len),DontDelete|ReadOnly|DontEnum);
    6363}
    6464
     
    157157  Value protect(this);
    158158  // ECMA 15.10.5.1 RegExp.prototype
    159   put(exec,"prototype", Object(regProto), DontEnum|DontDelete|ReadOnly);
     159  put(exec,prototypePropertyName, Object(regProto), DontEnum|DontDelete|ReadOnly);
    160160
    161161  // no. of arguments for constructor
    162   put(exec,"length", Number(2), ReadOnly|DontDelete|DontEnum);
     162  put(exec,lengthPropertyName, Number(2), ReadOnly|DontDelete|DontEnum);
    163163}
    164164
  • trunk/JavaScriptCore/kjs/string_object.cpp

    r1623 r1799  
    9090  Value protect(this);
    9191  // The constructor will be added later, after StringObjectImp has been built
    92   put(exec,"length",Number(0),DontDelete|ReadOnly|DontEnum);
     92  put(exec,lengthPropertyName,Number(0),DontDelete|ReadOnly|DontEnum);
    9393
    9494}
     
    107107{
    108108  Value protect(this);
    109   put(exec,"length",Number(len),DontDelete|ReadOnly|DontEnum);
     109  put(exec,lengthPropertyName,Number(len),DontDelete|ReadOnly|DontEnum);
    110110}
    111111
     
    343343      if (u.isEmpty() && !reg.match(u, 0).isNull()) {
    344344        // empty string matched by regexp -> empty array
    345         res.put(exec,"length", Number(0));
     345        res.put(exec,lengthPropertyName, Number(0));
    346346        break;
    347347      }
     
    357357        pos = mpos + (mstr.isEmpty() ? 1 : mstr.size());
    358358        if (mpos != p0 || !mstr.isEmpty()) {
    359           res.put(exec,UString::from(i), String(u.substr(p0, mpos-p0)));
     359          res.put(exec,i, String(u.substr(p0, mpos-p0)));
    360360          p0 = mpos + mstr.size();
    361361          i++;
     
    367367        if (u.isEmpty()) {
    368368          // empty separator matches empty string -> empty array
    369           put(exec,"length", Number(0));
     369          put(exec,lengthPropertyName, Number(0));
    370370          break;
    371371        } else {
    372372          while (i != d && i < u.size()-1)
    373             res.put(exec,UString::from(i++), String(u.substr(p0++, 1)));
     373            res.put(exec, i++, String(u.substr(p0++, 1)));
    374374        }
    375375      } else {
    376376        while (i != d && (pos = u.find(u2, p0)) >= 0) {
    377           res.put(exec,UString::from(i), String(u.substr(p0, pos-p0)));
     377          res.put(exec, i, String(u.substr(p0, pos-p0)));
    378378          p0 = pos + u2.size();
    379379          i++;
     
    383383    // add remaining string, if any
    384384    if (i != d)
    385       res.put(exec,UString::from(i++), String(u.substr(p0)));
    386     res.put(exec,"length", Number(i));
     385      res.put(exec, i++, String(u.substr(p0)));
     386    res.put(exec,lengthPropertyName, Number(i));
    387387    }
    388388    break;
     
    498498  Value protect(this);
    499499  // ECMA 15.5.3.1 String.prototype
    500   put(exec,"prototype", Object(stringProto), DontEnum|DontDelete|ReadOnly);
    501 
    502   put(exec,"fromCharCode", Object(new StringObjectFuncImp(exec,funcProto)), DontEnum);
     500  put(exec,prototypePropertyName, Object(stringProto), DontEnum|DontDelete|ReadOnly);
     501
     502  static UString fromCharCode("fromCharCode");
     503  put(exec,fromCharCode, Object(new StringObjectFuncImp(exec,funcProto)), DontEnum);
    503504
    504505  // no. of arguments for constructor
    505   put(exec,"length", Number(1), ReadOnly|DontDelete|DontEnum);
     506  put(exec,lengthPropertyName, Number(1), ReadOnly|DontDelete|DontEnum);
    506507}
    507508
     
    525526
    526527  obj.setInternalValue(String(s));
    527   obj.put(exec, "length", Number(s.size()), ReadOnly|DontEnum|DontDelete);
     528  obj.put(exec, lengthPropertyName, Number(s.size()), ReadOnly|DontEnum|DontDelete);
    528529
    529530  return obj;
     
    553554{
    554555  Value protect(this);
    555   put(exec,"length",Number(1),DontDelete|ReadOnly|DontEnum);
     556  put(exec,lengthPropertyName,Number(1),DontDelete|ReadOnly|DontEnum);
    556557}
    557558
  • trunk/JavaScriptCore/kjs/types.cpp

    r1623 r1799  
    4646}
    4747
     48Reference::Reference(const Object& b, unsigned p)
     49  : Value(new ReferenceImp(b,p))
     50{
     51}
     52
    4853Reference::Reference(const Null& b, const UString& p)
    4954  : Value(new ReferenceImp(b,p))
     
    5156}
    5257
    53 Reference::Reference(ReferenceImp *v) : Value(v)
    54 {
    55 }
    56 
    57 Reference::Reference(const Reference &v) : Value(v)
    58 {
    59 }
    60 
    61 Reference::~Reference()
    62 {
    63 }
    64 
    65 Reference& Reference::operator=(const Reference &v)
    66 {
    67   Value::operator=(v);
    68   return *this;
     58Reference::Reference(const Null& b, unsigned p)
     59  : Value(new ReferenceImp(b,p))
     60{
    6961}
    7062
     
    8779ListIterator::ListIterator(const List &l)
    8880  : node(static_cast<ListImp*>(l.imp())->hook->next)
    89 {
    90 }
    91 
    92 ListIterator& ListIterator::operator=(const ListIterator &iterator)
    93 {
    94   node=iterator.node;
    95   return *this;
    96 }
    97 
    98 ListIterator::ListIterator(const ListIterator &i) : node(i.node)
    99 {
    100 }
    101 
    102 ListIterator::~ListIterator()
    10381{
    10482}
     
    160138}
    161139
    162 List::List(ListImp *v) : Value(v)
    163 {
    164   //fprintf(stderr,"List::List(imp) this=%p imp=%p refcount=%d\n",this,v,v?v->refcount:0);
    165 }
    166 
    167 List::List(const List &v) : Value(v)
    168 {
    169   //fprintf(stderr,"List::List(List) this=%p imp=%p refcount=%d\n",this,rep,rep?rep->refcount:0);
    170 }
    171 
    172 List::~List()
    173 {
    174   //fprintf(stderr,"List::~List() this=%p imp=%p refcount=%d\n",this,rep,rep->refcount-1);
    175 }
    176 
    177 List& List::operator=(const List &v)
    178 {
    179   //fprintf(stderr,"List::operator=() this=%p\n",this);
    180   Value::operator=(v);
    181   return *this;
    182 }
    183 
    184140List List::dynamicCast(const Value &v)
    185141{
     
    286242}
    287243
    288 Completion::Completion(CompletionImp *v) : Value(v)
    289 {
    290 }
    291 
    292 Completion::Completion(const Completion &v) : Value(v)
    293 {
    294 }
    295 
    296 Completion::~Completion()
    297 {
    298 }
    299 
    300 Completion& Completion::operator=(const Completion &v)
    301 {
    302   Value::operator=(v);
    303   return *this;
    304 }
    305 
    306244Completion Completion::dynamicCast(const Value &v)
    307245{
  • trunk/JavaScriptCore/kjs/types.h

    r1623 r1799  
    3434  public:
    3535    Reference(const Object& b, const UString& p);
     36    Reference(const Object& b, unsigned p);
    3637    Reference(const Null& b, const UString& p);
     38    Reference(const Null& b, unsigned p);
    3739    Reference(ReferenceImp *v);
    38     Reference(const Reference &v);
    39     virtual ~Reference();
    40 
    41     Reference& operator=(const Reference &v);
    4240
    4341    /**
     
    7270    ListIterator(const List &l);
    7371    /**
    74      * Assignment constructor.
    75      */
    76     ListIterator& operator=(const ListIterator &iterator);
    77     /**
    78      * Copy constructor.
    79      */
    80     ListIterator(const ListIterator &i);
    81     ~ListIterator();
    82     /**
    8372     * Dereference the iterator.
    8473     * @return A pointer to the element the iterator operates on.
     
    139128    List();
    140129    List(ListImp *v);
    141     List(const List &v);
    142     virtual ~List();
    143 
    144     List& operator=(const List &v);
    145130
    146131    /**
     
    255240               const UString &t = UString::null);
    256241    Completion(CompletionImp *v);
    257     Completion(const Completion &v);
    258     virtual ~Completion();
    259 
    260     Completion& operator=(const Completion &v);
    261242
    262243    /**
  • trunk/JavaScriptCore/kjs/ustring.cpp

    r1791 r1799  
    116116UChar UChar::null;
    117117UString::Rep UString::Rep::null = { 0, 0, 0, 1 };
     118UString::Rep UString::Rep::empty = { 0, 0, 0, 1 };
    118119UString UString::null;
    119120const int normalStatBufferSize = 4096;
     
    191192  }
    192193  int length = strlen(c);
     194  if (length == 0) {
     195    attach(&Rep::empty);
     196    return;
     197  }
    193198  UChar *d = new UChar[length];
    194199  for (int i = 0; i < length; i++)
     
    199204UString::UString(const UChar *c, int length)
    200205{
     206  if (length == 0) {
     207    attach(&Rep::empty);
     208    return;
     209  }
    201210  UChar *d = new UChar[length];
    202211  memcpy(d, c, length * sizeof(UChar));
     
    206215UString::UString(UChar *c, int length, bool copy)
    207216{
     217  if (length == 0) {
     218    attach(&Rep::empty);
     219    return;
     220  }
    208221  UChar *d;
    209222  if (copy) {
     
    224237  int aSize = a.size();
    225238  int bSize = b.size();
    226   UChar *d = new UChar[aSize + bSize];
     239  int length = aSize + bSize;
     240  if (length == 0) {
     241    attach(&Rep::empty);
     242    return;
     243  }
     244  UChar *d = new UChar[length];
    227245  memcpy(d, a.data(), aSize * sizeof(UChar));
    228246  memcpy(d + aSize, b.data(), bSize * sizeof(UChar));
    229   rep = Rep::create(d, aSize + bSize);
     247  rep = Rep::create(d, length);
    230248}
    231249
     
    467485int UString::find(const UString &f, int pos) const
    468486{
    469   if (isNull())
     487  if (size() < f.size())
    470488    return -1;
    471   long fsize = f.size() * sizeof(UChar);
    472489  if (pos < 0)
    473490    pos = 0;
    474491  const UChar *end = data() + size() - f.size();
     492  long fsize = f.size() * sizeof(UChar);
     493  const void *fdata = f.data();
    475494  for (const UChar *c = data() + pos; c <= end; c++)
    476     if (!memcmp((void*)c, (void*)f.data(), fsize))
     495    if (!memcmp(c, fdata, fsize))
    477496      return (c-data());
    478497
     
    480499}
    481500
     501int UString::find(UChar ch, int pos) const
     502{
     503  if (pos < 0)
     504    pos = 0;
     505  const UChar *end = data() + size();
     506  for (const UChar *c = data() + pos; c < end; c++)
     507    if (*c == ch)
     508      return (c-data());
     509
     510  return -1;
     511}
     512
    482513int UString::rfind(const UString &f, int pos) const
    483514{
    484   if (isNull())
     515  if (size() < f.size())
    485516    return -1;
    486517  if (pos + f.size() >= size())
    487518    pos = size() - f.size();
    488519  long fsize = f.size() * sizeof(UChar);
     520  const void *fdata = f.data();
    489521  for (const UChar *c = data() + pos; c >= data(); c--) {
    490     if (!memcmp((void*)c, (void*)f.data(), fsize))
     522    if (!memcmp(c, fdata, fsize))
    491523      return (c-data());
    492524  }
     
    495527}
    496528
     529int UString::rfind(UChar ch, int pos) const
     530{
     531  if (isEmpty())
     532    return -1;
     533  if (pos + 1 >= size())
     534    pos = size() - 1;
     535  for (const UChar *c = data() + pos; c >= data(); c--) {
     536    if (*c == ch)
     537      return (c-data());
     538  }
     539
     540  return -1;
     541}
     542
    497543UString UString::substr(int pos, int len) const
    498544{
    499   if (isNull())
    500     return UString();
    501545  if (pos < 0)
    502546    pos = 0;
     
    552596bool KJS::operator==(const UString& s1, const char *s2)
    553597{
    554   if (s2 == 0L && s1.isNull())
    555     return true;
    556 
    557   if (s1.size() != (int) strlen(s2))
     598  if (s2 == 0) {
     599    return s1.isEmpty();
     600  }
     601
     602  if (s1.size() != (int)strlen(s2))
    558603    return false;
    559604
    560605  const UChar *u = s1.data();
    561606  while (*s2) {
    562     if (u->uc != *s2 )
     607    if (u->uc != (unsigned char)*s2)
    563608      return false;
    564609    s2++;
     
    583628  }
    584629  if (l < lmin)
    585     return (c1->unicode() < c2->unicode());
     630    return (c1->uc < c2->uc);
    586631
    587632  return (l1 < l2);
  • trunk/JavaScriptCore/kjs/ustring.h

    r1791 r1799  
    216216      int rc;
    217217      static Rep null;
     218      static Rep empty;
    218219    };
    219220
     
    226227     * Constructs a string from the single character c.
    227228     */
    228     UString(char c);
     229    explicit UString(char c);
    229230    /**
    230231     * Constructs a string from a classical zero determined char string.
     
    316317     */
    317318    UString &operator=(const char *c);
    318     /**
    319      * Assignment operator.
    320      */
    321319    UString &operator=(const UString &);
    322320    /**
     
    376374     */
    377375    int find(const UString &f, int pos = 0) const;
     376    int find(UChar, int pos = 0) const;
    378377    /**
    379378     * @return Position of first occurence of f searching backwards from
     
    382381     */
    383382    int rfind(const UString &f, int pos) const;
     383    int rfind(UChar, int pos) const;
    384384    /**
    385385     * @return The sub string starting at position pos and length len.
  • trunk/JavaScriptCore/kjs/value.cpp

    r1789 r1799  
    8383}
    8484
     85bool ValueImp::toUInt32(unsigned&) const
     86{
     87  return false;
     88}
     89
    8590// ECMA 9.4
    8691int ValueImp::toInteger(ExecState *exec) const
    8792{
     93  unsigned i;
     94  if (toUInt32(i))
     95    return (int)i;
    8896  return int(roundValue(exec, Value(const_cast<ValueImp*>(this))));
    8997}
     
    9199int ValueImp::toInt32(ExecState *exec) const
    92100{
     101  unsigned i;
     102  if (toUInt32(i))
     103    return (int)i;
     104
    93105  double d = roundValue(exec, Value(const_cast<ValueImp*>(this)));
    94106  double d32 = fmod(d, D32);
     
    102114unsigned int ValueImp::toUInt32(ExecState *exec) const
    103115{
     116  unsigned i;
     117  if (toUInt32(i))
     118    return i;
     119
    104120  double d = roundValue(exec, Value(const_cast<ValueImp*>(this)));
    105121  double d32 = fmod(d, D32);
     
    110126unsigned short ValueImp::toUInt16(ExecState *exec) const
    111127{
     128  unsigned i;
     129  if (toUInt32(i))
     130    return (unsigned short)i;
     131
    112132  double d = roundValue(exec, Value(const_cast<ValueImp*>(this)));
    113133  double d16 = fmod(d, D16);
     
    119139Value ValueImp::getBase(ExecState *exec) const
    120140{
    121   if (type() != ReferenceType) {
    122     Object err = Error::create(exec, ReferenceError, I18N_NOOP("Invalid reference base"));
    123     exec->setException(err);
    124     return err;
    125   }
    126 
    127   return (static_cast<const ReferenceImp*>(this))->getBase();
     141  Object err = Error::create(exec, ReferenceError, I18N_NOOP("Invalid reference base"));
     142  exec->setException(err);
     143  return err;
    128144}
    129145
     
    131147UString ValueImp::getPropertyName(ExecState * /*exec*/) const
    132148{
    133   if (type() != ReferenceType)
    134     // the spec wants a runtime error here. But getValue() and putValue()
    135     // will catch this case on their own earlier. When returning a Null
    136     // string we should be on the safe side.
    137     return UString();
    138 
    139   return (static_cast<const ReferenceImp*>(this))->getPropertyName();
     149  // the spec wants a runtime error here. But getValue() and putValue()
     150  // will catch this case on their own earlier. When returning a Null
     151  // string we should be on the safe side.
     152  return UString();
    140153}
    141154
     
    143156Value ValueImp::getValue(ExecState *exec) const
    144157{
    145   if (type() != ReferenceType)
    146     return Value(const_cast<ValueImp*>(this));
    147 
    148   Value o = getBase(exec);
    149 
    150   if (o.isNull() || o.type() == NullType) {
    151     UString m = I18N_NOOP("Can't find variable: ") + getPropertyName(exec);
    152     Object err = Error::create(exec, ReferenceError, m.ascii());
    153     exec->setException(err);
    154     return err;
    155   }
    156 
    157   if (o.type() != ObjectType) {
    158     UString m = I18N_NOOP("Base is not an object");
    159     Object err = Error::create(exec, ReferenceError, m.ascii());
    160     exec->setException(err);
    161     return err;
    162   }
    163 
    164   return static_cast<ObjectImp*>(o.imp())->get(exec,getPropertyName(exec));
    165 }
    166 
    167 void ValueImp::putValue(ExecState *exec, const Value w)
    168 {
    169   if (type() != ReferenceType) {
    170     Object err = Error::create(exec,ReferenceError);
    171     exec->setException(err);
    172     return;
    173   }
    174 
    175 #ifdef KJS_VERBOSE
    176   printInfo(exec,(UString("setting property ")+getPropertyName(exec)).cstring().c_str(),w);
    177 #endif
    178   Value o = getBase(exec);
    179   if (o.type() == NullType)
    180     exec->interpreter()->globalObject().put(exec,getPropertyName(exec), w);
    181   else {
    182     static_cast<ObjectImp*>(o.imp())->put(exec,getPropertyName(exec), w);
    183   }
    184 
    185   return;
    186 }
    187 
    188 bool KJS::operator==(const Value &v1, const Value &v2)
    189 {
    190   return (v1.imp() == v2.imp());
    191 }
    192 
    193 bool KJS::operator!=(const Value &v1, const Value &v2)
    194 {
    195   return (v1.imp() != v2.imp());
    196 }
    197 
    198 
    199 
     158  return Value(const_cast<ValueImp*>(this));
     159}
     160
     161void ValueImp::putValue(ExecState *exec, const Value& w)
     162{
     163  Object err = Error::create(exec,ReferenceError);
     164  exec->setException(err);
     165}
     166
     167bool ValueImp::deleteValue(ExecState *exec)
     168{
     169  Object err = Error::create(exec,ReferenceError);
     170  exec->setException(err);
     171  return false;
     172}
    200173
    201174// ------------------------------ Value ----------------------------------------
    202 
    203 Value::Value()
    204 {
    205   rep = 0;
    206 }
    207175
    208176Value::Value(ValueImp *v)
     
    251219}
    252220
    253 bool Value::isNull() const
    254 {
    255   return (rep == 0);
    256 }
    257 
    258 ValueImp *Value::imp() const
    259 {
    260   return rep;
    261 }
    262 
    263 Type Value::type() const
    264 {
    265   return rep->type();
    266 }
    267 
    268 bool Value::isA(Type t) const
    269 {
    270   return (type() == t);
    271 }
    272 
    273 Value Value::toPrimitive(ExecState *exec, Type preferredType) const
    274 {
    275   return rep->toPrimitive(exec,preferredType);
    276 }
    277 
    278 bool Value::toBoolean(ExecState *exec) const
    279 {
    280   return rep->toBoolean(exec);
    281 }
    282 
    283 double Value::toNumber(ExecState *exec) const
    284 {
    285   return rep->toNumber(exec);
    286 }
    287 
    288 int Value::toInteger(ExecState *exec) const
    289 {
    290   return rep->toInteger(exec);
    291 }
    292 
    293 int Value::toInt32(ExecState *exec) const
    294 {
    295   return rep->toInt32(exec);
    296 }
    297 
    298 unsigned int Value::toUInt32(ExecState *exec) const
    299 {
    300   return rep->toUInt32(exec);
    301 }
    302 
    303 unsigned short Value::toUInt16(ExecState *exec) const
    304 {
    305   return rep->toUInt16(exec);
    306 }
    307 
    308 UString Value::toString(ExecState *exec) const
    309 {
    310   return rep->toString(exec);
    311 }
    312 
    313 Object Value::toObject(ExecState *exec) const
    314 {
    315   return rep->toObject(exec);
    316 }
    317 
    318 Value Value::getBase(ExecState *exec) const
    319 {
    320   return rep->getBase(exec);
    321 }
    322 
    323 UString Value::getPropertyName(ExecState *exec) const
    324 {
    325   return rep->getPropertyName(exec);
    326 }
    327 
    328 Value Value::getValue(ExecState *exec) const
    329 {
    330   return rep->getValue(exec);
    331 }
    332 
    333 void Value::putValue(ExecState *exec, const Value w)
    334 {
    335   rep->putValue(exec,w);
    336 }
    337 
    338221// ------------------------------ Undefined ------------------------------------
    339222
    340223Undefined::Undefined() : Value(UndefinedImp::staticUndefined)
    341224{
    342 }
    343 
    344 Undefined::~Undefined() {
    345 }
    346 
    347 Undefined::Undefined(UndefinedImp *v) : Value(v)
    348 {
    349 }
    350 
    351 Undefined::Undefined(const Undefined &v) : Value(v)
    352 {
    353 }
    354 
    355 Undefined& Undefined::operator=(const Undefined &v)
    356 {
    357   Value::operator=(v);
    358   return *this;
    359225}
    360226
     
    373239}
    374240
    375 Null::~Null() {
    376 }
    377 
    378 
    379 Null::Null(NullImp *v) : Value(v)
    380 {
    381 }
    382 
    383 Null::Null(const Null &v) : Value(v)
    384 {
    385 }
    386 
    387 Null& Null::operator=(const Null &v)
    388 {
    389   Value::operator=(v);
    390   return *this;
    391 }
    392 
    393241Null Null::dynamicCast(const Value &v)
    394242{
     
    406254}
    407255
    408 Boolean::~Boolean() { }
    409 
    410 
    411 
    412 Boolean::Boolean(BooleanImp *v) : Value(v)
    413 {
    414 }
    415 
    416 Boolean::Boolean(const Boolean &v) : Value(v)
    417 {
    418 }
    419 
    420 Boolean& Boolean::operator=(const Boolean &v)
    421 {
    422   Value::operator=(v);
    423   return *this;
    424 }
    425 
    426 
    427256bool Boolean::value() const
    428257{
     
    445274}
    446275
    447 String::~String() { }
    448 
    449 String::String(StringImp *v) : Value(v)
    450 {
    451 }
    452 
    453 String::String(const String &v) : Value(v)
    454 {
    455 }
    456 
    457 String& String::operator=(const String &v)
    458 {
    459   Value::operator=(v);
    460   return *this;
    461 }
    462 
    463276UString String::value() const
    464277{
     
    492305  : Value(new NumberImp(static_cast<double>(l))) { }
    493306
    494 Number::~Number() { }
    495 
    496 Number::Number(NumberImp *v) : Value(v)
    497 {
    498 }
    499 
    500 Number::Number(const Number &v) : Value(v)
    501 {
    502 }
    503 
    504 Number& Number::operator=(const Number &v)
    505 {
    506   Value::operator=(v);
    507   return *this;
    508 }
    509 
    510307Number Number::dynamicCast(const Value &v)
    511308{
     
    536333  return KJS::isInf(value());
    537334}
    538 
  • trunk/JavaScriptCore/kjs/value.h

    r1791 r1799  
    115115    // The conversion operations
    116116
    117     virtual Value toPrimitive(ExecState *exec,
    118                               Type preferredType = UnspecifiedType) const = 0;
     117    virtual Value toPrimitive(ExecState *exec, Type preferredType = UnspecifiedType) const = 0;
    119118    virtual bool toBoolean(ExecState *exec) const = 0;
    120119    virtual double toNumber(ExecState *exec) const = 0;
    121     virtual int toInteger(ExecState *exec) const;
    122     virtual int toInt32(ExecState *exec) const;
    123     virtual unsigned int toUInt32(ExecState *exec) const;
    124     virtual unsigned short toUInt16(ExecState *exec) const;
    125120    virtual UString toString(ExecState *exec) const = 0;
    126121    virtual Object toObject(ExecState *exec) const = 0;
     122
     123    virtual bool toUInt32(unsigned&) const;
     124   
     125    int toInteger(ExecState *exec) const;
     126    int toInt32(ExecState *exec) const;
     127    unsigned int toUInt32(ExecState *exec) const;
     128    unsigned short toUInt16(ExecState *exec) const;
    127129
    128130    // Reference operations
     
    131133    virtual UString getPropertyName(ExecState *exec) const;
    132134    virtual Value getValue(ExecState *exec) const;
    133     virtual void putValue(ExecState *exec, const Value w);
     135    virtual void putValue(ExecState *exec, const Value& w);
     136    virtual bool deleteValue(ExecState *exec);
    134137
    135138  private:
     
    143146    ValueImpPrivate *_vd;
    144147    unsigned int _flags;
     148   
     149    // Give a compile time error if we try to copy one of these.
     150    ValueImp(const ValueImp&);
     151    ValueImp& operator=(const ValueImp&);
    145152  };
    146153
     
    162169  class Value {
    163170  public:
    164     Value();
     171    Value() : rep(0) { }
    165172    explicit Value(ValueImp *v);
    166173    Value(const Value &v);
    167     virtual ~Value();
     174    ~Value();
    168175
    169176    Value& operator=(const Value &v);
    170     bool isNull() const;
    171     ValueImp *imp() const;
     177    bool isNull() const { return rep == 0; }
     178    ValueImp *imp() const { return rep; }
    172179
    173180    /**
     
    178185     * @return The type of value
    179186     */
    180     Type type() const;
     187    Type type() const { return rep->type(); }
    181188
    182189    /**
     
    186193     * @return true if the value is of the specified type, otherwise false
    187194     */
    188     bool isA(Type t) const;
     195    bool isA(Type t) const { return rep->type() == t; }
    189196
    190197    /**
     
    193200     */
    194201    Value toPrimitive(ExecState *exec,
    195                       Type preferredType = UnspecifiedType) const;
     202                      Type preferredType = UnspecifiedType) const
     203      { return rep->toPrimitive(exec, preferredType); }
    196204
    197205    /**
    198206     * Performs the ToBoolean type conversion operation on this value (ECMA 9.2)
    199207     */
    200     bool toBoolean(ExecState *exec) const;
     208    bool toBoolean(ExecState *exec) const { return rep->toBoolean(exec); }
    201209
    202210    /**
    203211     * Performs the ToNumber type conversion operation on this value (ECMA 9.3)
    204212     */
    205     double toNumber(ExecState *exec) const;
     213    double toNumber(ExecState *exec) const { return rep->toNumber(exec); }
    206214
    207215    /**
    208216     * Performs the ToInteger type conversion operation on this value (ECMA 9.4)
    209217     */
    210     int toInteger(ExecState *exec) const;
     218    int toInteger(ExecState *exec) const { return rep->toInteger(exec); }
    211219
    212220    /**
    213221     * Performs the ToInt32 type conversion operation on this value (ECMA 9.5)
    214222     */
    215     int toInt32(ExecState *exec) const;
     223    int toInt32(ExecState *exec) const { return rep->toInt32(exec); }
    216224
    217225    /**
    218226     * Performs the ToUint32 type conversion operation on this value (ECMA 9.6)
    219227     */
    220     unsigned int toUInt32(ExecState *exec) const;
     228    unsigned int toUInt32(ExecState *exec) const { return rep->toUInt32(exec); }
    221229
    222230    /**
    223231     * Performs the ToUint16 type conversion operation on this value (ECMA 9.7)
    224232     */
    225     unsigned short toUInt16(ExecState *exec) const;
     233    unsigned short toUInt16(ExecState *exec) const { return rep->toUInt16(exec); }
    226234
    227235    /**
    228236     * Performs the ToString type conversion operation on this value (ECMA 9.8)
    229237     */
    230     UString toString(ExecState *exec) const;
     238    UString toString(ExecState *exec) const { return rep->toString(exec); }
    231239
    232240    /**
     
    241249     * this method is guaranteed to return either Null() or an Object value.
    242250     */
    243     Value getBase(ExecState *exec) const;
     251    Value getBase(ExecState *exec) const { return rep->getBase(exec); }
    244252
    245253    /**
     
    247255     * (ECMA 8.7)
    248256     */
    249     UString getPropertyName(ExecState *exec) const;
     257    UString getPropertyName(ExecState *exec) const { return rep->getPropertyName(exec); }
    250258
    251259    /**
     
    253261     * (ECMA 8.7.1)
    254262     */
    255     Value getValue(ExecState *exec) const;
     263    Value getValue(ExecState *exec) const { return rep->getValue(exec); }
    256264
    257265    /**
     
    259267     * (ECMA 8.7.1)
    260268     */
    261     void putValue(ExecState *exec, const Value w);
     269    void putValue(ExecState *exec, const Value &w) { rep->putValue(exec, w); }
     270    bool deleteValue(ExecState *exec) { return rep->deleteValue(exec); }
     271
     272    /**
     273     * Checks if we can do a lossless conversion to UInt32.
     274     */
     275    bool toUInt32(unsigned& i) const { return rep->toUInt32(i); }
    262276
    263277  protected:
    264278    ValueImp *rep;
    265279  };
    266 
    267   bool operator==(const Value &v1, const Value &v2);
    268   bool operator!=(const Value &v1, const Value &v2);
    269280
    270281  // Primitive types
     
    278289  public:
    279290    Undefined();
    280     Undefined(const Undefined &v);
    281     virtual ~Undefined();
    282 
    283     Undefined& operator=(const Undefined &v);
    284291
    285292    /**
     
    307314  public:
    308315    Null();
    309     Null(const Null &v);
    310     virtual ~Null();
    311 
    312     Null& operator=(const Null &v);
    313316
    314317    /**
     
    333336  public:
    334337    Boolean(bool b = false);
    335     Boolean(const Boolean &v);
    336     virtual ~Boolean();
    337 
    338     Boolean& operator=(const Boolean &v);
    339338
    340339    /**
     
    361360  public:
    362361    String(const UString &s = "");
    363     String(const String &v);
    364     virtual ~String();
    365 
    366     String& operator=(const String &v);
    367362
    368363    /**
     
    396391    Number(long int l);
    397392    Number(long unsigned int l);
    398     Number(const Number &v);
    399     virtual ~Number();
    400 
    401     Number& operator=(const Number &v);
    402393
    403394    double value() const;
Note: See TracChangeset for help on using the changeset viewer.