| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 (function(global, utils) { | 5 (function(global, utils) { |
| 6 | 6 |
| 7 %CheckIsBootstrapping(); | 7 %CheckIsBootstrapping(); |
| 8 | 8 |
| 9 // ------------------------------------------------------------------- | 9 // ------------------------------------------------------------------- |
| 10 // Imports | 10 // Imports |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 var result = %_StringCharCodeAt(this, pos); | 74 var result = %_StringCharCodeAt(this, pos); |
| 75 if (!%_IsSmi(result)) { | 75 if (!%_IsSmi(result)) { |
| 76 result = %_StringCharCodeAt(TO_STRING(this), TO_INTEGER(pos)); | 76 result = %_StringCharCodeAt(TO_STRING(this), TO_INTEGER(pos)); |
| 77 } | 77 } |
| 78 return result; | 78 return result; |
| 79 } | 79 } |
| 80 | 80 |
| 81 | 81 |
| 82 // ECMA-262, section 15.5.4.6 | 82 // ECMA-262, section 15.5.4.6 |
| 83 function StringConcat(other /* and more */) { // length == 1 | 83 function StringConcat(other /* and more */) { // length == 1 |
| 84 "use strict"; |
| 84 CHECK_OBJECT_COERCIBLE(this, "String.prototype.concat"); | 85 CHECK_OBJECT_COERCIBLE(this, "String.prototype.concat"); |
| 85 var len = %_ArgumentsLength(); | 86 var s = TO_STRING(this); |
| 86 var this_as_string = TO_STRING(this); | 87 var len = arguments.length; |
| 87 if (len === 1) { | 88 for (var i = 0; i < len; ++i) { |
| 88 return this_as_string + TO_STRING(other); | 89 s = s + TO_STRING(arguments[i]); |
| 89 } | 90 } |
| 90 var parts = new InternalArray(len + 1); | 91 return s; |
| 91 parts[0] = this_as_string; | |
| 92 for (var i = 0; i < len; i++) { | |
| 93 var part = %_Arguments(i); | |
| 94 parts[i + 1] = TO_STRING(part); | |
| 95 } | |
| 96 return %StringBuilderConcat(parts, len + 1, ""); | |
| 97 } | 92 } |
| 98 | 93 |
| 99 | 94 |
| 100 // ECMA-262 section 15.5.4.7 | 95 // ECMA-262 section 15.5.4.7 |
| 101 function StringIndexOfJS(pattern /* position */) { // length == 1 | 96 function StringIndexOf(pattern, position) { // length == 1 |
| 102 CHECK_OBJECT_COERCIBLE(this, "String.prototype.indexOf"); | 97 CHECK_OBJECT_COERCIBLE(this, "String.prototype.indexOf"); |
| 103 | 98 |
| 104 var subject = TO_STRING(this); | 99 var subject = TO_STRING(this); |
| 105 pattern = TO_STRING(pattern); | 100 pattern = TO_STRING(pattern); |
| 106 var index = 0; | 101 var index = TO_INTEGER(position); |
| 107 if (%_ArgumentsLength() > 1) { | 102 if (index < 0) index = 0; |
| 108 index = %_Arguments(1); // position | 103 if (index > subject.length) index = subject.length; |
| 109 index = TO_INTEGER(index); | |
| 110 if (index < 0) index = 0; | |
| 111 if (index > subject.length) index = subject.length; | |
| 112 } | |
| 113 return %StringIndexOf(subject, pattern, index); | 104 return %StringIndexOf(subject, pattern, index); |
| 114 } | 105 } |
| 115 | 106 |
| 107 %FunctionSetLength(StringIndexOf, 1); |
| 108 |
| 116 | 109 |
| 117 // ECMA-262 section 15.5.4.8 | 110 // ECMA-262 section 15.5.4.8 |
| 118 function StringLastIndexOfJS(pat /* position */) { // length == 1 | 111 function StringLastIndexOf(pat, pos) { // length == 1 |
| 119 CHECK_OBJECT_COERCIBLE(this, "String.prototype.lastIndexOf"); | 112 CHECK_OBJECT_COERCIBLE(this, "String.prototype.lastIndexOf"); |
| 120 | 113 |
| 121 var sub = TO_STRING(this); | 114 var sub = TO_STRING(this); |
| 122 var subLength = sub.length; | 115 var subLength = sub.length; |
| 123 var pat = TO_STRING(pat); | 116 var pat = TO_STRING(pat); |
| 124 var patLength = pat.length; | 117 var patLength = pat.length; |
| 125 var index = subLength - patLength; | 118 var index = subLength - patLength; |
| 126 if (%_ArgumentsLength() > 1) { | 119 var position = TO_NUMBER(pos); |
| 127 var position = TO_NUMBER(%_Arguments(1)); | 120 if (!NUMBER_IS_NAN(position)) { |
| 128 if (!NUMBER_IS_NAN(position)) { | 121 position = TO_INTEGER(position); |
| 129 position = TO_INTEGER(position); | 122 if (position < 0) { |
| 130 if (position < 0) { | 123 position = 0; |
| 131 position = 0; | 124 } |
| 132 } | 125 if (position + patLength < subLength) { |
| 133 if (position + patLength < subLength) { | 126 index = position; |
| 134 index = position; | |
| 135 } | |
| 136 } | 127 } |
| 137 } | 128 } |
| 138 if (index < 0) { | 129 if (index < 0) { |
| 139 return -1; | 130 return -1; |
| 140 } | 131 } |
| 141 return %StringLastIndexOf(sub, pat, index); | 132 return %StringLastIndexOf(sub, pat, index); |
| 142 } | 133 } |
| 143 | 134 |
| 135 %FunctionSetLength(StringLastIndexOf, 1); |
| 136 |
| 144 | 137 |
| 145 // ECMA-262 section 15.5.4.9 | 138 // ECMA-262 section 15.5.4.9 |
| 146 // | 139 // |
| 147 // This function is implementation specific. For now, we do not | 140 // This function is implementation specific. For now, we do not |
| 148 // do anything locale specific. | 141 // do anything locale specific. |
| 149 function StringLocaleCompareJS(other) { | 142 function StringLocaleCompareJS(other) { |
| 150 CHECK_OBJECT_COERCIBLE(this, "String.prototype.localeCompare"); | 143 CHECK_OBJECT_COERCIBLE(this, "String.prototype.localeCompare"); |
| 151 | 144 |
| 152 return %StringLocaleCompare(TO_STRING(this), TO_STRING(other)); | 145 return %StringLocaleCompare(TO_STRING(this), TO_STRING(other)); |
| 153 } | 146 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 170 var regexp = new GlobalRegExp(pattern); | 163 var regexp = new GlobalRegExp(pattern); |
| 171 return RegExpExecNoTests(regexp, subject, 0); | 164 return RegExpExecNoTests(regexp, subject, 0); |
| 172 } | 165 } |
| 173 | 166 |
| 174 | 167 |
| 175 // ECMA-262 v6, section 21.1.3.12 | 168 // ECMA-262 v6, section 21.1.3.12 |
| 176 // | 169 // |
| 177 // For now we do nothing, as proper normalization requires big tables. | 170 // For now we do nothing, as proper normalization requires big tables. |
| 178 // If Intl is enabled, then i18n.js will override it and provide the the | 171 // If Intl is enabled, then i18n.js will override it and provide the the |
| 179 // proper functionality. | 172 // proper functionality. |
| 180 function StringNormalizeJS() { | 173 function StringNormalize(formArg) { // length == 0 |
| 181 CHECK_OBJECT_COERCIBLE(this, "String.prototype.normalize"); | 174 CHECK_OBJECT_COERCIBLE(this, "String.prototype.normalize"); |
| 182 var s = TO_STRING(this); | 175 var s = TO_STRING(this); |
| 183 | 176 |
| 184 var formArg = %_Arguments(0); | |
| 185 var form = IS_UNDEFINED(formArg) ? 'NFC' : TO_STRING(formArg); | 177 var form = IS_UNDEFINED(formArg) ? 'NFC' : TO_STRING(formArg); |
| 186 | 178 |
| 187 var NORMALIZATION_FORMS = ['NFC', 'NFD', 'NFKC', 'NFKD']; | 179 var NORMALIZATION_FORMS = ['NFC', 'NFD', 'NFKC', 'NFKD']; |
| 188 var normalizationForm = %_Call(ArrayIndexOf, NORMALIZATION_FORMS, form); | 180 var normalizationForm = %_Call(ArrayIndexOf, NORMALIZATION_FORMS, form); |
| 189 if (normalizationForm === -1) { | 181 if (normalizationForm === -1) { |
| 190 throw MakeRangeError(kNormalizationForm, | 182 throw MakeRangeError(kNormalizationForm, |
| 191 %_Call(ArrayJoin, NORMALIZATION_FORMS, ', ')); | 183 %_Call(ArrayJoin, NORMALIZATION_FORMS, ', ')); |
| 192 } | 184 } |
| 193 | 185 |
| 194 return s; | 186 return s; |
| 195 } | 187 } |
| 196 | 188 |
| 189 %FunctionSetLength(StringNormalize, 0); |
| 190 |
| 197 | 191 |
| 198 // This has the same size as the RegExpLastMatchInfo array, and can be used | 192 // This has the same size as the RegExpLastMatchInfo array, and can be used |
| 199 // for functions that expect that structure to be returned. It is used when | 193 // for functions that expect that structure to be returned. It is used when |
| 200 // the needle is a string rather than a regexp. In this case we can't update | 194 // the needle is a string rather than a regexp. In this case we can't update |
| 201 // lastMatchArray without erroneously affecting the properties on the global | 195 // lastMatchArray without erroneously affecting the properties on the global |
| 202 // RegExp object. | 196 // RegExp object. |
| 203 var reusableMatchInfo = [2, "", "", -1, -1]; | 197 var reusableMatchInfo = [2, "", "", -1, -1]; |
| 204 | 198 |
| 205 | 199 |
| 206 // ES6, section 21.1.3.14 | 200 // ES6, section 21.1.3.14 |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 function StringTrimRight() { | 554 function StringTrimRight() { |
| 561 CHECK_OBJECT_COERCIBLE(this, "String.prototype.trimRight"); | 555 CHECK_OBJECT_COERCIBLE(this, "String.prototype.trimRight"); |
| 562 | 556 |
| 563 return %StringTrim(TO_STRING(this), false, true); | 557 return %StringTrim(TO_STRING(this), false, true); |
| 564 } | 558 } |
| 565 | 559 |
| 566 | 560 |
| 567 // ECMA-262, section 15.5.3.2 | 561 // ECMA-262, section 15.5.3.2 |
| 568 function StringFromCharCode(code) { | 562 function StringFromCharCode(code) { |
| 569 var n = %_ArgumentsLength(); | 563 var n = %_ArgumentsLength(); |
| 570 if (n == 1) return %_StringCharFromCode(code & 0xffff); | 564 if (n === 1) return %_StringCharFromCode(code & 0xffff); |
| 571 | 565 |
| 572 var one_byte = %NewString(n, NEW_ONE_BYTE_STRING); | 566 var one_byte = %NewString(n, NEW_ONE_BYTE_STRING); |
| 573 var i; | 567 var i; |
| 574 for (i = 0; i < n; i++) { | 568 for (i = 0; i < n; i++) { |
| 575 code = %_Arguments(i) & 0xffff; | 569 code = %_Arguments(i) & 0xffff; |
| 576 if (code > 0xff) break; | 570 if (code > 0xff) break; |
| 577 %_OneByteSeqStringSetChar(i, code, one_byte); | 571 %_OneByteSeqStringSetChar(i, code, one_byte); |
| 578 } | 572 } |
| 579 if (i == n) return one_byte; | 573 if (i == n) return one_byte; |
| 580 one_byte = %TruncateString(one_byte, i); | 574 one_byte = %TruncateString(one_byte, i); |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 while (true) { | 703 while (true) { |
| 710 if (n & 1) r += s; | 704 if (n & 1) r += s; |
| 711 n >>= 1; | 705 n >>= 1; |
| 712 if (n === 0) return r; | 706 if (n === 0) return r; |
| 713 s += s; | 707 s += s; |
| 714 } | 708 } |
| 715 } | 709 } |
| 716 | 710 |
| 717 | 711 |
| 718 // ES6 draft 04-05-14, section 21.1.3.18 | 712 // ES6 draft 04-05-14, section 21.1.3.18 |
| 719 function StringStartsWith(searchString /* position */) { // length == 1 | 713 function StringStartsWith(searchString, position) { // length == 1 |
| 720 CHECK_OBJECT_COERCIBLE(this, "String.prototype.startsWith"); | 714 CHECK_OBJECT_COERCIBLE(this, "String.prototype.startsWith"); |
| 721 | 715 |
| 722 var s = TO_STRING(this); | 716 var s = TO_STRING(this); |
| 723 | 717 |
| 724 if (IS_REGEXP(searchString)) { | 718 if (IS_REGEXP(searchString)) { |
| 725 throw MakeTypeError(kFirstArgumentNotRegExp, "String.prototype.startsWith"); | 719 throw MakeTypeError(kFirstArgumentNotRegExp, "String.prototype.startsWith"); |
| 726 } | 720 } |
| 727 | 721 |
| 728 var ss = TO_STRING(searchString); | 722 var ss = TO_STRING(searchString); |
| 729 var pos = 0; | 723 var pos = TO_INTEGER(position); |
| 730 if (%_ArgumentsLength() > 1) { | |
| 731 var arg = %_Arguments(1); // position | |
| 732 if (!IS_UNDEFINED(arg)) { | |
| 733 pos = TO_INTEGER(arg); | |
| 734 } | |
| 735 } | |
| 736 | 724 |
| 737 var s_len = s.length; | 725 var s_len = s.length; |
| 738 var start = MinSimple(MaxSimple(pos, 0), s_len); | 726 var start = MinSimple(MaxSimple(pos, 0), s_len); |
| 739 var ss_len = ss.length; | 727 var ss_len = ss.length; |
| 740 if (ss_len + start > s_len) { | 728 if (ss_len + start > s_len) { |
| 741 return false; | 729 return false; |
| 742 } | 730 } |
| 743 | 731 |
| 744 return %_SubString(s, start, start + ss_len) === ss; | 732 return %_SubString(s, start, start + ss_len) === ss; |
| 745 } | 733 } |
| 746 | 734 |
| 735 %FunctionSetLength(StringStartsWith, 1); |
| 736 |
| 747 | 737 |
| 748 // ES6 draft 04-05-14, section 21.1.3.7 | 738 // ES6 draft 04-05-14, section 21.1.3.7 |
| 749 function StringEndsWith(searchString /* position */) { // length == 1 | 739 function StringEndsWith(searchString, position) { // length == 1 |
| 750 CHECK_OBJECT_COERCIBLE(this, "String.prototype.endsWith"); | 740 CHECK_OBJECT_COERCIBLE(this, "String.prototype.endsWith"); |
| 751 | 741 |
| 752 var s = TO_STRING(this); | 742 var s = TO_STRING(this); |
| 753 | 743 |
| 754 if (IS_REGEXP(searchString)) { | 744 if (IS_REGEXP(searchString)) { |
| 755 throw MakeTypeError(kFirstArgumentNotRegExp, "String.prototype.endsWith"); | 745 throw MakeTypeError(kFirstArgumentNotRegExp, "String.prototype.endsWith"); |
| 756 } | 746 } |
| 757 | 747 |
| 758 var ss = TO_STRING(searchString); | 748 var ss = TO_STRING(searchString); |
| 759 var s_len = s.length; | 749 var s_len = s.length; |
| 760 var pos = s_len; | 750 var pos = !IS_UNDEFINED(position) ? TO_INTEGER(position) : s_len |
| 761 if (%_ArgumentsLength() > 1) { | |
| 762 var arg = %_Arguments(1); // position | |
| 763 if (!IS_UNDEFINED(arg)) { | |
| 764 pos = TO_INTEGER(arg); | |
| 765 } | |
| 766 } | |
| 767 | 751 |
| 768 var end = MinSimple(MaxSimple(pos, 0), s_len); | 752 var end = MinSimple(MaxSimple(pos, 0), s_len); |
| 769 var ss_len = ss.length; | 753 var ss_len = ss.length; |
| 770 var start = end - ss_len; | 754 var start = end - ss_len; |
| 771 if (start < 0) { | 755 if (start < 0) { |
| 772 return false; | 756 return false; |
| 773 } | 757 } |
| 774 | 758 |
| 775 return %_SubString(s, start, start + ss_len) === ss; | 759 return %_SubString(s, start, start + ss_len) === ss; |
| 776 } | 760 } |
| 777 | 761 |
| 762 %FunctionSetLength(StringEndsWith, 1); |
| 763 |
| 778 | 764 |
| 779 // ES6 draft 04-05-14, section 21.1.3.6 | 765 // ES6 draft 04-05-14, section 21.1.3.6 |
| 780 function StringIncludes(searchString /* position */) { // length == 1 | 766 function StringIncludes(searchString, position) { // length == 1 |
| 781 CHECK_OBJECT_COERCIBLE(this, "String.prototype.includes"); | 767 CHECK_OBJECT_COERCIBLE(this, "String.prototype.includes"); |
| 782 | 768 |
| 783 var string = TO_STRING(this); | 769 var string = TO_STRING(this); |
| 784 | 770 |
| 785 if (IS_REGEXP(searchString)) { | 771 if (IS_REGEXP(searchString)) { |
| 786 throw MakeTypeError(kFirstArgumentNotRegExp, "String.prototype.includes"); | 772 throw MakeTypeError(kFirstArgumentNotRegExp, "String.prototype.includes"); |
| 787 } | 773 } |
| 788 | 774 |
| 789 searchString = TO_STRING(searchString); | 775 searchString = TO_STRING(searchString); |
| 790 var pos = 0; | 776 var pos = TO_INTEGER(position); |
| 791 if (%_ArgumentsLength() > 1) { | |
| 792 pos = %_Arguments(1); // position | |
| 793 pos = TO_INTEGER(pos); | |
| 794 } | |
| 795 | 777 |
| 796 var stringLength = string.length; | 778 var stringLength = string.length; |
| 797 if (pos < 0) pos = 0; | 779 if (pos < 0) pos = 0; |
| 798 if (pos > stringLength) pos = stringLength; | 780 if (pos > stringLength) pos = stringLength; |
| 799 var searchStringLength = searchString.length; | 781 var searchStringLength = searchString.length; |
| 800 | 782 |
| 801 if (searchStringLength + pos > stringLength) { | 783 if (searchStringLength + pos > stringLength) { |
| 802 return false; | 784 return false; |
| 803 } | 785 } |
| 804 | 786 |
| 805 return %StringIndexOf(string, searchString, pos) !== -1; | 787 return %StringIndexOf(string, searchString, pos) !== -1; |
| 806 } | 788 } |
| 807 | 789 |
| 790 %FunctionSetLength(StringIncludes, 1); |
| 791 |
| 808 | 792 |
| 809 // ES6 Draft 05-22-2014, section 21.1.3.3 | 793 // ES6 Draft 05-22-2014, section 21.1.3.3 |
| 810 function StringCodePointAt(pos) { | 794 function StringCodePointAt(pos) { |
| 811 CHECK_OBJECT_COERCIBLE(this, "String.prototype.codePointAt"); | 795 CHECK_OBJECT_COERCIBLE(this, "String.prototype.codePointAt"); |
| 812 | 796 |
| 813 var string = TO_STRING(this); | 797 var string = TO_STRING(this); |
| 814 var size = string.length; | 798 var size = string.length; |
| 815 pos = TO_INTEGER(pos); | 799 pos = TO_INTEGER(pos); |
| 816 if (pos < 0 || pos >= size) { | 800 if (pos < 0 || pos >= size) { |
| 817 return UNDEFINED; | 801 return UNDEFINED; |
| 818 } | 802 } |
| 819 var first = %_StringCharCodeAt(string, pos); | 803 var first = %_StringCharCodeAt(string, pos); |
| 820 if (first < 0xD800 || first > 0xDBFF || pos + 1 == size) { | 804 if (first < 0xD800 || first > 0xDBFF || pos + 1 == size) { |
| 821 return first; | 805 return first; |
| 822 } | 806 } |
| 823 var second = %_StringCharCodeAt(string, pos + 1); | 807 var second = %_StringCharCodeAt(string, pos + 1); |
| 824 if (second < 0xDC00 || second > 0xDFFF) { | 808 if (second < 0xDC00 || second > 0xDFFF) { |
| 825 return first; | 809 return first; |
| 826 } | 810 } |
| 827 return (first - 0xD800) * 0x400 + second + 0x2400; | 811 return (first - 0xD800) * 0x400 + second + 0x2400; |
| 828 } | 812 } |
| 829 | 813 |
| 830 | 814 |
| 831 // ES6 Draft 05-22-2014, section 21.1.2.2 | 815 // ES6 Draft 05-22-2014, section 21.1.2.2 |
| 832 function StringFromCodePoint(_) { // length = 1 | 816 function StringFromCodePoint(_) { // length = 1 |
| 817 "use strict"; |
| 833 var code; | 818 var code; |
| 834 var length = %_ArgumentsLength(); | 819 var length = arguments.length; |
| 835 var index; | 820 var index; |
| 836 var result = ""; | 821 var result = ""; |
| 837 for (index = 0; index < length; index++) { | 822 for (index = 0; index < length; index++) { |
| 838 code = %_Arguments(index); | 823 code = arguments[index]; |
| 839 if (!%_IsSmi(code)) { | 824 if (!%_IsSmi(code)) { |
| 840 code = TO_NUMBER(code); | 825 code = TO_NUMBER(code); |
| 841 } | 826 } |
| 842 if (code < 0 || code > 0x10FFFF || code !== TO_INTEGER(code)) { | 827 if (code < 0 || code > 0x10FFFF || code !== TO_INTEGER(code)) { |
| 843 throw MakeRangeError(kInvalidCodePoint, code); | 828 throw MakeRangeError(kInvalidCodePoint, code); |
| 844 } | 829 } |
| 845 if (code <= 0xFFFF) { | 830 if (code <= 0xFFFF) { |
| 846 result += %_StringCharFromCode(code); | 831 result += %_StringCharFromCode(code); |
| 847 } else { | 832 } else { |
| 848 code -= 0x10000; | 833 code -= 0x10000; |
| 849 result += %_StringCharFromCode((code >>> 10) & 0x3FF | 0xD800); | 834 result += %_StringCharFromCode((code >>> 10) & 0x3FF | 0xD800); |
| 850 result += %_StringCharFromCode(code & 0x3FF | 0xDC00); | 835 result += %_StringCharFromCode(code & 0x3FF | 0xDC00); |
| 851 } | 836 } |
| 852 } | 837 } |
| 853 return result; | 838 return result; |
| 854 } | 839 } |
| 855 | 840 |
| 856 | 841 |
| 857 // ------------------------------------------------------------------- | 842 // ------------------------------------------------------------------- |
| 858 // String methods related to templates | 843 // String methods related to templates |
| 859 | 844 |
| 860 // ES6 Draft 03-17-2015, section 21.1.2.4 | 845 // ES6 Draft 03-17-2015, section 21.1.2.4 |
| 861 function StringRaw(callSite) { | 846 function StringRaw(callSite) { |
| 862 // TODO(caitp): Use rest parameters when implemented | 847 "use strict"; |
| 863 var numberOfSubstitutions = %_ArgumentsLength(); | 848 var numberOfSubstitutions = arguments.length; |
| 864 var cooked = TO_OBJECT(callSite); | 849 var cooked = TO_OBJECT(callSite); |
| 865 var raw = TO_OBJECT(cooked.raw); | 850 var raw = TO_OBJECT(cooked.raw); |
| 866 var literalSegments = TO_LENGTH(raw.length); | 851 var literalSegments = TO_LENGTH(raw.length); |
| 867 if (literalSegments <= 0) return ""; | 852 if (literalSegments <= 0) return ""; |
| 868 | 853 |
| 869 var result = TO_STRING(raw[0]); | 854 var result = TO_STRING(raw[0]); |
| 870 | 855 |
| 871 for (var i = 1; i < literalSegments; ++i) { | 856 for (var i = 1; i < literalSegments; ++i) { |
| 872 if (i < numberOfSubstitutions) { | 857 if (i < numberOfSubstitutions) { |
| 873 result += TO_STRING(%_Arguments(i)); | 858 result += TO_STRING(arguments[i]); |
| 874 } | 859 } |
| 875 result += TO_STRING(raw[i]); | 860 result += TO_STRING(raw[i]); |
| 876 } | 861 } |
| 877 | 862 |
| 878 return result; | 863 return result; |
| 879 } | 864 } |
| 880 | 865 |
| 881 // ------------------------------------------------------------------- | 866 // ------------------------------------------------------------------- |
| 882 | 867 |
| 883 // Set the String function and constructor. | 868 // Set the String function and constructor. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 897 // Set up the non-enumerable functions on the String prototype object. | 882 // Set up the non-enumerable functions on the String prototype object. |
| 898 utils.InstallFunctions(GlobalString.prototype, DONT_ENUM, [ | 883 utils.InstallFunctions(GlobalString.prototype, DONT_ENUM, [ |
| 899 "valueOf", StringValueOf, | 884 "valueOf", StringValueOf, |
| 900 "toString", StringToString, | 885 "toString", StringToString, |
| 901 "charAt", StringCharAtJS, | 886 "charAt", StringCharAtJS, |
| 902 "charCodeAt", StringCharCodeAtJS, | 887 "charCodeAt", StringCharCodeAtJS, |
| 903 "codePointAt", StringCodePointAt, | 888 "codePointAt", StringCodePointAt, |
| 904 "concat", StringConcat, | 889 "concat", StringConcat, |
| 905 "endsWith", StringEndsWith, | 890 "endsWith", StringEndsWith, |
| 906 "includes", StringIncludes, | 891 "includes", StringIncludes, |
| 907 "indexOf", StringIndexOfJS, | 892 "indexOf", StringIndexOf, |
| 908 "lastIndexOf", StringLastIndexOfJS, | 893 "lastIndexOf", StringLastIndexOf, |
| 909 "localeCompare", StringLocaleCompareJS, | 894 "localeCompare", StringLocaleCompareJS, |
| 910 "match", StringMatchJS, | 895 "match", StringMatchJS, |
| 911 "normalize", StringNormalizeJS, | 896 "normalize", StringNormalize, |
| 912 "repeat", StringRepeat, | 897 "repeat", StringRepeat, |
| 913 "replace", StringReplace, | 898 "replace", StringReplace, |
| 914 "search", StringSearch, | 899 "search", StringSearch, |
| 915 "slice", StringSlice, | 900 "slice", StringSlice, |
| 916 "split", StringSplitJS, | 901 "split", StringSplitJS, |
| 917 "substring", StringSubstring, | 902 "substring", StringSubstring, |
| 918 "substr", StringSubstr, | 903 "substr", StringSubstr, |
| 919 "startsWith", StringStartsWith, | 904 "startsWith", StringStartsWith, |
| 920 "toLowerCase", StringToLowerCaseJS, | 905 "toLowerCase", StringToLowerCaseJS, |
| 921 "toLocaleLowerCase", StringToLocaleLowerCase, | 906 "toLocaleLowerCase", StringToLocaleLowerCase, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 939 "sub", StringSub, | 924 "sub", StringSub, |
| 940 "sup", StringSup | 925 "sup", StringSup |
| 941 ]); | 926 ]); |
| 942 | 927 |
| 943 // ------------------------------------------------------------------- | 928 // ------------------------------------------------------------------- |
| 944 // Exports | 929 // Exports |
| 945 | 930 |
| 946 utils.Export(function(to) { | 931 utils.Export(function(to) { |
| 947 to.ExpandReplacement = ExpandReplacement; | 932 to.ExpandReplacement = ExpandReplacement; |
| 948 to.StringCharAt = StringCharAtJS; | 933 to.StringCharAt = StringCharAtJS; |
| 949 to.StringIndexOf = StringIndexOfJS; | 934 to.StringIndexOf = StringIndexOf; |
| 950 to.StringLastIndexOf = StringLastIndexOfJS; | 935 to.StringLastIndexOf = StringLastIndexOf; |
| 951 to.StringMatch = StringMatchJS; | 936 to.StringMatch = StringMatchJS; |
| 952 to.StringReplace = StringReplace; | 937 to.StringReplace = StringReplace; |
| 953 to.StringSlice = StringSlice; | 938 to.StringSlice = StringSlice; |
| 954 to.StringSplit = StringSplitJS; | 939 to.StringSplit = StringSplitJS; |
| 955 to.StringSubstr = StringSubstr; | 940 to.StringSubstr = StringSubstr; |
| 956 to.StringSubstring = StringSubstring; | 941 to.StringSubstring = StringSubstring; |
| 957 }); | 942 }); |
| 958 | 943 |
| 959 }) | 944 }) |
| OLD | NEW |