| OLD | NEW | 
|---|
| 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without | 
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are | 
| 4 // met: | 4 // met: | 
| 5 // | 5 // | 
| 6 //     * Redistributions of source code must retain the above copyright | 6 //     * Redistributions of source code must retain the above copyright | 
| 7 //       notice, this list of conditions and the following disclaimer. | 7 //       notice, this list of conditions and the following disclaimer. | 
| 8 //     * Redistributions in binary form must reproduce the above | 8 //     * Redistributions in binary form must reproduce the above | 
| 9 //       copyright notice, this list of conditions and the following | 9 //       copyright notice, this list of conditions and the following | 
| 10 //       disclaimer in the documentation and/or other materials provided | 10 //       disclaimer in the documentation and/or other materials provided | 
| (...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 904 // ReplaceResultBuilder support. | 904 // ReplaceResultBuilder support. | 
| 905 function ReplaceResultBuilder(str) { | 905 function ReplaceResultBuilder(str) { | 
| 906   if (%_ArgumentsLength() > 1) { | 906   if (%_ArgumentsLength() > 1) { | 
| 907     this.elements = %_Arguments(1); | 907     this.elements = %_Arguments(1); | 
| 908   } else { | 908   } else { | 
| 909     this.elements = new InternalArray(); | 909     this.elements = new InternalArray(); | 
| 910   } | 910   } | 
| 911   this.special_string = str; | 911   this.special_string = str; | 
| 912 } | 912 } | 
| 913 | 913 | 
| 914 SetUpLockedPrototype(ReplaceResultBuilder, | 914 ReplaceResultBuilder.prototype.__proto__ = null; | 
| 915   $Array("elements", "special_string"), $Array( | 915 | 
| 916   "add", function(str) { | 916 | 
| 917     str = TO_STRING_INLINE(str); | 917 ReplaceResultBuilder.prototype.add = function(str) { | 
| 918     if (str.length > 0) this.elements.push(str); | 918   str = TO_STRING_INLINE(str); | 
| 919   }, | 919   if (str.length > 0) this.elements.push(str); | 
| 920   "addSpecialSlice", function(start, end) { | 920 } | 
| 921     var len = end - start; | 921 | 
| 922     if (start < 0 || len <= 0) return; | 922 | 
| 923     if (start < 0x80000 && len < 0x800) { | 923 ReplaceResultBuilder.prototype.addSpecialSlice = function(start, end) { | 
| 924       this.elements.push((start << 11) | len); | 924   var len = end - start; | 
| 925     } else { | 925   if (start < 0 || len <= 0) return; | 
| 926       // 0 < len <= String::kMaxLength and Smi::kMaxValue >= String::kMaxLength, | 926   if (start < 0x80000 && len < 0x800) { | 
| 927       // so -len is a smi. | 927     this.elements.push((start << 11) | len); | 
| 928       var elements = this.elements; | 928   } else { | 
| 929       elements.push(-len); | 929     // 0 < len <= String::kMaxLength and Smi::kMaxValue >= String::kMaxLength, | 
| 930       elements.push(start); | 930     // so -len is a smi. | 
| 931     } |  | 
| 932   }, |  | 
| 933   "generate", function() { |  | 
| 934     var elements = this.elements; | 931     var elements = this.elements; | 
| 935     return %StringBuilderConcat(elements, elements.length, this.special_string); | 932     elements.push(-len); | 
|  | 933     elements.push(start); | 
| 936   } | 934   } | 
| 937 )); | 935 } | 
|  | 936 | 
|  | 937 | 
|  | 938 ReplaceResultBuilder.prototype.generate = function() { | 
|  | 939   var elements = this.elements; | 
|  | 940   return %StringBuilderConcat(elements, elements.length, this.special_string); | 
|  | 941 } | 
| 938 | 942 | 
| 939 | 943 | 
| 940 // ------------------------------------------------------------------- | 944 // ------------------------------------------------------------------- | 
| 941 | 945 | 
| 942 function SetUpString() { | 946 function SetupString() { | 
| 943   %CheckIsBootstrapping(); | 947   // Setup the constructor property on the String prototype object. | 
| 944   // Set up the constructor property on the String prototype object. |  | 
| 945   %SetProperty($String.prototype, "constructor", $String, DONT_ENUM); | 948   %SetProperty($String.prototype, "constructor", $String, DONT_ENUM); | 
| 946 | 949 | 
| 947 | 950 | 
| 948   // Set up the non-enumerable functions on the String object. | 951   // Setup the non-enumerable functions on the String object. | 
| 949   InstallFunctions($String, DONT_ENUM, $Array( | 952   InstallFunctions($String, DONT_ENUM, $Array( | 
| 950     "fromCharCode", StringFromCharCode | 953     "fromCharCode", StringFromCharCode | 
| 951   )); | 954   )); | 
| 952 | 955 | 
| 953 | 956 | 
| 954   // Set up the non-enumerable functions on the String prototype object. | 957   // Setup the non-enumerable functions on the String prototype object. | 
| 955   InstallFunctionsOnHiddenPrototype($String.prototype, DONT_ENUM, $Array( | 958   InstallFunctionsOnHiddenPrototype($String.prototype, DONT_ENUM, $Array( | 
| 956     "valueOf", StringValueOf, | 959     "valueOf", StringValueOf, | 
| 957     "toString", StringToString, | 960     "toString", StringToString, | 
| 958     "charAt", StringCharAt, | 961     "charAt", StringCharAt, | 
| 959     "charCodeAt", StringCharCodeAt, | 962     "charCodeAt", StringCharCodeAt, | 
| 960     "concat", StringConcat, | 963     "concat", StringConcat, | 
| 961     "indexOf", StringIndexOf, | 964     "indexOf", StringIndexOf, | 
| 962     "lastIndexOf", StringLastIndexOf, | 965     "lastIndexOf", StringLastIndexOf, | 
| 963     "localeCompare", StringLocaleCompare, | 966     "localeCompare", StringLocaleCompare, | 
| 964     "match", StringMatch, | 967     "match", StringMatch, | 
| (...skipping 19 matching lines...) Expand all  Loading... | 
| 984     "bold", StringBold, | 987     "bold", StringBold, | 
| 985     "fixed", StringFixed, | 988     "fixed", StringFixed, | 
| 986     "italics", StringItalics, | 989     "italics", StringItalics, | 
| 987     "small", StringSmall, | 990     "small", StringSmall, | 
| 988     "strike", StringStrike, | 991     "strike", StringStrike, | 
| 989     "sub", StringSub, | 992     "sub", StringSub, | 
| 990     "sup", StringSup | 993     "sup", StringSup | 
| 991   )); | 994   )); | 
| 992 } | 995 } | 
| 993 | 996 | 
| 994 SetUpString(); | 997 | 
|  | 998 SetupString(); | 
| OLD | NEW | 
|---|