OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
650 if (length === 0) { | 650 if (length === 0) { |
651 if (DoRegExpExec(separator, subject, 0, 0) != null) { | 651 if (DoRegExpExec(separator, subject, 0, 0) != null) { |
652 return []; | 652 return []; |
653 } | 653 } |
654 return [subject]; | 654 return [subject]; |
655 } | 655 } |
656 | 656 |
657 var currentIndex = 0; | 657 var currentIndex = 0; |
658 var startIndex = 0; | 658 var startIndex = 0; |
659 var startMatch = 0; | 659 var startMatch = 0; |
660 var result = []; | 660 var result = new InternalArray(); |
661 | 661 |
662 outer_loop: | 662 outer_loop: |
663 while (true) { | 663 while (true) { |
664 | 664 |
665 if (startIndex === length) { | 665 if (startIndex === length) { |
666 result.push(%_SubString(subject, currentIndex, length)); | 666 result.push(%_SubString(subject, currentIndex, length)); |
667 break; | 667 break; |
668 } | 668 } |
669 | 669 |
670 var matchInfo = DoRegExpExec(separator, subject, startIndex); | 670 var matchInfo = DoRegExpExec(separator, subject, startIndex); |
(...skipping 20 matching lines...) Expand all Loading... |
691 if (end != -1) { | 691 if (end != -1) { |
692 result.push(%_SubString(subject, start, end)); | 692 result.push(%_SubString(subject, start, end)); |
693 } else { | 693 } else { |
694 result.push(void 0); | 694 result.push(void 0); |
695 } | 695 } |
696 if (result.length === limit) break outer_loop; | 696 if (result.length === limit) break outer_loop; |
697 } | 697 } |
698 | 698 |
699 startIndex = currentIndex = endIndex; | 699 startIndex = currentIndex = endIndex; |
700 } | 700 } |
701 return result; | 701 return %MoveArrayContents(result, []); |
702 } | 702 } |
703 | 703 |
704 | 704 |
705 // ECMA-262 section 15.5.4.15 | 705 // ECMA-262 section 15.5.4.15 |
706 function StringSubstring(start, end) { | 706 function StringSubstring(start, end) { |
707 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { | 707 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { |
708 throw MakeTypeError("called_on_null_or_undefined", | 708 throw MakeTypeError("called_on_null_or_undefined", |
709 ["String.prototype.subString"]); | 709 ["String.prototype.subString"]); |
710 } | 710 } |
711 var s = TO_STRING_INLINE(this); | 711 var s = TO_STRING_INLINE(this); |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1000 "fixed", StringFixed, | 1000 "fixed", StringFixed, |
1001 "italics", StringItalics, | 1001 "italics", StringItalics, |
1002 "small", StringSmall, | 1002 "small", StringSmall, |
1003 "strike", StringStrike, | 1003 "strike", StringStrike, |
1004 "sub", StringSub, | 1004 "sub", StringSub, |
1005 "sup", StringSup | 1005 "sup", StringSup |
1006 )); | 1006 )); |
1007 } | 1007 } |
1008 | 1008 |
1009 SetUpString(); | 1009 SetUpString(); |
OLD | NEW |