Index: src/builtins/builtins-string.cc |
diff --git a/src/builtins/builtins-string.cc b/src/builtins/builtins-string.cc |
index d38f6b069d50f5e751d7dfb3147f602a25b2d4f6..612b70a9c696977ee95f70ad0dd5d01fb2bded40 100644 |
--- a/src/builtins/builtins-string.cc |
+++ b/src/builtins/builtins-string.cc |
@@ -477,6 +477,37 @@ void Builtins::Generate_StringPrototypeCharCodeAt( |
assembler->Return(result); |
} |
+// ECMA-262 v6, section 21.1.3.12 String.prototype.normalize ( [form] ) |
+// |
+// 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. |
+BUILTIN(StringPrototypeNormalize) { |
+ HandleScope handle_scope(isolate); |
+ TO_THIS_STRING(string, "String.prototype.trim"); |
Franzi
2016/09/09 12:51:04
trim?
|
+ |
+ Handle<String> form; |
+ |
+ if (args.atOrUndefined(isolate, 1)->IsUndefined(isolate)) { |
+ return *string; |
+ } |
+ MaybeHandle<String> maybe_form(Object::ToString(isolate, args.at<Object>(1))); |
Benedikt Meurer
2016/09/08 04:41:30
This is not correct, as the ToString can throw and
petermarshall
2016/09/09 11:41:07
Done.
|
+ maybe_form.ToHandle(&form); |
+ |
+ if (!(form->Equals(*isolate->factory()->NewStringFromStaticChars("NFC")) || |
+ form->Equals(*isolate->factory()->NewStringFromStaticChars("NFD")) || |
+ form->Equals(*isolate->factory()->NewStringFromStaticChars("NFKC")) || |
+ form->Equals(*isolate->factory()->NewStringFromStaticChars("NFKD")))) { |
+ Handle<String> validForms = |
+ isolate->factory()->NewStringFromStaticChars("NFC, NFD, NFKC, NFKD"); |
+ THROW_NEW_ERROR_RETURN_FAILURE( |
+ isolate, |
+ NewRangeError(MessageTemplate::kNormalizationForm, validForms)); |
+ } |
+ |
+ return *string; |
+} |
+ |
// ES6 section 21.1.3.25 String.prototype.toString () |
void Builtins::Generate_StringPrototypeToString(CodeStubAssembler* assembler) { |
typedef compiler::Node Node; |