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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
179 if (result !== null) lastMatchInfoOverride = null; | 179 if (result !== null) lastMatchInfoOverride = null; |
180 regexp.lastIndex = 0; | 180 regexp.lastIndex = 0; |
181 return result; | 181 return result; |
182 } | 182 } |
183 // Non-regexp argument. | 183 // Non-regexp argument. |
184 regexp = new $RegExp(regexp); | 184 regexp = new $RegExp(regexp); |
185 return RegExpExecNoTests(regexp, subject, 0); | 185 return RegExpExecNoTests(regexp, subject, 0); |
186 } | 186 } |
187 | 187 |
188 | 188 |
189 var NORMALIZATION_FORMS = ['NFC', 'NFD', 'NFKC', 'NFKD']; | |
190 | |
191 | |
192 // ECMA-262 v6, section 21.1.3.12 | |
193 // | |
194 // For now we do nothing, as proper normalization requires big tables. | |
195 // If Intl is enabled, then i18n.js will override it and provide the the | |
196 // proper functionality. | |
197 function StringNormalize(form) { | |
198 CHECK_OBJECT_COERCIBLE(this, "String.prototype.normalize"); | |
199 | |
200 var form = form ? TO_STRING_INLINE(form) : 'NFC'; | |
201 var normalizationForm = NORMALIZATION_FORMS.indexOf(form); | |
arv (Not doing code reviews)
2014/04/10 18:20:10
same here?
mnita
2014/04/10 21:20:30
Done.
| |
202 if (normalizationForm === -1) { | |
203 throw new $RangeError('The normalization form should be one of ' | |
204 + NORMALIZATION_FORMS.join(', ') + '.'); | |
arv (Not doing code reviews)
2014/04/10 18:20:10
and here
mnita
2014/04/10 21:20:30
Done.
| |
205 } | |
206 | |
207 return %_ValueOf(this); | |
208 } | |
209 | |
210 | |
189 // This has the same size as the lastMatchInfo array, and can be used for | 211 // This has the same size as the lastMatchInfo array, and can be used for |
190 // functions that expect that structure to be returned. It is used when the | 212 // functions that expect that structure to be returned. It is used when the |
191 // needle is a string rather than a regexp. In this case we can't update | 213 // needle is a string rather than a regexp. In this case we can't update |
192 // lastMatchArray without erroneously affecting the properties on the global | 214 // lastMatchArray without erroneously affecting the properties on the global |
193 // RegExp object. | 215 // RegExp object. |
194 var reusableMatchInfo = [2, "", "", -1, -1]; | 216 var reusableMatchInfo = [2, "", "", -1, -1]; |
195 | 217 |
196 | 218 |
197 // ECMA-262, section 15.5.4.11 | 219 // ECMA-262, section 15.5.4.11 |
198 function StringReplace(search, replace) { | 220 function StringReplace(search, replace) { |
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
935 InstallFunctions($String.prototype, DONT_ENUM, $Array( | 957 InstallFunctions($String.prototype, DONT_ENUM, $Array( |
936 "valueOf", StringValueOf, | 958 "valueOf", StringValueOf, |
937 "toString", StringToString, | 959 "toString", StringToString, |
938 "charAt", StringCharAt, | 960 "charAt", StringCharAt, |
939 "charCodeAt", StringCharCodeAt, | 961 "charCodeAt", StringCharCodeAt, |
940 "concat", StringConcat, | 962 "concat", StringConcat, |
941 "indexOf", StringIndexOf, | 963 "indexOf", StringIndexOf, |
942 "lastIndexOf", StringLastIndexOf, | 964 "lastIndexOf", StringLastIndexOf, |
943 "localeCompare", StringLocaleCompare, | 965 "localeCompare", StringLocaleCompare, |
944 "match", StringMatch, | 966 "match", StringMatch, |
967 "normalize", StringNormalize, | |
945 "replace", StringReplace, | 968 "replace", StringReplace, |
946 "search", StringSearch, | 969 "search", StringSearch, |
947 "slice", StringSlice, | 970 "slice", StringSlice, |
948 "split", StringSplit, | 971 "split", StringSplit, |
949 "substring", StringSubstring, | 972 "substring", StringSubstring, |
950 "substr", StringSubstr, | 973 "substr", StringSubstr, |
951 "toLowerCase", StringToLowerCase, | 974 "toLowerCase", StringToLowerCase, |
952 "toLocaleLowerCase", StringToLocaleLowerCase, | 975 "toLocaleLowerCase", StringToLocaleLowerCase, |
953 "toUpperCase", StringToUpperCase, | 976 "toUpperCase", StringToUpperCase, |
954 "toLocaleUpperCase", StringToLocaleUpperCase, | 977 "toLocaleUpperCase", StringToLocaleUpperCase, |
(...skipping 10 matching lines...) Expand all Loading... | |
965 "fixed", StringFixed, | 988 "fixed", StringFixed, |
966 "italics", StringItalics, | 989 "italics", StringItalics, |
967 "small", StringSmall, | 990 "small", StringSmall, |
968 "strike", StringStrike, | 991 "strike", StringStrike, |
969 "sub", StringSub, | 992 "sub", StringSub, |
970 "sup", StringSup | 993 "sup", StringSup |
971 )); | 994 )); |
972 } | 995 } |
973 | 996 |
974 SetUpString(); | 997 SetUpString(); |
OLD | NEW |