Ignore:
Timestamp:
May 12, 2008, 12:12:31 AM (17 years ago)
Author:
[email protected]
Message:

Roll out recent threading changes (r32807, r32810, r32819, r32822) to simplify
SquirrelFish merging.

File:
1 edited

Legend:

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

    r32807 r33038  
    4141const ClassInfo StringInstance::info = { "String", 0, 0, 0 };
    4242
    43 StringInstance::StringInstance(ExecState* exec, JSObject* proto)
     43StringInstance::StringInstance(JSObject *proto)
    4444  : JSWrapperObject(proto)
    4545{
    46   setInternalValue(jsString(exec, ""));
     46  setInternalValue(jsString(""));
    4747}
    4848
     
    5353}
    5454
    55 StringInstance::StringInstance(ExecState* exec, JSObject* proto, const UString &string)
     55StringInstance::StringInstance(JSObject *proto, const UString &string)
    5656  : JSWrapperObject(proto)
    5757{
    58   setInternalValue(jsString(exec, string));
    59 }
    60 
    61 JSValue* StringInstance::lengthGetter(ExecState* exec, JSObject*, const Identifier&, const PropertySlot& slot)
    62 {
    63     return jsNumber(exec, static_cast<StringInstance*>(slot.slotBase())->internalValue()->value().size());
    64 }
    65 
    66 JSValue* StringInstance::indexGetter(ExecState* exec, JSObject*, const Identifier&, const PropertySlot& slot)
    67 {
    68     return jsString(exec, static_cast<StringInstance*>(slot.slotBase())->internalValue()->value().substr(slot.index(), 1));
    69 }
    70 
    71 static JSValue* stringInstanceNumericPropertyGetter(ExecState* exec, JSObject*, unsigned index, const PropertySlot& slot)
    72 {
    73     return jsString(exec, static_cast<StringInstance*>(slot.slotBase())->internalValue()->value().substr(index, 1));
     58  setInternalValue(jsString(string));
     59}
     60
     61JSValue *StringInstance::lengthGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot &slot)
     62{
     63    return jsNumber(static_cast<StringInstance*>(slot.slotBase())->internalValue()->value().size());
     64}
     65
     66JSValue* StringInstance::indexGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot& slot)
     67{
     68    return jsString(static_cast<StringInstance*>(slot.slotBase())->internalValue()->value().substr(slot.index(), 1));
     69}
     70
     71static JSValue* stringInstanceNumericPropertyGetter(ExecState*, JSObject*, unsigned index, const PropertySlot& slot)
     72{
     73    return jsString(static_cast<StringInstance*>(slot.slotBase())->internalValue()->value().substr(index, 1));
    7474}
    7575
     
    166166// ECMA 15.5.4
    167167StringPrototype::StringPrototype(ExecState* exec, ObjectPrototype* objProto)
    168   : StringInstance(exec, objProto)
     168  : StringInstance(objProto)
    169169{
    170170  // The constructor will be added later, after StringObjectImp has been built
    171   putDirect(exec->propertyNames().length, jsNumber(exec, 0), DontDelete | ReadOnly | DontEnum);
     171  putDirect(exec->propertyNames().length, jsNumber(0), DontDelete | ReadOnly | DontEnum);
    172172}
    173173
     
    345345                args.append(jsUndefined());
    346346              else
    347                 args.append(jsString(exec, source.substr(matchStart, matchLen)));
     347                args.append(jsString(source.substr(matchStart, matchLen)));
    348348          }
    349349         
    350           args.append(jsNumber(exec, completeMatchStart));
     350          args.append(jsNumber(completeMatchStart));
    351351          args.append(sourceVal);
    352352
     
    382382      return sourceVal;
    383383
    384     return jsString(exec, result);
     384    return jsString(result);
    385385  }
    386386 
     
    396396      List args;
    397397     
    398       args.append(jsString(exec, source.substr(matchPos, matchLen)));
    399       args.append(jsNumber(exec, matchPos));
     398      args.append(jsString(source.substr(matchPos, matchLen)));
     399      args.append(jsNumber(matchPos));
    400400      args.append(sourceVal);
    401401     
     
    403403  }
    404404
    405   return jsString(exec, source.substr(0, matchPos) + replacementString + source.substr(matchPos + matchLen));
     405  return jsString(source.substr(0, matchPos) + replacementString + source.substr(matchPos + matchLen));
    406406}
    407407
     
    435435    else
    436436      u = "";
    437     return jsString(exec, u);
     437    return jsString(u);
    438438}
    439439
     
    449449    double dpos = a0->toInteger(exec);
    450450    if (dpos >= 0 && dpos < len)
    451       result = jsNumber(exec, s[static_cast<int>(dpos)]);
     451      result = jsNumber(s[static_cast<int>(dpos)]);
    452452    else
    453       result = jsNaN(exec);
     453      result = jsNaN();
    454454    return result;
    455455}
     
    464464        s += (*it)->toString(exec);
    465465    }
    466     return jsString(exec, s);
     466    return jsString(s);
    467467}
    468468
     
    481481    else if (dpos > len)
    482482        dpos = len;
    483     return jsNumber(exec, s.find(u2, static_cast<int>(dpos)));
     483    return jsNumber(s.find(u2, static_cast<int>(dpos)));
    484484}
    485485
     
    499499    else if (!(dpos <= len)) // true for NaN
    500500        dpos = len;
    501     return jsNumber(exec, s.rfind(u2, static_cast<int>(dpos)));
     501    return jsNumber(s.rfind(u2, static_cast<int>(dpos)));
    502502}
    503503
     
    538538      int lastIndex = 0;
    539539      while (pos >= 0) {
    540         list.append(jsString(exec, u.substr(pos, matchLength)));
     540        list.append(jsString(u.substr(pos, matchLength)));
    541541        lastIndex = pos;
    542542        pos += matchLength == 0 ? 1 : matchLength;
     
    580580    int matchLength;
    581581    regExpObj->performMatch(reg.get(), u, 0, pos, matchLength);
    582     return jsNumber(exec, pos);
     582    return jsNumber(pos);
    583583}
    584584
     
    590590    StringImp* sVal = thisObj->inherits(&StringInstance::info) ?
    591591      static_cast<StringInstance*>(thisObj)->internalValue() :
    592       static_cast<StringImp*>(jsString(exec, s));
     592      static_cast<StringImp*>(jsString(s));
    593593
    594594    JSValue* a0 = args[0];
     
    617617        if (to > len)
    618618            to = len;
    619         return jsString(exec, s.substr(static_cast<int>(from), static_cast<int>(to - from)));
    620     }
    621 
    622     return jsString(exec, "");
     619        return jsString(s.substr(static_cast<int>(from), static_cast<int>(to - from)));
     620    }
     621
     622    return jsString("");
    623623}
    624624
     
    643643      if (u.isEmpty() && reg->match(u, 0) >= 0) {
    644644        // empty string matched by regexp -> empty array
    645         res->put(exec, exec->propertyNames().length, jsNumber(exec, 0));
     645        res->put(exec, exec->propertyNames().length, jsNumber(0));
    646646        return result;
    647647      }
     
    655655        pos = mpos + (mlen == 0 ? 1 : mlen);
    656656        if (mpos != p0 || mlen) {
    657           res->put(exec,i, jsString(exec, u.substr(p0, mpos-p0)));
     657          res->put(exec,i, jsString(u.substr(p0, mpos-p0)));
    658658          p0 = mpos + mlen;
    659659          i++;
     
    664664            res->put(exec, i++, jsUndefined());
    665665          else
    666             res->put(exec, i++, jsString(exec, u.substr(spos, ovector[si * 2 + 1] - spos)));
     666            res->put(exec, i++, jsString(u.substr(spos, ovector[si * 2 + 1] - spos)));
    667667        }
    668668      }
     
    672672        if (u.isEmpty()) {
    673673          // empty separator matches empty string -> empty array
    674           res->put(exec, exec->propertyNames().length, jsNumber(exec, 0));
     674          res->put(exec, exec->propertyNames().length, jsNumber(0));
    675675          return result;
    676676        } else {
    677677          while (static_cast<uint32_t>(i) != limit && i < u.size()-1)
    678             res->put(exec, i++, jsString(exec, u.substr(p0++, 1)));
     678            res->put(exec, i++, jsString(u.substr(p0++, 1)));
    679679        }
    680680      } else {
    681681        while (static_cast<uint32_t>(i) != limit && (pos = u.find(u2, p0)) >= 0) {
    682           res->put(exec, i, jsString(exec, u.substr(p0, pos - p0)));
     682          res->put(exec, i, jsString(u.substr(p0, pos-p0)));
    683683          p0 = pos + u2.size();
    684684          i++;
     
    688688    // add remaining string, if any
    689689    if (static_cast<uint32_t>(i) != limit)
    690       res->put(exec, i++, jsString(exec, u.substr(p0)));
    691     res->put(exec, exec->propertyNames().length, jsNumber(exec, i));
     690      res->put(exec, i++, jsString(u.substr(p0)));
     691    res->put(exec, exec->propertyNames().length, jsNumber(i));
    692692    return result;
    693693}
     
    705705    double length = a1->isUndefined() ? len : a1->toInteger(exec);
    706706    if (start >= len)
    707       return jsString(exec, "");
     707      return jsString("");
    708708    if (length < 0)
    709       return jsString(exec, "");
     709      return jsString("");
    710710    if (start < 0) {
    711711      start += len;
     
    715715    if (length > len)
    716716      length = len;
    717     return jsString(exec, s.substr(static_cast<int>(start), static_cast<int>(length)));
     717    return jsString(s.substr(static_cast<int>(start), static_cast<int>(length)));
    718718}
    719719
     
    748748      start = temp;
    749749    }
    750     return jsString(exec, s.substr((int)start, (int)end-(int)start));
     750    return jsString(s.substr((int)start, (int)end-(int)start));
    751751}
    752752
     
    758758    StringImp* sVal = thisObj->inherits(&StringInstance::info)
    759759        ? static_cast<StringInstance*>(thisObj)->internalValue()
    760         : static_cast<StringImp*>(jsString(exec, s));
     760        : static_cast<StringImp*>(jsString(s));
    761761    int ssize = s.size();
    762762    if (!ssize)
     
    773773    if (length == ssize && memcmp(buffer.data(), s.data(), length * sizeof(UChar)) == 0)
    774774        return sVal;
    775     return jsString(exec, UString(buffer.releaseBuffer(), length, false));
     775    return jsString(UString(buffer.releaseBuffer(), length, false));
    776776}
    777777
     
    783783    StringImp* sVal = thisObj->inherits(&StringInstance::info)
    784784        ? static_cast<StringInstance*>(thisObj)->internalValue()
    785         : static_cast<StringImp*>(jsString(exec, s));
     785        : static_cast<StringImp*>(jsString(s));
    786786    int ssize = s.size();
    787787    if (!ssize)
     
    798798    if (length == ssize && memcmp(buffer.data(), s.data(), length * sizeof(UChar)) == 0)
    799799        return sVal;
    800     return jsString(exec, UString(buffer.releaseBuffer(), length, false));
     800    return jsString(UString(buffer.releaseBuffer(), length, false));
    801801}
    802802
     
    809809    StringImp* sVal = thisObj->inherits(&StringInstance::info)
    810810        ? static_cast<StringInstance*>(thisObj)->internalValue()
    811         : static_cast<StringImp*>(jsString(exec, s));
     811        : static_cast<StringImp*>(jsString(s));
    812812    int ssize = s.size();
    813813    if (!ssize)
     
    824824    if (length == ssize && memcmp(buffer.data(), s.data(), length * sizeof(UChar)) == 0)
    825825        return sVal;
    826     return jsString(exec, UString(buffer.releaseBuffer(), length, false));
     826    return jsString(UString(buffer.releaseBuffer(), length, false));
    827827}
    828828
     
    834834    StringImp* sVal = thisObj->inherits(&StringInstance::info)
    835835        ? static_cast<StringInstance*>(thisObj)->internalValue()
    836         : static_cast<StringImp*>(jsString(exec, s));
     836        : static_cast<StringImp*>(jsString(s));
    837837    int ssize = s.size();
    838838    if (!ssize)
     
    849849    if (length == ssize && memcmp(buffer.data(), s.data(), length * sizeof(UChar)) == 0)
    850850        return sVal;
    851     return jsString(exec, UString(buffer.releaseBuffer(), length, false));
     851    return jsString(UString(buffer.releaseBuffer(), length, false));
    852852}
    853853
     
    855855{
    856856    if (args.size() < 1)
    857       return jsNumber(exec, 0);
    858 
    859     // This optimizes the common case that thisObj is a StringInstance
    860     UString s = thisObj->inherits(&StringInstance::info) ? static_cast<StringInstance*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
    861     JSValue* a0 = args[0];
    862     return jsNumber(exec, localeCompare(s, a0->toString(exec)));
     857      return jsNumber(0);
     858
     859    // This optimizes the common case that thisObj is a StringInstance
     860    UString s = thisObj->inherits(&StringInstance::info) ? static_cast<StringInstance*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
     861    JSValue* a0 = args[0];
     862    return jsNumber(localeCompare(s, a0->toString(exec)));
    863863}
    864864
     
    867867    // This optimizes the common case that thisObj is a StringInstance
    868868    UString s = thisObj->inherits(&StringInstance::info) ? static_cast<StringInstance*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
    869     return jsString(exec, "<big>" + s + "</big>");
     869    return jsString("<big>" + s + "</big>");
    870870}
    871871
     
    874874    // This optimizes the common case that thisObj is a StringInstance
    875875    UString s = thisObj->inherits(&StringInstance::info) ? static_cast<StringInstance*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
    876     return jsString(exec, "<small>" + s + "</small>");
     876    return jsString("<small>" + s + "</small>");
    877877}
    878878
     
    881881    // This optimizes the common case that thisObj is a StringInstance
    882882    UString s = thisObj->inherits(&StringInstance::info) ? static_cast<StringInstance*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
    883     return jsString(exec, "<blink>" + s + "</blink>");
     883    return jsString("<blink>" + s + "</blink>");
    884884}
    885885
     
    888888    // This optimizes the common case that thisObj is a StringInstance
    889889    UString s = thisObj->inherits(&StringInstance::info) ? static_cast<StringInstance*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
    890     return jsString(exec, "<b>" + s + "</b>");
     890    return jsString("<b>" + s + "</b>");
    891891}
    892892
     
    895895    // This optimizes the common case that thisObj is a StringInstance
    896896    UString s = thisObj->inherits(&StringInstance::info) ? static_cast<StringInstance*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
    897     return jsString(exec, "<tt>" + s + "</tt>");
     897    return jsString("<tt>" + s + "</tt>");
    898898}
    899899
     
    902902    // This optimizes the common case that thisObj is a StringInstance
    903903    UString s = thisObj->inherits(&StringInstance::info) ? static_cast<StringInstance*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
    904     return jsString(exec, "<i>" + s + "</i>");
     904    return jsString("<i>" + s + "</i>");
    905905}
    906906
     
    909909    // This optimizes the common case that thisObj is a StringInstance
    910910    UString s = thisObj->inherits(&StringInstance::info) ? static_cast<StringInstance*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
    911     return jsString(exec, "<strike>" + s + "</strike>");
     911    return jsString("<strike>" + s + "</strike>");
    912912}
    913913
     
    916916    // This optimizes the common case that thisObj is a StringInstance
    917917    UString s = thisObj->inherits(&StringInstance::info) ? static_cast<StringInstance*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
    918     return jsString(exec, "<sub>" + s + "</sub>");
     918    return jsString("<sub>" + s + "</sub>");
    919919}
    920920
     
    923923    // This optimizes the common case that thisObj is a StringInstance
    924924    UString s = thisObj->inherits(&StringInstance::info) ? static_cast<StringInstance*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
    925     return jsString(exec, "<sup>" + s + "</sup>");
     925    return jsString("<sup>" + s + "</sup>");
    926926}
    927927
     
    931931    UString s = thisObj->inherits(&StringInstance::info) ? static_cast<StringInstance*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
    932932    JSValue* a0 = args[0];
    933     return jsString(exec, "<font color=\"" + a0->toString(exec) + "\">" + s + "</font>");
     933    return jsString("<font color=\"" + a0->toString(exec) + "\">" + s + "</font>");
    934934}
    935935
     
    939939    UString s = thisObj->inherits(&StringInstance::info) ? static_cast<StringInstance*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
    940940    JSValue* a0 = args[0];
    941     return jsString(exec, "<font size=\"" + a0->toString(exec) + "\">" + s + "</font>");
     941    return jsString("<font size=\"" + a0->toString(exec) + "\">" + s + "</font>");
    942942}
    943943
     
    947947    UString s = thisObj->inherits(&StringInstance::info) ? static_cast<StringInstance*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
    948948    JSValue* a0 = args[0];
    949     return jsString(exec, "<a name=\"" + a0->toString(exec) + "\">" + s + "</a>");
     949    return jsString("<a name=\"" + a0->toString(exec) + "\">" + s + "</a>");
    950950}
    951951
     
    955955    UString s = thisObj->inherits(&StringInstance::info) ? static_cast<StringInstance*>(thisObj)->internalValue()->value() : thisObj->toString(exec);
    956956    JSValue* a0 = args[0];
    957     return jsString(exec, "<a href=\"" + a0->toString(exec) + "\">" + s + "</a>");
     957    return jsString("<a href=\"" + a0->toString(exec) + "\">" + s + "</a>");
    958958}
    959959
     
    966966  putDirect(exec->propertyNames().prototype, stringProto, DontEnum|DontDelete|ReadOnly);
    967967
    968   putDirectFunction(new (exec) StringObjectFuncImp(exec, funcProto, exec->propertyNames().fromCharCode), DontEnum);
     968  putDirectFunction(new StringObjectFuncImp(exec, funcProto, exec->propertyNames().fromCharCode), DontEnum);
    969969
    970970  // no. of arguments for constructor
    971   putDirect(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly|DontDelete|DontEnum);
     971  putDirect(exec->propertyNames().length, jsNumber(1), ReadOnly|DontDelete|DontEnum);
    972972}
    973973
     
    983983  JSObject *proto = exec->lexicalGlobalObject()->stringPrototype();
    984984  if (args.size() == 0)
    985     return new (exec) StringInstance(exec, proto);
    986   return new (exec) StringInstance(exec, proto, args[0]->toString(exec));
     985    return new StringInstance(proto);
     986  return new StringInstance(proto, args[0]->toString(exec));
    987987}
    988988
     
    991991{
    992992  if (args.isEmpty())
    993     return jsString(exec, "");
     993    return jsString("");
    994994  else {
    995995    JSValue *v = args[0];
    996     return jsString(exec, v->toString(exec));
     996    return jsString(v->toString(exec));
    997997  }
    998998}
     
    10041004  : InternalFunctionImp(funcProto, name)
    10051005{
    1006   putDirect(exec->propertyNames().length, jsNumber(exec, 1), DontDelete|ReadOnly|DontEnum);
     1006  putDirect(exec->propertyNames().length, jsNumber(1), DontDelete|ReadOnly|DontEnum);
    10071007}
    10081008
     
    10221022    s = "";
    10231023
    1024   return jsString(exec, s);
     1024  return jsString(s);
    10251025}
    10261026
Note: See TracChangeset for help on using the changeset viewer.