Changeset 34821 in webkit for trunk/JavaScriptCore/kjs/string_object.cpp
- Timestamp:
- Jun 26, 2008, 7:53:42 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/string_object.cpp
r34754 r34821 37 37 38 38 static JSValue* stringProtoFuncToString(ExecState*, JSObject*, JSValue*, const ArgList&); 39 static JSValue* stringProtoFuncValueOf(ExecState*, JSObject*, JSValue*, const ArgList&);40 39 static JSValue* stringProtoFuncCharAt(ExecState*, JSObject*, JSValue*, const ArgList&); 41 40 static JSValue* stringProtoFuncCharCodeAt(ExecState*, JSObject*, JSValue*, const ArgList&); … … 128 127 void StringObject::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames) 129 128 { 130 int size = internalValue()-> getString().size();129 int size = internalValue()->value().size(); 131 130 for (int i = 0; i < size; i++) 132 131 propertyNames.add(Identifier(exec, UString::from(i))); 133 132 return JSObject::getPropertyNames(exec, propertyNames); 133 } 134 135 UString StringObject::toString(ExecState*) const 136 { 137 return internalValue()->value(); 138 } 139 140 UString StringObject::toThisString(ExecState*) const 141 { 142 return internalValue()->value(); 143 } 144 145 JSString* StringObject::toThisJSString(ExecState*) 146 { 147 return internalValue(); 134 148 } 135 149 … … 139 153 @begin stringTable 26 140 154 toString stringProtoFuncToString DontEnum|Function 0 141 valueOf stringProtoFunc ValueOfDontEnum|Function 0155 valueOf stringProtoFuncToString DontEnum|Function 0 142 156 charAt stringProtoFuncCharAt DontEnum|Function 1 143 157 charCodeAt stringProtoFuncCharCodeAt DontEnum|Function 1 … … 188 202 // ------------------------------ Functions -------------------------- 189 203 190 static inline void expandSourceRanges(UString::Range * & array, int& count, int& capacity) 191 { 192 int newCapacity; 193 if (capacity == 0) { 194 newCapacity = 16; 195 } else { 196 newCapacity = capacity * 2; 197 } 198 199 UString::Range *newArray = new UString::Range[newCapacity]; 200 for (int i = 0; i < count; i++) { 201 newArray[i] = array[i]; 202 } 203 204 delete [] array; 205 206 capacity = newCapacity; 207 array = newArray; 208 } 209 210 static void pushSourceRange(UString::Range * & array, int& count, int& capacity, UString::Range range) 211 { 212 if (count + 1 > capacity) 213 expandSourceRanges(array, count, capacity); 214 215 array[count] = range; 216 count++; 217 } 218 219 static inline void expandReplacements(UString * & array, int& count, int& capacity) 220 { 221 int newCapacity; 222 if (capacity == 0) { 223 newCapacity = 16; 224 } else { 225 newCapacity = capacity * 2; 226 } 227 228 UString *newArray = new UString[newCapacity]; 229 for (int i = 0; i < count; i++) { 230 newArray[i] = array[i]; 231 } 232 233 delete [] array; 234 235 capacity = newCapacity; 236 array = newArray; 237 } 238 239 static void pushReplacement(UString * & array, int& count, int& capacity, UString replacement) 240 { 241 if (count + 1 > capacity) 242 expandReplacements(array, count, capacity); 243 244 array[count] = replacement; 245 count++; 246 } 247 248 static inline UString substituteBackreferences(const UString &replacement, const UString &source, int *ovector, RegExp *reg) 249 { 250 UString substitutedReplacement = replacement; 251 204 static inline UString substituteBackreferences(const UString& replacement, const UString& source, const int* ovector, RegExp* reg) 205 { 206 UString substitutedReplacement; 207 int offset = 0; 252 208 int i = -1; 253 while ((i = substitutedReplacement.find(UString("$"), i + 1)) != -1) {254 if (i +1 == substitutedReplacement.size())209 while ((i = replacement.find('$', i + 1)) != -1) { 210 if (i + 1 == replacement.size()) 255 211 break; 256 212 257 unsigned short ref = substitutedReplacement[i+1]; 258 int backrefStart = 0; 259 int backrefLength = 0; 213 unsigned short ref = replacement[i + 1]; 214 if (ref == '$') { 215 // "$$" -> "$" 216 ++i; 217 substitutedReplacement.append(replacement.data() + offset, i - offset); 218 offset = i + 1; 219 substitutedReplacement.append('$'); 220 continue; 221 } 222 223 int backrefStart; 224 int backrefLength; 260 225 int advance = 0; 261 262 if (ref == '$') { // "$$" -> "$" 263 substitutedReplacement = substitutedReplacement.substr(0, i + 1) + substitutedReplacement.substr(i + 2); 264 continue; 265 } else if (ref == '&') { 226 if (ref == '&') { 266 227 backrefStart = ovector[0]; 267 228 backrefLength = ovector[1] - backrefStart; … … 277 238 if (backrefIndex > reg->numSubpatterns()) 278 239 continue; 279 if ( substitutedReplacement.size() > i + 2) {280 ref = substitutedReplacement[i+2];240 if (replacement.size() > i + 2) { 241 ref = replacement[i + 2]; 281 242 if (ref >= '0' && ref <= '9') { 282 243 backrefIndex = 10 * backrefIndex + ref - '0'; … … 292 253 continue; 293 254 294 substitutedReplacement = substitutedReplacement.substr(0, i) + source.substr(backrefStart, backrefLength) + substitutedReplacement.substr(i + 2 + advance); 295 i += backrefLength - 1; // - 1 offsets 'i + 1' 255 if (i - offset) 256 substitutedReplacement.append(replacement.data() + offset, i - offset); 257 i += 1 + advance; 258 offset = i + 1; 259 substitutedReplacement.append(source.data() + backrefStart, backrefLength); 296 260 } 297 261 262 if (!offset) 263 return replacement; 264 265 if (replacement.size() - offset) 266 substitutedReplacement.append(replacement.data() + offset, replacement.size() - offset); 267 298 268 return substitutedReplacement; 299 269 } … … 304 274 } 305 275 306 static JSValue *replace(ExecState *exec, JSString* sourceVal, JSValue *pattern, JSValue *replacement) 307 { 308 UString source = sourceVal->value(); 276 JSValue* stringProtoFuncReplace(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) 277 { 278 JSString* sourceVal = thisValue->toThisJSString(exec); 279 const UString& source = sourceVal->value(); 280 281 JSValue* pattern = args[0]; 282 283 JSValue* replacement = args[1]; 284 UString replacementString; 309 285 CallData callData; 310 UString replacementString;311 312 286 CallType callType = replacement->getCallData(callData); 313 287 if (callType == CallTypeNone) 314 288 replacementString = replacement->toString(exec); 315 289 316 if (pattern->isObject( ) && static_cast<JSObject *>(pattern)->inherits(&RegExpObject::info)) {317 RegExp *reg = static_cast<RegExpObject*>(pattern)->regExp();290 if (pattern->isObject(&RegExpObject::info)) { 291 RegExp* reg = static_cast<RegExpObject*>(pattern)->regExp(); 318 292 bool global = reg->global(); 319 293 320 RegExpConstructor* regExpObj = static_cast<RegExpConstructor*>(exec->lexicalGlobalObject()->regExpConstructor());294 RegExpConstructor* regExpObj = exec->lexicalGlobalObject()->regExpConstructor(); 321 295 322 296 int lastIndex = 0; 323 297 int startPosition = 0; 324 298 325 UString::Range *sourceRanges = 0; 326 int sourceRangeCount = 0; 327 int sourceRangeCapacity = 0; 328 UString *replacements = 0; 329 int replacementCount = 0; 330 int replacementCapacity = 0; 299 Vector<UString::Range, 16> sourceRanges; 300 Vector<UString, 16> replacements; 331 301 332 302 // This is either a loop (if global is set) or a one-way (if not). … … 339 309 break; 340 310 341 pushSourceRange(sourceRanges, sourceRangeCount, sourceRangeCapacity, UString::Range(lastIndex, matchIndex - lastIndex)); 342 343 UString substitutedReplacement; 311 sourceRanges.append(UString::Range(lastIndex, matchIndex - lastIndex)); 312 344 313 if (callType != CallTypeNone) { 345 314 int completeMatchStart = ovector[0]; … … 359 328 args.append(sourceVal); 360 329 361 substitutedReplacement = call(exec, replacement, callType, callData, exec->globalThisValue(), args)->toString(exec);330 replacements.append(call(exec, replacement, callType, callData, exec->globalThisValue(), args)->toString(exec)); 362 331 } else 363 substitutedReplacement = substituteBackreferences(replacementString, source, ovector, reg); 364 365 pushReplacement(replacements, replacementCount, replacementCapacity, substitutedReplacement); 332 replacements.append(substituteBackreferences(replacementString, source, ovector, reg)); 366 333 367 334 lastIndex = matchIndex + matchLen; … … 377 344 378 345 if (lastIndex < source.size()) 379 pushSourceRange(sourceRanges, sourceRangeCount, sourceRangeCapacity, UString::Range(lastIndex, source.size() - lastIndex)); 380 381 UString result; 382 383 if (sourceRanges) 384 result = source.spliceSubstringsWithSeparators(sourceRanges, sourceRangeCount, replacements, replacementCount); 385 386 delete [] sourceRanges; 387 delete [] replacements; 346 sourceRanges.append(UString::Range(lastIndex, source.size() - lastIndex)); 347 348 UString result = source.spliceSubstringsWithSeparators(sourceRanges.data(), sourceRanges.size(), replacements.data(), replacements.size()); 388 349 389 350 if (result == source) … … 416 377 JSValue* stringProtoFuncToString(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&) 417 378 { 418 if (!thisValue->isObject(&StringObject::info)) 419 return throwError(exec, TypeError); 420 421 return static_cast<StringObject*>(thisValue)->internalValue(); 422 } 423 424 JSValue* stringProtoFuncValueOf(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&) 425 { 426 if (!thisValue->isObject(&StringObject::info)) 427 return throwError(exec, TypeError); 428 429 return static_cast<StringObject*>(thisValue)->internalValue(); 379 // Also used for valueOf. 380 381 if (thisValue->isString()) 382 return thisValue; 383 384 if (thisValue->isObject(&StringObject::info)) 385 return static_cast<StringObject*>(thisValue)->internalValue(); 386 387 return throwError(exec, TypeError); 430 388 } 431 389 432 390 JSValue* stringProtoFuncCharAt(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) 433 391 { 434 // This optimizes the common case that thisObj is a StringObject 435 UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec); 392 UString s = thisValue->toThisString(exec); 436 393 int len = s.size(); 437 394 … … 448 405 JSValue* stringProtoFuncCharCodeAt(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) 449 406 { 450 // This optimizes the common case that thisObj is a StringObject 451 UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec); 407 UString s = thisValue->toThisString(exec); 452 408 int len = s.size(); 453 409 … … 465 421 JSValue* stringProtoFuncConcat(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) 466 422 { 467 // This optimizes the common case that thisObj is a StringObject 468 UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec); 423 UString s = thisValue->toThisString(exec); 469 424 470 425 ArgList::const_iterator end = args.end(); … … 477 432 JSValue* stringProtoFuncIndexOf(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) 478 433 { 479 // This optimizes the common case that thisObj is a StringObject 480 UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec); 434 UString s = thisValue->toThisString(exec); 481 435 int len = s.size(); 482 436 … … 494 448 JSValue* stringProtoFuncLastIndexOf(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) 495 449 { 496 // This optimizes the common case that thisObj is a StringObject 497 UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec); 450 UString s = thisValue->toThisString(exec); 498 451 int len = s.size(); 499 452 … … 512 465 JSValue* stringProtoFuncMatch(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) 513 466 { 514 // This optimizes the common case that thisObj is a StringObject 515 UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec); 467 UString s = thisValue->toThisString(exec); 516 468 517 469 JSValue* a0 = args[0]; … … 530 482 reg = RegExp::create(a0->toString(exec)); 531 483 } 532 RegExpConstructor* regExpObj = static_cast<RegExpConstructor*>(exec->lexicalGlobalObject()->regExpConstructor());484 RegExpConstructor* regExpObj = exec->lexicalGlobalObject()->regExpConstructor(); 533 485 int pos; 534 486 int matchLength; … … 567 519 JSValue* stringProtoFuncSearch(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) 568 520 { 569 // This optimizes the common case that thisObj is a StringObject 570 UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec); 521 UString s = thisValue->toThisString(exec); 571 522 572 523 JSValue* a0 = args[0]; … … 584 535 reg = RegExp::create(a0->toString(exec)); 585 536 } 586 RegExpConstructor* regExpObj = static_cast<RegExpConstructor*>(exec->lexicalGlobalObject()->regExpConstructor());537 RegExpConstructor* regExpObj = exec->lexicalGlobalObject()->regExpConstructor(); 587 538 int pos; 588 539 int matchLength; … … 591 542 } 592 543 593 JSValue* stringProtoFuncReplace(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)594 {595 // This optimizes the common case that thisObj is a StringObject596 UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);597 598 JSString* sVal = thisValue->isObject(&StringObject::info) ?599 static_cast<StringObject*>(thisValue)->internalValue() :600 static_cast<JSString*>(jsString(exec, s));601 602 JSValue* a0 = args[0];603 JSValue* a1 = args[1];604 605 return replace(exec, sVal, a0, a1);606 }607 608 544 JSValue* stringProtoFuncSlice(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) 609 545 { 610 // This optimizes the common case that thisObj is a StringObject 611 UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec); 546 UString s = thisValue->toThisString(exec); 612 547 int len = s.size(); 613 548 … … 633 568 JSValue* stringProtoFuncSplit(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) 634 569 { 635 // This optimizes the common case that thisObj is a StringObject 636 UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec); 570 UString s = thisValue->toThisString(exec); 637 571 638 572 JSValue* a0 = args[0]; … … 702 636 JSValue* stringProtoFuncSubstr(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) 703 637 { 704 // This optimizes the common case that thisObj is a StringObject 705 UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec); 638 UString s = thisValue->toThisString(exec); 706 639 int len = s.size(); 707 640 … … 727 660 JSValue* stringProtoFuncSubstring(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) 728 661 { 729 // This optimizes the common case that thisObj is a StringObject 730 UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec); 662 UString s = thisValue->toThisString(exec); 731 663 int len = s.size(); 732 664 … … 760 692 JSValue* stringProtoFuncToLowerCase(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&) 761 693 { 762 // This optimizes the common case that thisObj is a StringObject763 UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec);694 JSString* sVal = thisValue->toThisJSString(exec); 695 const UString& s = sVal->value(); 764 696 765 JSString* sVal = thisValue->isObject(&StringObject::info)766 ? static_cast<StringObject*>(thisValue)->internalValue()767 : static_cast<JSString*>(jsString(exec, s));768 697 int ssize = s.size(); 769 698 if (!ssize) … … 785 714 JSValue* stringProtoFuncToUpperCase(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&) 786 715 { 787 // This optimizes the common case that thisObj is a StringObject 788 UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec); 789 790 JSString* sVal = thisValue->isObject(&StringObject::info) 791 ? static_cast<StringObject*>(thisValue)->internalValue() 792 : static_cast<JSString*>(jsString(exec, s)); 716 JSString* sVal = thisValue->toThisJSString(exec); 717 const UString& s = sVal->value(); 718 793 719 int ssize = s.size(); 794 720 if (!ssize) … … 810 736 JSValue* stringProtoFuncToLocaleLowerCase(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&) 811 737 { 812 // This optimizes the common case that thisObj is a StringObject 813 UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec); 738 // FIXME: See http://www.unicode.org/Public/UNIDATA/SpecialCasing.txt for locale-sensitive mappings that aren't implemented. 739 740 JSString* sVal = thisValue->toThisJSString(exec); 741 const UString& s = sVal->value(); 814 742 815 // FIXME: See http://www.unicode.org/Public/UNIDATA/SpecialCasing.txt for locale-sensitive mappings that aren't implemented.816 JSString* sVal = thisValue->isObject(&StringObject::info)817 ? static_cast<StringObject*>(thisValue)->internalValue()818 : static_cast<JSString*>(jsString(exec, s));819 743 int ssize = s.size(); 820 744 if (!ssize) … … 836 760 JSValue* stringProtoFuncToLocaleUpperCase(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&) 837 761 { 838 // This optimizes the common case that thisObj is a StringObject 839 UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec); 840 841 JSString* sVal = thisValue->isObject(&StringObject::info) 842 ? static_cast<StringObject*>(thisValue)->internalValue() 843 : static_cast<JSString*>(jsString(exec, s)); 762 JSString* sVal = thisValue->toThisJSString(exec); 763 const UString& s = sVal->value(); 764 844 765 int ssize = s.size(); 845 766 if (!ssize) … … 864 785 return jsNumber(exec, 0); 865 786 866 // This optimizes the common case that thisObj is a StringObject 867 UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec); 787 UString s = thisValue->toThisString(exec); 868 788 JSValue* a0 = args[0]; 869 789 return jsNumber(exec, localeCompare(s, a0->toString(exec))); … … 872 792 JSValue* stringProtoFuncBig(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&) 873 793 { 874 // This optimizes the common case that thisObj is a StringObject 875 UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec); 794 UString s = thisValue->toThisString(exec); 876 795 return jsString(exec, "<big>" + s + "</big>"); 877 796 } … … 879 798 JSValue* stringProtoFuncSmall(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&) 880 799 { 881 // This optimizes the common case that thisObj is a StringObject 882 UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec); 800 UString s = thisValue->toThisString(exec); 883 801 return jsString(exec, "<small>" + s + "</small>"); 884 802 } … … 886 804 JSValue* stringProtoFuncBlink(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&) 887 805 { 888 // This optimizes the common case that thisObj is a StringObject 889 UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec); 806 UString s = thisValue->toThisString(exec); 890 807 return jsString(exec, "<blink>" + s + "</blink>"); 891 808 } … … 893 810 JSValue* stringProtoFuncBold(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&) 894 811 { 895 // This optimizes the common case that thisObj is a StringObject 896 UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec); 812 UString s = thisValue->toThisString(exec); 897 813 return jsString(exec, "<b>" + s + "</b>"); 898 814 } … … 900 816 JSValue* stringProtoFuncFixed(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&) 901 817 { 902 // This optimizes the common case that thisObj is a StringObject 903 UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec); 818 UString s = thisValue->toThisString(exec); 904 819 return jsString(exec, "<tt>" + s + "</tt>"); 905 820 } … … 907 822 JSValue* stringProtoFuncItalics(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&) 908 823 { 909 // This optimizes the common case that thisObj is a StringObject 910 UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec); 824 UString s = thisValue->toThisString(exec); 911 825 return jsString(exec, "<i>" + s + "</i>"); 912 826 } … … 914 828 JSValue* stringProtoFuncStrike(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&) 915 829 { 916 // This optimizes the common case that thisObj is a StringObject 917 UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec); 830 UString s = thisValue->toThisString(exec); 918 831 return jsString(exec, "<strike>" + s + "</strike>"); 919 832 } … … 921 834 JSValue* stringProtoFuncSub(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&) 922 835 { 923 // This optimizes the common case that thisObj is a StringObject 924 UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec); 836 UString s = thisValue->toThisString(exec); 925 837 return jsString(exec, "<sub>" + s + "</sub>"); 926 838 } … … 928 840 JSValue* stringProtoFuncSup(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&) 929 841 { 930 // This optimizes the common case that thisObj is a StringObject 931 UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec); 842 UString s = thisValue->toThisString(exec); 932 843 return jsString(exec, "<sup>" + s + "</sup>"); 933 844 } … … 935 846 JSValue* stringProtoFuncFontcolor(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) 936 847 { 937 // This optimizes the common case that thisObj is a StringObject 938 UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec); 848 UString s = thisValue->toThisString(exec); 939 849 JSValue* a0 = args[0]; 940 850 return jsString(exec, "<font color=\"" + a0->toString(exec) + "\">" + s + "</font>"); … … 943 853 JSValue* stringProtoFuncFontsize(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) 944 854 { 945 // This optimizes the common case that thisObj is a StringObject 946 UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec); 855 UString s = thisValue->toThisString(exec); 947 856 JSValue* a0 = args[0]; 948 857 return jsString(exec, "<font size=\"" + a0->toString(exec) + "\">" + s + "</font>"); … … 951 860 JSValue* stringProtoFuncAnchor(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) 952 861 { 953 // This optimizes the common case that thisObj is a StringObject 954 UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec); 862 UString s = thisValue->toThisString(exec); 955 863 JSValue* a0 = args[0]; 956 864 return jsString(exec, "<a name=\"" + a0->toString(exec) + "\">" + s + "</a>"); … … 959 867 JSValue* stringProtoFuncLink(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) 960 868 { 961 // This optimizes the common case that thisObj is a StringObject 962 UString s = thisValue->isObject(&StringObject::info) ? static_cast<StringObject*>(thisValue)->internalValue()->value() : thisValue->toThisObject(exec)->toString(exec); 869 UString s = thisValue->toThisString(exec); 963 870 JSValue* a0 = args[0]; 964 871 return jsString(exec, "<a href=\"" + a0->toString(exec) + "\">" + s + "</a>");
Note:
See TracChangeset
for help on using the changeset viewer.