Commit c62b0634 authored by Frank Tang's avatar Frank Tang Committed by Commit Bot

[Intl] mv code to objects/js-date-time-format.*

Bug: v8:5751
Cq-Include-Trybots: luci.v8.try:v8_linux_noi18n_rel_ng;luci.chromium.try:linux_chromium_rel_ng
Change-Id: Idf89e9d79e9b063c7d01e2b133826b9127910f4e
Reviewed-on: https://chromium-review.googlesource.com/1205835
Commit-Queue: Frank Tang <ftang@chromium.org>
Reviewed-by: 's avatarSathya Gunasekaran <gsathya@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55785}
parent 0d1b00b8
......@@ -30,6 +30,7 @@
#ifdef V8_INTL_SUPPORT
#include "src/objects/js-break-iterator.h"
#include "src/objects/js-collator.h"
#include "src/objects/js-date-time-format.h"
#include "src/objects/js-list-format.h"
#include "src/objects/js-locale.h"
#include "src/objects/js-number-format.h"
......@@ -2901,8 +2902,15 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
{
Handle<JSFunction> date_time_format_constructor = InstallFunction(
isolate_, intl, "DateTimeFormat", JS_OBJECT_TYPE, DateFormat::kSize,
0, factory->the_hole_value(), Builtins::kIllegal);
isolate_, intl, "DateTimeFormat", JS_INTL_DATE_TIME_FORMAT_TYPE,
JSDateTimeFormat::kSize, 0, factory->the_hole_value(),
Builtins::kDateTimeFormatConstructor);
date_time_format_constructor->shared()->set_length(0);
date_time_format_constructor->shared()->DontAdaptArguments();
InstallWithIntrinsicDefaultProto(
isolate_, date_time_format_constructor,
Context::INTL_DATE_TIME_FORMAT_FUNCTION_INDEX);
native_context()->set_intl_date_time_format_function(
*date_time_format_constructor);
......
......@@ -844,14 +844,14 @@ BUILTIN(DatePrototypeToTimeString) {
BUILTIN(DatePrototypeToLocaleDateString) {
HandleScope scope(isolate);
CHECK_RECEIVER(JSDate, date, "Date.prototype.toLocaleDateString");
RETURN_RESULT_OR_FAILURE(isolate,
JSDateTimeFormat::ToLocaleDateTime(
RETURN_RESULT_OR_FAILURE(
isolate, JSDateTimeFormat::ToLocaleDateTime(
isolate,
date, // date
args.atOrUndefined(isolate, 1), // locales
args.atOrUndefined(isolate, 2), // options
"date", // required
"date", // defaults
JSDateTimeFormat::RequiredOption::kDate, // required
JSDateTimeFormat::DefaultsOption::kDate, // defaults
"dateformatdate")); // service
}
......@@ -859,14 +859,14 @@ BUILTIN(DatePrototypeToLocaleDateString) {
BUILTIN(DatePrototypeToLocaleString) {
HandleScope scope(isolate);
CHECK_RECEIVER(JSDate, date, "Date.prototype.toLocaleString");
RETURN_RESULT_OR_FAILURE(isolate,
JSDateTimeFormat::ToLocaleDateTime(
RETURN_RESULT_OR_FAILURE(
isolate, JSDateTimeFormat::ToLocaleDateTime(
isolate,
date, // date
args.atOrUndefined(isolate, 1), // locales
args.atOrUndefined(isolate, 2), // options
"any", // required
"all", // defaults
JSDateTimeFormat::RequiredOption::kAny, // required
JSDateTimeFormat::DefaultsOption::kAll, // defaults
"dateformatall")); // service
}
......@@ -874,14 +874,14 @@ BUILTIN(DatePrototypeToLocaleString) {
BUILTIN(DatePrototypeToLocaleTimeString) {
HandleScope scope(isolate);
CHECK_RECEIVER(JSDate, date, "Date.prototype.toLocaleTimeString");
RETURN_RESULT_OR_FAILURE(isolate,
JSDateTimeFormat::ToLocaleDateTime(
RETURN_RESULT_OR_FAILURE(
isolate, JSDateTimeFormat::ToLocaleDateTime(
isolate,
date, // date
args.atOrUndefined(isolate, 1), // locales
args.atOrUndefined(isolate, 2), // options
"time", // required
"time", // defaults
JSDateTimeFormat::RequiredOption::kTime, // required
JSDateTimeFormat::DefaultsOption::kTime, // defaults
"dateformattime")); // service
}
#endif // V8_INTL_SUPPORT
......
......@@ -1345,6 +1345,8 @@ namespace internal {
CPP(DatePrototypeToLocaleString) \
/* ecma402 #sup-date.prototype.tolocaletimestring */ \
CPP(DatePrototypeToLocaleTimeString) \
/* ecma402 #sec-intl.datetimeformat */ \
CPP(DateTimeFormatConstructor) \
/* ecma402 #sec-datetime-format-functions */ \
CPP(DateTimeFormatInternalFormat) \
/* ecma402 #sec-intl.datetimeformat.prototype.format */ \
......
This diff is collapsed.
......@@ -43,35 +43,6 @@ utils.Import(function(from) {
ArrayPush = from.ArrayPush;
});
// Utilities for definitions
macro NUMBER_IS_NAN(arg)
(%IS_VAR(arg) !== arg)
endmacro
// To avoid ES2015 Function name inference.
macro ANONYMOUS_FUNCTION(fn)
(0, (fn))
endmacro
function IntlConstruct(receiver, constructor, create, newTarget, args,
compat) {
var locales = args[0];
var options = args[1];
var instance = create(locales, options);
if (compat && IS_UNDEFINED(newTarget) && receiver instanceof constructor) {
%object_define_property(receiver, IntlFallbackSymbol, { value: instance });
return receiver;
}
return instance;
}
// -------------------------------------------------------------------
/**
......@@ -299,69 +270,6 @@ function bestFitMatcher(service, requestedLocales) {
return lookupMatcher(service, requestedLocales);
}
/**
* Populates internalOptions object with boolean key-value pairs
* from extensionMap and options.
* Returns filtered extension (number and date format constructors use
* Unicode extensions for passing parameters to ICU).
* It's used for extension-option pairs only, e.g. kn-normalization, but not
* for 'sensitivity' since it doesn't have extension equivalent.
* Extensions like nu and ca don't have options equivalent, so we place
* undefined in the map.property to denote that.
*/
function setOptions(inOptions, extensionMap, keyValues, getOption, outOptions) {
var extension = '';
var updateExtension = function updateExtension(key, value) {
return '-' + key + '-' + TO_STRING(value);
}
var updateProperty = function updateProperty(property, type, value) {
if (type === 'boolean' && (typeof value === 'string')) {
value = (value === 'true') ? true : false;
}
if (!IS_UNDEFINED(property)) {
%DefineWEProperty(outOptions, property, value);
}
}
for (var key in keyValues) {
if (HAS_OWN_PROPERTY(keyValues, key)) {
var value = UNDEFINED;
var map = keyValues[key];
if (!IS_UNDEFINED(map.property)) {
// This may return true if user specifies numeric: 'false', since
// Boolean('nonempty') === true.
value = getOption(map.property, map.type, map.values);
}
if (!IS_UNDEFINED(value)) {
updateProperty(map.property, map.type, value);
extension += updateExtension(key, value);
continue;
}
// User options didn't have it, check Unicode extension.
// Here we want to convert strings 'true', 'false' into proper Boolean
// values (not a user error).
if (HAS_OWN_PROPERTY(extensionMap, key)) {
value = extensionMap[key];
if (!IS_UNDEFINED(value)) {
updateProperty(map.property, map.type, value);
extension += updateExtension(key, value);
} else if (map.type === 'boolean') {
// Boolean keys are allowed not to have values in Unicode extension.
// Those default to true.
updateProperty(map.property, map.type, true);
extension += updateExtension(key, true);
}
}
}
}
return extension === ''? '' : '-u' + extension;
}
/**
* Given an array-like, outputs an Array with the numbered
* properties copied over and defined
......@@ -422,16 +330,6 @@ function getAvailableLocalesOf(service) {
return available;
}
/**
* Defines a property and sets writable, enumerable and configurable to true.
*/
function defineWECProperty(object, property, value) {
%object_define_property(object, property, {value: value,
writable: true,
enumerable: true,
configurable: true});
}
/**
* Returns an InternalArray where all locales are canonicalized and duplicates
* removed.
......@@ -503,73 +401,6 @@ DEFINE_METHOD(
}
);
/**
* Initializes the given object so it's a valid DateTimeFormat instance.
* Useful for subclassing.
*/
function CreateDateTimeFormat(locales, options) {
if (IS_UNDEFINED(options)) {
options = {__proto__: null};
}
var locale = resolveLocale('dateformat', locales, options);
options = %ToDateTimeOptions(options, 'any', 'date');
var getOption = getGetOption(options, 'dateformat');
// We implement only best fit algorithm, but still need to check
// if the formatMatcher values are in range.
var matcher = getOption('formatMatcher', 'string',
['basic', 'best fit'], 'best fit');
// ICU prefers options to be passed using -u- extension key/values, so
// we need to build that.
var internalOptions = {__proto__: null};
var extensionMap = %ParseExtension(locale.extension);
/**
* Map of Unicode extensions to option properties, and their values and types,
* for a date/time format.
*/
var DATETIME_FORMAT_KEY_MAP = {
__proto__: null,
'ca': {__proto__: null, 'property': UNDEFINED, 'type': 'string'},
'nu': {__proto__: null, 'property': UNDEFINED, 'type': 'string'}
};
var extension = setOptions(options, extensionMap, DATETIME_FORMAT_KEY_MAP,
getOption, internalOptions);
var requestedLocale = locale.locale + extension;
// Still need to store locale and numberingSystem till we move the storage
// to JSDateTimeFormat
var resolved = {__proto__: null};
var dateFormat = %CreateDateTimeFormat(requestedLocale, options, resolved);
%MarkAsInitializedIntlObjectOfType(dateFormat, DATE_TIME_FORMAT_TYPE);
// Still need to store locale and numberingSystem till we move the storage
// to JSDateTimeFormat
dateFormat[resolvedSymbol] = resolved;
return dateFormat;
}
/**
* Constructs Intl.DateTimeFormat object given optional locales and options
* parameters.
*
* @constructor
*/
function DateTimeFormatConstructor() {
return IntlConstruct(this, GlobalIntlDateTimeFormat, CreateDateTimeFormat,
new.target, arguments, true);
}
%SetCode(GlobalIntlDateTimeFormat, DateTimeFormatConstructor);
/**
* DateTimeFormat resolvedOptions method.
*/
......
......@@ -1910,6 +1910,10 @@ void JSCollator::JSCollatorVerify(Isolate* isolate) {
void JSDateTimeFormat::JSDateTimeFormatVerify(Isolate* isolate) {
JSObjectVerify(isolate);
VerifyObjectField(isolate, kLocaleOffset);
VerifyObjectField(isolate, kNumberingSystemOffset);
VerifyObjectField(isolate, kICUSimpleDateFormatOffset);
VerifyObjectField(isolate, kBoundFormatOffset);
}
void JSListFormat::JSListFormatVerify(Isolate* isolate) {
......
......@@ -1991,6 +1991,11 @@ void JSCollator::JSCollatorPrint(std::ostream& os) { // NOLINT
void JSDateTimeFormat::JSDateTimeFormatPrint(std::ostream& os) { // NOLINT
JSObjectPrintHeader(os, this, "JSDateTimeFormat");
os << "\n - locale: " << Brief(locale());
os << "\n - numbering system: " << Brief(numbering_system());
os << "\n - icu simple date format: " << Brief(icu_simple_date_format());
os << "\n - bound format: " << Brief(bound_format());
os << "\n";
}
void JSListFormat::JSListFormatPrint(std::ostream& os) { // NOLINT
......
This diff is collapsed.
......@@ -31,41 +31,6 @@ namespace internal {
template <typename T>
class Handle;
class DateFormat {
public:
// Create a formatter for the specificied locale and options. Returns the
// resolved settings for the locale / options.
static Maybe<icu::SimpleDateFormat*> InitializeDateTimeFormat(
Isolate* isolate, Handle<String> locale, Handle<JSObject> options,
Handle<JSObject> resolved);
// Unpacks date format object from corresponding JavaScript object.
static icu::SimpleDateFormat* UnpackDateFormat(Handle<JSObject> obj);
// Release memory we allocated for the DateFormat once the JS object that
// holds the pointer gets garbage collected.
static void DeleteDateFormat(const v8::WeakCallbackInfo<void>& data);
// Layout description.
#define DATE_FORMAT_FIELDS(V) \
V(kSimpleDateFormat, kPointerSize) \
V(kBoundFormat, kPointerSize) \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(JSObject::kHeaderSize, DATE_FORMAT_FIELDS)
#undef DATE_FORMAT_FIELDS
// TODO(ryzokuken): Remove this and use regular accessors once DateFormat is a
// subclass of JSObject
//
// This needs to be consistent with the above Layout Description
static const int kSimpleDateFormatIndex = 0;
static const int kBoundFormatIndex = 1;
private:
DateFormat();
};
class Intl {
public:
enum Type {
......@@ -119,23 +84,11 @@ class Intl {
static std::string DefaultLocale(Isolate* isolate);
static void DefineWEProperty(Isolate* isolate, Handle<JSReceiver> target,
Handle<Name> key, Handle<Object> value);
// If locale has a script tag then return true and the locale without the
// script else return false and an empty string
static bool RemoveLocaleScriptTag(const std::string& icu_locale,
std::string* locale_less_script);
// Returns the underlying Intl receiver for various methods which
// implement ECMA-402 v1 semantics for supporting initializing
// existing Intl objects.
V8_WARN_UNUSED_RESULT static MaybeHandle<JSObject> UnwrapReceiver(
Isolate* isolate, Handle<JSReceiver> receiver,
Handle<JSFunction> constructor, Intl::Type type,
Handle<String> method_name /* TODO(gsathya): Make this char const* */,
bool check_legacy_constructor = false);
// The ResolveLocale abstract operation compares a BCP 47 language
// priority list requestedLocales against the locales in
// availableLocales and determines the best available language to
......@@ -213,10 +166,6 @@ class Intl {
Isolate* isolate, Handle<Object> locales,
bool only_return_one_result = false);
// TODO(ftang): Remove this and use ICU to the conversion in the future
static void ParseExtension(Isolate* isolate, const std::string& extension,
std::map<std::string, std::string>& out);
V8_WARN_UNUSED_RESULT static MaybeHandle<JSObject> CreateNumberFormat(
Isolate* isolate, Handle<String> locale, Handle<JSObject> options,
Handle<JSObject> resolved);
......
......@@ -18,6 +18,12 @@
namespace v8 {
namespace internal {
ACCESSORS(JSDateTimeFormat, locale, String, kLocaleOffset);
ACCESSORS(JSDateTimeFormat, numbering_system, String, kNumberingSystemOffset);
ACCESSORS(JSDateTimeFormat, icu_simple_date_format,
Managed<icu::SimpleDateFormat>, kICUSimpleDateFormatOffset)
ACCESSORS(JSDateTimeFormat, bound_format, Object, kBoundFormatOffset);
CAST_ACCESSOR(JSDateTimeFormat);
} // namespace internal
......
This diff is collapsed.
......@@ -10,6 +10,7 @@
#define V8_OBJECTS_JS_DATE_TIME_FORMAT_H_
#include "src/isolate.h"
#include "src/objects/managed.h"
// Has to be the last include (doesn't have include guards):
#include "src/objects/object-macros.h"
......@@ -23,16 +24,19 @@ namespace internal {
class JSDateTimeFormat : public JSObject {
public:
V8_WARN_UNUSED_RESULT static MaybeHandle<JSDateTimeFormat> Initialize(
Isolate* isolate, Handle<JSDateTimeFormat> date_time_format,
Handle<Object> locales, Handle<Object> options);
static icu::SimpleDateFormat* UnpackDateFormat(
Handle<JSDateTimeFormat> date_time_format);
V8_WARN_UNUSED_RESULT static MaybeHandle<JSObject> ResolvedOptions(
Isolate* isolate, Handle<JSReceiver> date_time_holder);
Isolate* isolate, Handle<JSReceiver> format_holder);
// The UnwrapDateTimeFormat abstract operation gets the underlying
// DateTimeFormat operation for various methods which implement ECMA-402 v1
// semantics for supporting initializing existing Intl objects.
//
// ecma402/#sec-unwrapdatetimeformat
V8_WARN_UNUSED_RESULT static MaybeHandle<JSObject> Unwrap(
Isolate* isolate, Handle<JSReceiver> receiver, const char* method_name);
V8_WARN_UNUSED_RESULT static MaybeHandle<JSDateTimeFormat>
UnwrapDateTimeFormat(Isolate* isolate, Handle<JSReceiver> format_holder);
// Convert the options to ICU DateTimePatternGenerator skeleton.
static Maybe<std::string> OptionsToSkeleton(Isolate* isolate,
......@@ -46,23 +50,35 @@ class JSDateTimeFormat : public JSObject {
// ecma402/#sec-datetime-format-functions
// DateTime Format Functions
V8_WARN_UNUSED_RESULT static MaybeHandle<String> DateTimeFormat(
Isolate* isolate, Handle<JSObject> date_time_format_holder,
Isolate* isolate, Handle<JSDateTimeFormat> date_time_format,
Handle<Object> date);
V8_WARN_UNUSED_RESULT static MaybeHandle<Object> FormatToParts(
Isolate* isolate, Handle<JSDateTimeFormat> date_time_format,
double date_value);
// ecma-402/#sec-todatetimeoptions
enum class RequiredOption { kDate, kTime, kAny };
enum class DefaultsOption { kDate, kTime, kAll };
V8_WARN_UNUSED_RESULT static MaybeHandle<JSObject> ToDateTimeOptions(
Isolate* isolate, Handle<Object> input_options, const char* required,
const char* defaults);
Isolate* isolate, Handle<Object> input_options, RequiredOption required,
DefaultsOption defaults);
V8_WARN_UNUSED_RESULT static MaybeHandle<String> ToLocaleDateTime(
Isolate* isolate, Handle<Object> date, Handle<Object> locales,
Handle<Object> options, const char* required, const char* defaults,
Handle<Object> options, RequiredOption required, DefaultsOption defaults,
const char* service);
DECL_CAST(JSDateTimeFormat)
// TODO(ftang): try to remove numbering_system from JSDateTimeFormat and
// directly read from icu to save some bytes later.
// Layout description.
#define JS_DATE_TIME_FORMAT_FIELDS(V) \
V(kLocaleOffset, kPointerSize) \
V(kNumberingSystemOffset, kPointerSize) \
V(kICUSimpleDateFormatOffset, kPointerSize) \
V(kBoundFormatOffset, kPointerSize) \
/* Total size. */ \
V(kSize, 0)
......@@ -70,6 +86,11 @@ class JSDateTimeFormat : public JSObject {
JS_DATE_TIME_FORMAT_FIELDS)
#undef JS_DATE_TIME_FORMAT_FIELDS
DECL_ACCESSORS(locale, String)
DECL_ACCESSORS(numbering_system, String)
DECL_ACCESSORS(icu_simple_date_format, Managed<icu::SimpleDateFormat>)
DECL_ACCESSORS(bound_format, Object)
DECL_PRINTER(JSDateTimeFormat)
DECL_VERIFIER(JSDateTimeFormat)
......
......@@ -182,9 +182,11 @@ MaybeHandle<JSNumberFormat> JSNumberFormat::UnwrapNumberFormat(
}
// static
MaybeHandle<JSNumberFormat> JSNumberFormat::InitializeNumberFormat(
MaybeHandle<JSNumberFormat> JSNumberFormat::Initialize(
Isolate* isolate, Handle<JSNumberFormat> number_format,
Handle<Object> locales, Handle<Object> options_obj) {
// set the flags to 0 ASAP.
number_format->set_flags(0);
Factory* factory = isolate->factory();
// 1. Let requestedLocales be ? CanonicalizeLocaleList(locales).
Handle<JSObject> requested_locales;
......
......@@ -28,8 +28,8 @@ namespace internal {
class JSNumberFormat : public JSObject {
public:
// ecma402/#sec-initializenumberformat
V8_WARN_UNUSED_RESULT static MaybeHandle<JSNumberFormat>
InitializeNumberFormat(Isolate* isolate, Handle<JSNumberFormat> number_format,
V8_WARN_UNUSED_RESULT static MaybeHandle<JSNumberFormat> Initialize(
Isolate* isolate, Handle<JSNumberFormat> number_format,
Handle<Object> locales, Handle<Object> options);
// ecma402/#sec-unwrapnumberformat
......
......@@ -110,92 +110,13 @@ RUNTIME_FUNCTION(Runtime_GetDefaultICULocale) {
Intl::DefaultLocale(isolate).c_str());
}
RUNTIME_FUNCTION(Runtime_DefineWEProperty) {
HandleScope scope(isolate);
DCHECK_EQ(3, args.length());
CONVERT_ARG_HANDLE_CHECKED(JSObject, target, 0);
CONVERT_ARG_HANDLE_CHECKED(Name, key, 1);
CONVERT_ARG_HANDLE_CHECKED(Object, value, 2);
Intl::DefineWEProperty(isolate, target, key, value);
return ReadOnlyRoots(isolate).undefined_value();
}
RUNTIME_FUNCTION(Runtime_IsInitializedIntlObjectOfType) {
HandleScope scope(isolate);
DCHECK_EQ(2, args.length());
CONVERT_ARG_HANDLE_CHECKED(Object, input, 0);
CONVERT_SMI_ARG_CHECKED(expected_type_int, 1);
Intl::Type expected_type = Intl::TypeFromInt(expected_type_int);
return isolate->heap()->ToBoolean(
Intl::IsObjectOfType(isolate, input, expected_type));
}
RUNTIME_FUNCTION(Runtime_MarkAsInitializedIntlObjectOfType) {
HandleScope scope(isolate);
DCHECK_EQ(2, args.length());
CONVERT_ARG_HANDLE_CHECKED(JSObject, input, 0);
CONVERT_ARG_HANDLE_CHECKED(Smi, type, 1);
#ifdef DEBUG
// TypeFromSmi does correctness checks.
Intl::Type type_intl = Intl::TypeFromSmi(*type);
USE(type_intl);
#endif
Handle<Symbol> marker = isolate->factory()->intl_initialized_marker_symbol();
JSObject::SetProperty(isolate, input, marker, type, LanguageMode::kStrict)
.Assert();
return ReadOnlyRoots(isolate).undefined_value();
}
RUNTIME_FUNCTION(Runtime_CreateDateTimeFormat) {
HandleScope scope(isolate);
DCHECK_EQ(3, args.length());
CONVERT_ARG_HANDLE_CHECKED(String, locale, 0);
CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1);
CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2);
Handle<JSFunction> constructor(
isolate->native_context()->intl_date_time_format_function(), isolate);
Handle<JSObject> local_object;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, local_object,
JSObject::New(constructor, constructor));
// Set date time formatter as embedder field of the resulting JS object.
Maybe<icu::SimpleDateFormat*> maybe_date_format =
DateFormat::InitializeDateTimeFormat(isolate, locale, options, resolved);
MAYBE_RETURN(maybe_date_format, ReadOnlyRoots(isolate).exception());
icu::SimpleDateFormat* date_format = maybe_date_format.FromJust();
CHECK_NOT_NULL(date_format);
local_object->SetEmbedderField(DateFormat::kSimpleDateFormatIndex,
reinterpret_cast<Smi*>(date_format));
// Make object handle weak so we can delete the data format once GC kicks in.
Handle<Object> wrapper = isolate->global_handles()->Create(*local_object);
GlobalHandles::MakeWeak(wrapper.location(), wrapper.location(),
DateFormat::DeleteDateFormat,
WeakCallbackType::kInternalFields);
return *local_object;
}
// ecma402/#sec-intl.datetimeformat.prototype.resolvedoptions
RUNTIME_FUNCTION(Runtime_DateTimeFormatResolvedOptions) {
HandleScope scope(isolate);
DCHECK_EQ(1, args.length());
// 1. Let dtf be this value.
CONVERT_ARG_HANDLE_CHECKED(Object, dtf, 0);
// 2. If Type(dtf) is not Object, throw a TypeError exception.
if (!dtf->IsJSReceiver()) {
Handle<String> method_str = isolate->factory()->NewStringFromStaticChars(
......@@ -204,9 +125,10 @@ RUNTIME_FUNCTION(Runtime_DateTimeFormatResolvedOptions) {
isolate, NewTypeError(MessageTemplate::kIncompatibleMethodReceiver,
method_str, dtf));
}
Handle<JSReceiver> date_format_holder = Handle<JSReceiver>::cast(dtf);
Handle<JSReceiver> format_holder = Handle<JSReceiver>::cast(dtf);
RETURN_RESULT_OR_FAILURE(
isolate, JSDateTimeFormat::ResolvedOptions(isolate, date_format_holder));
isolate, JSDateTimeFormat::ResolvedOptions(isolate, format_holder));
}
RUNTIME_FUNCTION(Runtime_NumberFormatResolvedOptions) {
......@@ -236,25 +158,6 @@ RUNTIME_FUNCTION(Runtime_NumberFormatResolvedOptions) {
return *JSNumberFormat::ResolvedOptions(isolate, number_format);
}
RUNTIME_FUNCTION(Runtime_ParseExtension) {
Factory* factory = isolate->factory();
HandleScope scope(isolate);
DCHECK_EQ(1, args.length());
CONVERT_ARG_HANDLE_CHECKED(String, extension, 0);
std::map<std::string, std::string> map;
Intl::ParseExtension(isolate, std::string(extension->ToCString().get()), map);
Handle<JSObject> extension_map =
isolate->factory()->NewJSObjectWithNullProto();
for (std::map<std::string, std::string>::iterator it = map.begin();
it != map.end(); it++) {
JSObject::AddProperty(
isolate, extension_map,
factory->NewStringFromAsciiChecked(it->first.c_str()),
factory->NewStringFromAsciiChecked(it->second.c_str()), NONE);
}
return *extension_map;
}
RUNTIME_FUNCTION(Runtime_PluralRulesSelect) {
HandleScope scope(isolate);
......@@ -281,18 +184,6 @@ RUNTIME_FUNCTION(Runtime_PluralRulesSelect) {
isolate, JSPluralRules::ResolvePlural(isolate, plural_rules, number));
}
RUNTIME_FUNCTION(Runtime_ToDateTimeOptions) {
HandleScope scope(isolate);
DCHECK_EQ(args.length(), 3);
CONVERT_ARG_HANDLE_CHECKED(Object, options, 0);
CONVERT_ARG_HANDLE_CHECKED(String, required, 1);
CONVERT_ARG_HANDLE_CHECKED(String, defaults, 2);
RETURN_RESULT_OR_FAILURE(isolate,
JSDateTimeFormat::ToDateTimeOptions(
isolate, options, required->ToCString().get(),
defaults->ToCString().get()));
}
RUNTIME_FUNCTION(Runtime_StringToLowerCaseIntl) {
HandleScope scope(isolate);
DCHECK_EQ(args.length(), 1);
......@@ -327,20 +218,5 @@ RUNTIME_FUNCTION(Runtime_DateCacheVersion) {
return date_cache_version->get(0);
}
RUNTIME_FUNCTION(Runtime_IntlUnwrapReceiver) {
HandleScope scope(isolate);
DCHECK_EQ(5, args.length());
CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0);
CONVERT_SMI_ARG_CHECKED(type_int, 1);
CONVERT_ARG_HANDLE_CHECKED(JSFunction, constructor, 2);
CONVERT_ARG_HANDLE_CHECKED(String, method, 3);
CONVERT_BOOLEAN_ARG_CHECKED(check_legacy_constructor, 4);
RETURN_RESULT_OR_FAILURE(
isolate, Intl::UnwrapReceiver(isolate, receiver, constructor,
Intl::TypeFromInt(type_int), method,
check_legacy_constructor));
}
} // namespace internal
} // namespace v8
......@@ -202,20 +202,13 @@ namespace internal {
#define FOR_EACH_INTRINSIC_INTL(F) \
F(AvailableLocalesOf, 1, 1) \
F(CanonicalizeLanguageTag, 1, 1) \
F(CreateDateTimeFormat, 3, 1) \
F(DateCacheVersion, 0, 1) \
F(DateTimeFormatResolvedOptions, 1, 1) \
F(DefineWEProperty, 3, 1) \
F(FormatList, 2, 1) \
F(FormatListToParts, 2, 1) \
F(GetDefaultICULocale, 0, 1) \
F(IntlUnwrapReceiver, 5, 1) \
F(IsInitializedIntlObjectOfType, 2, 1) \
F(MarkAsInitializedIntlObjectOfType, 2, 1) \
F(ParseExtension, 1, 1) \
F(NumberFormatResolvedOptions, 1, 1) \
F(PluralRulesSelect, 2, 1) \
F(ToDateTimeOptions, 3, 1) \
F(StringToLowerCaseIntl, 1, 1) \
F(StringToUpperCaseIntl, 1, 1) // End of macro.
#else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment