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

Unified Diff: src/bootstrapper.cc

Issue 2736543002: [intl] Implement Intl.PluralRules
Patch Set: clarify comment Created 3 years, 9 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 | « no previous file | src/contexts.h » ('j') | src/i18n.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/bootstrapper.cc
diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc
index e1850c8adb7cc3164bc81ff4e7098544a7c2fea4..75e771f4a5d2f560ec702f18cbcdfdeb9ce8757f 100644
--- a/src/bootstrapper.cc
+++ b/src/bootstrapper.cc
@@ -3629,6 +3629,24 @@ void Bootstrapper::ExportFromRuntime(Isolate* isolate,
Accessors::FunctionSetPrototype(callsite_fun, proto).Assert();
}
}
+
+ { // I n t l P l u r a l R u l e s
+ Handle<JSObject> plural_rules_prototype =
+ factory->NewJSObject(isolate->object_function(), TENURED);
+ // Install the @@toStringTag property on the {prototype}.
+ JSObject::AddProperty(
+ plural_rules_prototype, factory->to_string_tag_symbol(),
+ factory->Object_string(),
+ static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY));
+ Handle<JSFunction> plural_rules_constructor = InstallFunction(
+ container, "PluralRules", JS_OBJECT_TYPE, PluralRules::kSize,
+ plural_rules_prototype, Builtins::kIllegal);
+ JSObject::AddProperty(plural_rules_prototype, factory->constructor_string(),
+ plural_rules_constructor, DONT_ENUM);
+ InstallWithIntrinsicDefaultProto(isolate, plural_rules_constructor,
+ Context::INTL_PLURAL_RULES_FUNCTION_INDEX);
+ }
+
isolate->native_context()->set_exports_container(*container);
}
@@ -3873,6 +3891,22 @@ void Genesis::InitializeGlobal_icu_case_mapping() {
SetFunction(string_prototype, to_locale_upper_case,
factory()->InternalizeUtf8String("toLocaleUpperCase"));
}
+
+void Genesis::InitializeGlobal_harmony_plural_rules() {
+ if (!FLAG_harmony_plural_rules) return;
+
+ Handle<JSReceiver> exports_container(
+ JSReceiver::cast(native_context()->exports_container()));
+ Handle<JSFunction> plural_rules(
+ native_context()->intl_plural_rules_function());
+ Handle<JSObject> intl = Handle<JSObject>::cast(
+ JSReceiver::GetProperty(
+ Handle<JSReceiver>(native_context()->global_object()),
+ factory()->InternalizeUtf8String("Intl"))
+ .ToHandleChecked());
+ JSObject::AddProperty(intl, factory()->InternalizeUtf8String("PluralRules"),
+ plural_rules, DONT_ENUM);
+}
#endif
Handle<JSFunction> Genesis::InstallArrayBuffer(Handle<JSObject> target,
@@ -4339,6 +4373,7 @@ bool Genesis::InstallExperimentalNatives() {
#ifdef V8_I18N_SUPPORT
static const char* icu_case_mapping_natives[] = {nullptr};
static const char* datetime_format_to_parts_natives[] = {nullptr};
+ static const char* harmony_plural_rules_natives[] = {nullptr};
#endif
static const char* harmony_restrictive_generators_natives[] = {nullptr};
static const char* harmony_trailing_commas_natives[] = {nullptr};
« no previous file with comments | « no previous file | src/contexts.h » ('j') | src/i18n.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698