OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 // Helper function to apply a string replacement function once. | 426 // Helper function to apply a string replacement function once. |
427 function ApplyReplacementFunction(replace, lastMatchInfo, subject) { | 427 function ApplyReplacementFunction(replace, lastMatchInfo, subject) { |
428 // Compute the parameter list consisting of the match, captures, index, | 428 // Compute the parameter list consisting of the match, captures, index, |
429 // and subject for the replace function invocation. | 429 // and subject for the replace function invocation. |
430 var index = lastMatchInfo[CAPTURE0]; | 430 var index = lastMatchInfo[CAPTURE0]; |
431 // The number of captures plus one for the match. | 431 // The number of captures plus one for the match. |
432 var m = NUMBER_OF_CAPTURES(lastMatchInfo) >> 1; | 432 var m = NUMBER_OF_CAPTURES(lastMatchInfo) >> 1; |
433 if (m == 1) { | 433 if (m == 1) { |
434 var s = CaptureString(subject, lastMatchInfo, 0); | 434 var s = CaptureString(subject, lastMatchInfo, 0); |
435 // Don't call directly to avoid exposing the built-in global object. | 435 // Don't call directly to avoid exposing the built-in global object. |
436 return ToString(replace.call(null, s, index, subject)); | 436 return replace.call(null, s, index, subject); |
437 } | 437 } |
438 var parameters = $Array(m + 2); | 438 var parameters = $Array(m + 2); |
439 for (var j = 0; j < m; j++) { | 439 for (var j = 0; j < m; j++) { |
440 parameters[j] = CaptureString(subject, lastMatchInfo, j); | 440 parameters[j] = CaptureString(subject, lastMatchInfo, j); |
441 } | 441 } |
442 parameters[j] = index; | 442 parameters[j] = index; |
443 parameters[j + 1] = subject; | 443 parameters[j + 1] = subject; |
444 return ToString(replace.apply(null, parameters)); | 444 return replace.apply(null, parameters); |
445 } | 445 } |
446 | 446 |
447 | 447 |
448 // ECMA-262 section 15.5.4.12 | 448 // ECMA-262 section 15.5.4.12 |
449 function StringSearch(re) { | 449 function StringSearch(re) { |
450 var regexp = new ORIGINAL_REGEXP(re); | 450 var regexp = new ORIGINAL_REGEXP(re); |
451 var s = ToString(this); | 451 var s = ToString(this); |
452 var last_idx = regexp.lastIndex; // keep old lastIndex | 452 var last_idx = regexp.lastIndex; // keep old lastIndex |
453 regexp.lastIndex = 0; // ignore re.global property | 453 regexp.lastIndex = 0; // ignore re.global property |
454 var result = regexp.exec(s); | 454 var result = regexp.exec(s); |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
867 "small", StringSmall, | 867 "small", StringSmall, |
868 "strike", StringStrike, | 868 "strike", StringStrike, |
869 "sub", StringSub, | 869 "sub", StringSub, |
870 "sup", StringSup, | 870 "sup", StringSup, |
871 "toJSON", StringToJSON | 871 "toJSON", StringToJSON |
872 )); | 872 )); |
873 } | 873 } |
874 | 874 |
875 | 875 |
876 SetupString(); | 876 SetupString(); |
OLD | NEW |