| 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 var patLength = pat.length; | 142 var patLength = pat.length; |
| 143 var index = subLength - patLength; | 143 var index = subLength - patLength; |
| 144 if (%_ArgumentsLength() > 1) { | 144 if (%_ArgumentsLength() > 1) { |
| 145 var position = ToNumber(%_Arguments(1)); | 145 var position = ToNumber(%_Arguments(1)); |
| 146 if (!NUMBER_IS_NAN(position)) { | 146 if (!NUMBER_IS_NAN(position)) { |
| 147 position = TO_INTEGER(position); | 147 position = TO_INTEGER(position); |
| 148 if (position < 0) { | 148 if (position < 0) { |
| 149 position = 0; | 149 position = 0; |
| 150 } | 150 } |
| 151 if (position + patLength < subLength) { | 151 if (position + patLength < subLength) { |
| 152 index = position | 152 index = position; |
| 153 } | 153 } |
| 154 } | 154 } |
| 155 } | 155 } |
| 156 if (index < 0) { | 156 if (index < 0) { |
| 157 return -1; | 157 return -1; |
| 158 } | 158 } |
| 159 return %StringLastIndexOf(sub, pat, index); | 159 return %StringLastIndexOf(sub, pat, index); |
| 160 } | 160 } |
| 161 | 161 |
| 162 | 162 |
| 163 // ECMA-262 section 15.5.4.9 | 163 // ECMA-262 section 15.5.4.9 |
| 164 // | 164 // |
| 165 // This function is implementation specific. For now, we do not | 165 // This function is implementation specific. For now, we do not |
| 166 // do anything locale specific. | 166 // do anything locale specific. |
| 167 function StringLocaleCompare(other) { | 167 function StringLocaleCompare(other) { |
| 168 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { | 168 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { |
| 169 throw MakeTypeError("called_on_null_or_undefined", | 169 throw MakeTypeError("called_on_null_or_undefined", |
| 170 ["String.prototype.localeCompare"]); | 170 ["String.prototype.localeCompare"]); |
| 171 } | 171 } |
| 172 if (%_ArgumentsLength() === 0) return 0; | 172 if (%_ArgumentsLength() === 0) return 0; |
| 173 return %StringLocaleCompare(TO_STRING_INLINE(this), | 173 return %StringLocaleCompare(TO_STRING_INLINE(this), |
| 174 TO_STRING_INLINE(other)); | 174 TO_STRING_INLINE(other)); |
| 175 } | 175 } |
| 176 | 176 |
| 177 | 177 |
| 178 // ECMA-262 section 15.5.4.10 | 178 // ECMA-262 section 15.5.4.10 |
| 179 function StringMatch(regexp) { | 179 function StringMatch(regexp) { |
| 180 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { | 180 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { |
| 181 throw MakeTypeError("called_on_null_or_undefined", | 181 throw MakeTypeError("called_on_null_or_undefined", |
| 182 ["String.prototype.match"]); | 182 ["String.prototype.match"]); |
| 183 } | 183 } |
| (...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 907 // ReplaceResultBuilder support. | 907 // ReplaceResultBuilder support. |
| 908 function ReplaceResultBuilder(str) { | 908 function ReplaceResultBuilder(str) { |
| 909 if (%_ArgumentsLength() > 1) { | 909 if (%_ArgumentsLength() > 1) { |
| 910 this.elements = %_Arguments(1); | 910 this.elements = %_Arguments(1); |
| 911 } else { | 911 } else { |
| 912 this.elements = new InternalArray(); | 912 this.elements = new InternalArray(); |
| 913 } | 913 } |
| 914 this.special_string = str; | 914 this.special_string = str; |
| 915 } | 915 } |
| 916 | 916 |
| 917 ReplaceResultBuilder.prototype.__proto__ = null; |
| 918 |
| 917 | 919 |
| 918 ReplaceResultBuilder.prototype.add = function(str) { | 920 ReplaceResultBuilder.prototype.add = function(str) { |
| 919 str = TO_STRING_INLINE(str); | 921 str = TO_STRING_INLINE(str); |
| 920 if (str.length > 0) this.elements.push(str); | 922 if (str.length > 0) this.elements.push(str); |
| 921 } | 923 } |
| 922 | 924 |
| 923 | 925 |
| 924 ReplaceResultBuilder.prototype.addSpecialSlice = function(start, end) { | 926 ReplaceResultBuilder.prototype.addSpecialSlice = function(start, end) { |
| 925 var len = end - start; | 927 var len = end - start; |
| 926 if (start < 0 || len <= 0) return; | 928 if (start < 0 || len <= 0) return; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 990 "italics", StringItalics, | 992 "italics", StringItalics, |
| 991 "small", StringSmall, | 993 "small", StringSmall, |
| 992 "strike", StringStrike, | 994 "strike", StringStrike, |
| 993 "sub", StringSub, | 995 "sub", StringSub, |
| 994 "sup", StringSup | 996 "sup", StringSup |
| 995 )); | 997 )); |
| 996 } | 998 } |
| 997 | 999 |
| 998 | 1000 |
| 999 SetupString(); | 1001 SetupString(); |
| OLD | NEW |