| 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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 if (%_ArgumentsLength() === 0) return 0; | 153 if (%_ArgumentsLength() === 0) return 0; |
| 154 | 154 |
| 155 var this_str = ToString(this); | 155 var this_str = ToString(this); |
| 156 var other_str = ToString(other); | 156 var other_str = ToString(other); |
| 157 return %StringLocaleCompare(this_str, other_str); | 157 return %StringLocaleCompare(this_str, other_str); |
| 158 } | 158 } |
| 159 | 159 |
| 160 | 160 |
| 161 // ECMA-262 section 15.5.4.10 | 161 // ECMA-262 section 15.5.4.10 |
| 162 function StringMatch(regexp) { | 162 function StringMatch(regexp) { |
| 163 if (!IS_REGEXP(regexp)) regexp = new ORIGINAL_REGEXP(regexp); | 163 if (!IS_REGEXP(regexp)) regexp = new $RegExp(regexp); |
| 164 var subject = ToString(this); | 164 var subject = ToString(this); |
| 165 | 165 |
| 166 if (!regexp.global) return regexp.exec(subject); | 166 if (!regexp.global) return regexp.exec(subject); |
| 167 %_Log('regexp', 'regexp-match,%0S,%1r', [subject, regexp]); | 167 %_Log('regexp', 'regexp-match,%0S,%1r', [subject, regexp]); |
| 168 // lastMatchInfo is defined in regexp-delay.js. | 168 // lastMatchInfo is defined in regexp.js. |
| 169 return %StringMatch(subject, regexp, lastMatchInfo); | 169 return %StringMatch(subject, regexp, lastMatchInfo); |
| 170 } | 170 } |
| 171 | 171 |
| 172 | 172 |
| 173 // SubString is an internal function that returns the sub string of 'string'. | 173 // SubString is an internal function that returns the sub string of 'string'. |
| 174 // If resulting string is of length 1, we use the one character cache | 174 // If resulting string is of length 1, we use the one character cache |
| 175 // otherwise we call the runtime system. | 175 // otherwise we call the runtime system. |
| 176 function SubString(string, start, end) { | 176 function SubString(string, start, end) { |
| 177 // Use the one character string cache. | 177 // Use the one character string cache. |
| 178 if (start + 1 == end) { | 178 if (start + 1 == end) { |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 parameters[j] = CaptureString(subject, matchInfo, j); | 450 parameters[j] = CaptureString(subject, matchInfo, j); |
| 451 } | 451 } |
| 452 parameters[j] = index; | 452 parameters[j] = index; |
| 453 parameters[j + 1] = subject; | 453 parameters[j + 1] = subject; |
| 454 return replace.apply(null, parameters); | 454 return replace.apply(null, parameters); |
| 455 } | 455 } |
| 456 | 456 |
| 457 | 457 |
| 458 // ECMA-262 section 15.5.4.12 | 458 // ECMA-262 section 15.5.4.12 |
| 459 function StringSearch(re) { | 459 function StringSearch(re) { |
| 460 var regexp = new ORIGINAL_REGEXP(re); | 460 var regexp = new $RegExp(re); |
| 461 var s = ToString(this); | 461 var s = ToString(this); |
| 462 var last_idx = regexp.lastIndex; // keep old lastIndex | 462 var last_idx = regexp.lastIndex; // keep old lastIndex |
| 463 regexp.lastIndex = 0; // ignore re.global property | 463 regexp.lastIndex = 0; // ignore re.global property |
| 464 var result = regexp.exec(s); | 464 var result = regexp.exec(s); |
| 465 regexp.lastIndex = last_idx; // restore lastIndex | 465 regexp.lastIndex = last_idx; // restore lastIndex |
| 466 if (result == null) | 466 if (result == null) |
| 467 return -1; | 467 return -1; |
| 468 else | 468 else |
| 469 return result.index; | 469 return result.index; |
| 470 } | 470 } |
| (...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 892 "small", StringSmall, | 892 "small", StringSmall, |
| 893 "strike", StringStrike, | 893 "strike", StringStrike, |
| 894 "sub", StringSub, | 894 "sub", StringSub, |
| 895 "sup", StringSup, | 895 "sup", StringSup, |
| 896 "toJSON", StringToJSON | 896 "toJSON", StringToJSON |
| 897 )); | 897 )); |
| 898 } | 898 } |
| 899 | 899 |
| 900 | 900 |
| 901 SetupString(); | 901 SetupString(); |
| OLD | NEW |