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 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 for (var j = 0; j < m; j++) { | 515 for (var j = 0; j < m; j++) { |
516 parameters[j] = CaptureString(subject, matchInfo, j); | 516 parameters[j] = CaptureString(subject, matchInfo, j); |
517 } | 517 } |
518 parameters[j] = index; | 518 parameters[j] = index; |
519 parameters[j + 1] = subject; | 519 parameters[j + 1] = subject; |
520 return replace.apply(null, parameters); | 520 return replace.apply(null, parameters); |
521 } | 521 } |
522 | 522 |
523 | 523 |
524 // ECMA-262 section 15.5.4.12 | 524 // ECMA-262 section 15.5.4.12 |
525 function StringSearch(re) { | 525 function StringSearch(re) { |
526 var regexp = new $RegExp(re); | 526 var regexp = new $RegExp(re); |
527 var s = TO_STRING_INLINE(this); | 527 var s = TO_STRING_INLINE(this); |
528 var last_idx = regexp.lastIndex; // keep old lastIndex | 528 var match = DoRegExpExec(regexp, s, 0); |
529 regexp.lastIndex = 0; // ignore re.global property | 529 if (match) { |
530 var result = regexp.exec(s); | 530 lastMatchInfo = match; |
531 regexp.lastIndex = last_idx; // restore lastIndex | 531 return match[CAPTURE0]; |
532 if (result == null) | 532 } |
533 return -1; | 533 return -1; |
534 else | |
535 return result.index; | |
536 } | 534 } |
537 | 535 |
538 | 536 |
539 // ECMA-262 section 15.5.4.13 | 537 // ECMA-262 section 15.5.4.13 |
540 function StringSlice(start, end) { | 538 function StringSlice(start, end) { |
541 var s = TO_STRING_INLINE(this); | 539 var s = TO_STRING_INLINE(this); |
542 var s_len = s.length; | 540 var s_len = s.length; |
543 var start_i = TO_INTEGER(start); | 541 var start_i = TO_INTEGER(start); |
544 var end_i = s_len; | 542 var end_i = s_len; |
545 if (end !== void 0) | 543 if (end !== void 0) |
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
986 "small", StringSmall, | 984 "small", StringSmall, |
987 "strike", StringStrike, | 985 "strike", StringStrike, |
988 "sub", StringSub, | 986 "sub", StringSub, |
989 "sup", StringSup, | 987 "sup", StringSup, |
990 "toJSON", StringToJSON | 988 "toJSON", StringToJSON |
991 )); | 989 )); |
992 } | 990 } |
993 | 991 |
994 | 992 |
995 SetupString(); | 993 SetupString(); |
OLD | NEW |