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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 } | 80 } |
81 if (index < 0) { | 81 if (index < 0) { |
82 return -1; | 82 return -1; |
83 } | 83 } |
84 return %StringLastIndexOf(sub, pat, index); | 84 return %StringLastIndexOf(sub, pat, index); |
85 } | 85 } |
86 | 86 |
87 %FunctionSetLength(StringLastIndexOf, 1); | 87 %FunctionSetLength(StringLastIndexOf, 1); |
88 | 88 |
89 | 89 |
90 // ECMA-262 section 15.5.4.9 | |
91 // | |
92 // This function is implementation specific. For now, we do not | |
93 // do anything locale specific. | |
94 function StringLocaleCompareJS(other) { | |
95 CHECK_OBJECT_COERCIBLE(this, "String.prototype.localeCompare"); | |
96 | |
97 return %StringLocaleCompare(TO_STRING(this), TO_STRING(other)); | |
98 } | |
99 | |
100 | |
101 // ES6 21.1.3.11. | 90 // ES6 21.1.3.11. |
102 function StringMatchJS(pattern) { | 91 function StringMatchJS(pattern) { |
103 CHECK_OBJECT_COERCIBLE(this, "String.prototype.match"); | 92 CHECK_OBJECT_COERCIBLE(this, "String.prototype.match"); |
104 | 93 |
105 if (!IS_NULL_OR_UNDEFINED(pattern)) { | 94 if (!IS_NULL_OR_UNDEFINED(pattern)) { |
106 var matcher = pattern[matchSymbol]; | 95 var matcher = pattern[matchSymbol]; |
107 if (!IS_UNDEFINED(matcher)) { | 96 if (!IS_UNDEFINED(matcher)) { |
108 return %_Call(matcher, pattern, this); | 97 return %_Call(matcher, pattern, this); |
109 } | 98 } |
110 } | 99 } |
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
707 ]); | 696 ]); |
708 | 697 |
709 // Set up the non-enumerable functions on the String prototype object. | 698 // Set up the non-enumerable functions on the String prototype object. |
710 utils.InstallFunctions(GlobalString.prototype, DONT_ENUM, [ | 699 utils.InstallFunctions(GlobalString.prototype, DONT_ENUM, [ |
711 "codePointAt", StringCodePointAt, | 700 "codePointAt", StringCodePointAt, |
712 "concat", StringConcat, | 701 "concat", StringConcat, |
713 "endsWith", StringEndsWith, | 702 "endsWith", StringEndsWith, |
714 "includes", StringIncludes, | 703 "includes", StringIncludes, |
715 "indexOf", StringIndexOf, | 704 "indexOf", StringIndexOf, |
716 "lastIndexOf", StringLastIndexOf, | 705 "lastIndexOf", StringLastIndexOf, |
717 "localeCompare", StringLocaleCompareJS, | |
718 "match", StringMatchJS, | 706 "match", StringMatchJS, |
719 "repeat", StringRepeat, | 707 "repeat", StringRepeat, |
720 "replace", StringReplace, | 708 "replace", StringReplace, |
721 "search", StringSearch, | 709 "search", StringSearch, |
722 "slice", StringSlice, | 710 "slice", StringSlice, |
723 "split", StringSplitJS, | 711 "split", StringSplitJS, |
724 "substring", StringSubstring, | 712 "substring", StringSubstring, |
725 "substr", StringSubstr, | 713 "substr", StringSubstr, |
726 "startsWith", StringStartsWith, | 714 "startsWith", StringStartsWith, |
727 "toLowerCase", StringToLowerCaseJS, | 715 "toLowerCase", StringToLowerCaseJS, |
(...skipping 25 matching lines...) Expand all Loading... |
753 to.StringLastIndexOf = StringLastIndexOf; | 741 to.StringLastIndexOf = StringLastIndexOf; |
754 to.StringMatch = StringMatchJS; | 742 to.StringMatch = StringMatchJS; |
755 to.StringReplace = StringReplace; | 743 to.StringReplace = StringReplace; |
756 to.StringSlice = StringSlice; | 744 to.StringSlice = StringSlice; |
757 to.StringSplit = StringSplitJS; | 745 to.StringSplit = StringSplitJS; |
758 to.StringSubstr = StringSubstr; | 746 to.StringSubstr = StringSubstr; |
759 to.StringSubstring = StringSubstring; | 747 to.StringSubstring = StringSubstring; |
760 }); | 748 }); |
761 | 749 |
762 }) | 750 }) |
OLD | NEW |