Update js-display-names.cc

This commit is contained in:
Alexander David Frick 2021-11-22 23:20:14 -06:00 committed by GitHub
parent 695366befd
commit d60fe5adf5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -452,24 +452,12 @@ MaybeHandle<JSDisplayNames> JSDisplayNames::New(Isolate* isolate,
// 12. Let type be ? GetOption(options, "type", "string", « "language",
// "region", "script", "currency" , "calendar", "dateTimeField", "unit"»,
// undefined).
Maybe<Type> maybe_type =
FLAG_harmony_intl_displaynames_v2
? GetStringOption<Type>(
isolate, options, "type", service,
{"language", "region", "script", "currency", "calendar",
"dateTimeField"},
{Type::kLanguage, Type::kRegion, Type::kScript, Type::kCurrency,
Type::kCalendar, Type::kDateTimeField},
Type::kUndefined)
: GetStringOption<Type>(isolate, options, "type", service,
{"language", "region", "script", "currency"},
{
Type::kLanguage,
Type::kRegion,
Type::kScript,
Type::kCurrency,
},
Type::kUndefined);
Maybe<Type> maybe_type = GetStringOption<Type>(
isolate, options, "type", service,
{"language", "region", "script", "currency", "calendar", "dateTimeField"},
{Type::kLanguage, Type::kRegion, Type::kScript, Type::kCurrency,
Type::kCalendar, Type::kDateTimeField},
Type::kUndefined);
MAYBE_RETURN(maybe_type, MaybeHandle<JSDisplayNames>());
Type type_enum = maybe_type.FromJust();
@ -492,21 +480,18 @@ MaybeHandle<JSDisplayNames> JSDisplayNames::New(Isolate* isolate,
// 16. Set displayNames.[[Fallback]] to fallback.
LanguageDisplay language_display_enum = LanguageDisplay::kDialect;
if (FLAG_harmony_intl_displaynames_v2) {
// 24. Let languageDisplay be ? GetOption(options, "languageDisplay",
// "string", « "dialect", "standard" », "dialect").
Maybe<LanguageDisplay> maybe_language_display =
GetStringOption<LanguageDisplay>(
isolate, options, "languageDisplay", service,
{"dialect", "standard"},
{LanguageDisplay::kDialect, LanguageDisplay::kStandard},
LanguageDisplay::kDialect);
MAYBE_RETURN(maybe_language_display, MaybeHandle<JSDisplayNames>());
// 25. If type is "language", then
if (type_enum == Type::kLanguage) {
// a. Set displayNames.[[LanguageDisplay]] to languageDisplay.
language_display_enum = maybe_language_display.FromJust();
}
// 24. Let languageDisplay be ? GetOption(options, "languageDisplay",
// "string", « "dialect", "standard" », "dialect").
Maybe<LanguageDisplay> maybe_language_display =
GetStringOption<LanguageDisplay>(
isolate, options, "languageDisplay", service, {"dialect", "standard"},
{LanguageDisplay::kDialect, LanguageDisplay::kStandard},
LanguageDisplay::kDialect);
MAYBE_RETURN(maybe_language_display, MaybeHandle<JSDisplayNames>());
// 25. If type is "language", then
if (type_enum == Type::kLanguage) {
// a. Set displayNames.[[LanguageDisplay]] to languageDisplay.
language_display_enum = maybe_language_display.FromJust();
}
// Set displayNames.[[Fallback]] to fallback.
@ -594,7 +579,6 @@ Handle<JSObject> JSDisplayNames::ResolvedOptions(
DCHECK(maybe_create_fallback.FromJust());
USE(maybe_create_fallback);
if (FLAG_harmony_intl_displaynames_v2) {
if (std::strcmp("language", internal->type()) == 0) {
Maybe<bool> maybe_create_language_display =
JSReceiver::CreateDataProperty(isolate, options,
@ -603,7 +587,6 @@ Handle<JSObject> JSDisplayNames::ResolvedOptions(
DCHECK(maybe_create_language_display.FromJust());
USE(maybe_create_language_display);
}
}
return options;
}