Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(180)

Unified Diff: src/string.js

Issue 155723005: A64: Synchronize with r19001. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/runtime.cc ('k') | src/stub-cache.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/string.js
diff --git a/src/string.js b/src/string.js
index 8e4b896eae5492bab3c1efb5a7222a4c6b9be654..74230c986411247d7d8f5dfdea869a1efff5c49e 100644
--- a/src/string.js
+++ b/src/string.js
@@ -186,6 +186,28 @@ function StringMatch(regexp) {
}
+var NORMALIZATION_FORMS = ['NFC', 'NFD', 'NFKC', 'NFKD'];
+
+
+// ECMA-262 v6, section 21.1.3.12
+//
+// For now we do nothing, as proper normalization requires big tables.
+// If Intl is enabled, then i18n.js will override it and provide the the
+// proper functionality.
+function StringNormalize(form) {
+ CHECK_OBJECT_COERCIBLE(this, "String.prototype.normalize");
+
+ var form = form ? TO_STRING_INLINE(form) : 'NFC';
+ var normalizationForm = NORMALIZATION_FORMS.indexOf(form);
+ if (normalizationForm === -1) {
+ throw new $RangeError('The normalization form should be one of '
+ + NORMALIZATION_FORMS.join(', ') + '.');
+ }
+
+ return %_ValueOf(this);
+}
+
+
// This has the same size as the lastMatchInfo array, and can be used for
// functions that expect that structure to be returned. It is used when the
// needle is a string rather than a regexp. In this case we can't update
@@ -942,6 +964,7 @@ function SetUpString() {
"lastIndexOf", StringLastIndexOf,
"localeCompare", StringLocaleCompare,
"match", StringMatch,
+ "normalize", StringNormalize,
"replace", StringReplace,
"search", StringSearch,
"slice", StringSlice,
« no previous file with comments | « src/runtime.cc ('k') | src/stub-cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698