Chromium Code Reviews| 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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 193 if (result !== null) lastMatchInfoOverride = null; | 193 if (result !== null) lastMatchInfoOverride = null; |
| 194 regexp.lastIndex = 0; | 194 regexp.lastIndex = 0; |
| 195 return result; | 195 return result; |
| 196 } | 196 } |
| 197 // Non-regexp argument. | 197 // Non-regexp argument. |
| 198 regexp = new $RegExp(regexp); | 198 regexp = new $RegExp(regexp); |
| 199 return RegExpExecNoTests(regexp, subject, 0); | 199 return RegExpExecNoTests(regexp, subject, 0); |
| 200 } | 200 } |
| 201 | 201 |
| 202 | 202 |
| 203 var NORMALIZATION_FORMS = ['NFC', 'NFD', 'NFKC', 'NFKD']; | |
| 204 | |
| 205 | |
| 206 // ECMA-262 v6, section 21.1.3.12 | |
| 207 // | |
| 208 // For now we do nothing, as proper normalization requires big tables. | |
| 209 // If Intl is enabled, then i18n.js will override it and provide the the | |
| 210 // proper functionality. | |
| 211 function StringNormalize(form) { | |
| 212 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { | |
|
mathias
2014/01/29 09:05:55
While this is correct, it might be better to just
| |
| 213 throw MakeTypeError("called_on_null_or_undefined", | |
| 214 ["String.prototype.localeCompare"]); | |
|
mathias
2014/01/29 09:05:55
s/localeCompare/normalize/
| |
| 215 } | |
| 216 | |
| 217 var form = form ? TO_STRING_INLINE(form) : 'NFC'; | |
| 218 var normalizationForm = NORMALIZATION_FORMS.indexOf(form); | |
| 219 if (normalizationForm === -1) { | |
| 220 throw new $RangeError('The normalization form should be one of ' | |
| 221 + NORMALIZATION_FORMS.join(', ') + '.'); | |
| 222 } | |
| 223 | |
| 224 return %_ValueOf(this); | |
| 225 } | |
| 226 | |
| 227 | |
| 203 // This has the same size as the lastMatchInfo array, and can be used for | 228 // This has the same size as the lastMatchInfo array, and can be used for |
| 204 // functions that expect that structure to be returned. It is used when the | 229 // functions that expect that structure to be returned. It is used when the |
| 205 // needle is a string rather than a regexp. In this case we can't update | 230 // needle is a string rather than a regexp. In this case we can't update |
| 206 // lastMatchArray without erroneously affecting the properties on the global | 231 // lastMatchArray without erroneously affecting the properties on the global |
| 207 // RegExp object. | 232 // RegExp object. |
| 208 var reusableMatchInfo = [2, "", "", -1, -1]; | 233 var reusableMatchInfo = [2, "", "", -1, -1]; |
| 209 | 234 |
| 210 | 235 |
| 211 // ECMA-262, section 15.5.4.11 | 236 // ECMA-262, section 15.5.4.11 |
| 212 function StringReplace(search, replace) { | 237 function StringReplace(search, replace) { |
| (...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 977 InstallFunctions($String.prototype, DONT_ENUM, $Array( | 1002 InstallFunctions($String.prototype, DONT_ENUM, $Array( |
| 978 "valueOf", StringValueOf, | 1003 "valueOf", StringValueOf, |
| 979 "toString", StringToString, | 1004 "toString", StringToString, |
| 980 "charAt", StringCharAt, | 1005 "charAt", StringCharAt, |
| 981 "charCodeAt", StringCharCodeAt, | 1006 "charCodeAt", StringCharCodeAt, |
| 982 "concat", StringConcat, | 1007 "concat", StringConcat, |
| 983 "indexOf", StringIndexOf, | 1008 "indexOf", StringIndexOf, |
| 984 "lastIndexOf", StringLastIndexOf, | 1009 "lastIndexOf", StringLastIndexOf, |
| 985 "localeCompare", StringLocaleCompare, | 1010 "localeCompare", StringLocaleCompare, |
| 986 "match", StringMatch, | 1011 "match", StringMatch, |
| 1012 "normalize", StringNormalize, | |
| 987 "replace", StringReplace, | 1013 "replace", StringReplace, |
| 988 "search", StringSearch, | 1014 "search", StringSearch, |
| 989 "slice", StringSlice, | 1015 "slice", StringSlice, |
| 990 "split", StringSplit, | 1016 "split", StringSplit, |
| 991 "substring", StringSubstring, | 1017 "substring", StringSubstring, |
| 992 "substr", StringSubstr, | 1018 "substr", StringSubstr, |
| 993 "toLowerCase", StringToLowerCase, | 1019 "toLowerCase", StringToLowerCase, |
| 994 "toLocaleLowerCase", StringToLocaleLowerCase, | 1020 "toLocaleLowerCase", StringToLocaleLowerCase, |
| 995 "toUpperCase", StringToUpperCase, | 1021 "toUpperCase", StringToUpperCase, |
| 996 "toLocaleUpperCase", StringToLocaleUpperCase, | 1022 "toLocaleUpperCase", StringToLocaleUpperCase, |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 1007 "fixed", StringFixed, | 1033 "fixed", StringFixed, |
| 1008 "italics", StringItalics, | 1034 "italics", StringItalics, |
| 1009 "small", StringSmall, | 1035 "small", StringSmall, |
| 1010 "strike", StringStrike, | 1036 "strike", StringStrike, |
| 1011 "sub", StringSub, | 1037 "sub", StringSub, |
| 1012 "sup", StringSup | 1038 "sup", StringSup |
| 1013 )); | 1039 )); |
| 1014 } | 1040 } |
| 1015 | 1041 |
| 1016 SetUpString(); | 1042 SetUpString(); |
| OLD | NEW |