Commit f69f826e authored by littledan's avatar littledan Committed by Commit bot

[intl] Remove dead code to support v8Parse method

The methods Intl.NumberFormat.prototype.v8Parse and
Intl.DateTimeFormat.prototype.v8Parse were removed several months
ago due to low usage and lack of standardization potential. This
patch removes some runtime functions used to implement them, which
were accidentally left in when they were taken out.

BUG=v8:3785

Review-Url: https://codereview.chromium.org/2591103003
Cr-Commit-Position: refs/heads/master@{#41887}
parent f4b336a5
......@@ -530,30 +530,6 @@ RUNTIME_FUNCTION(Runtime_InternalDateFormatToParts) {
return *result;
}
RUNTIME_FUNCTION(Runtime_InternalDateParse) {
HandleScope scope(isolate);
DCHECK(args.length() == 2);
CONVERT_ARG_HANDLE_CHECKED(JSObject, date_format_holder, 0);
CONVERT_ARG_HANDLE_CHECKED(String, date_string, 1);
v8::String::Utf8Value utf8_date(v8::Utils::ToLocal(date_string));
icu::UnicodeString u_date(icu::UnicodeString::fromUTF8(*utf8_date));
icu::SimpleDateFormat* date_format =
DateFormat::UnpackDateFormat(isolate, date_format_holder);
if (!date_format) return isolate->ThrowIllegalOperation();
UErrorCode status = U_ZERO_ERROR;
UDate date = date_format->parse(u_date, status);
if (U_FAILURE(status)) return isolate->heap()->undefined_value();
RETURN_RESULT_OR_FAILURE(
isolate, JSDate::New(isolate->date_function(), isolate->date_function(),
static_cast<double>(date)));
}
RUNTIME_FUNCTION(Runtime_CreateNumberFormat) {
HandleScope scope(isolate);
......@@ -618,47 +594,6 @@ RUNTIME_FUNCTION(Runtime_InternalNumberFormat) {
}
RUNTIME_FUNCTION(Runtime_InternalNumberParse) {
HandleScope scope(isolate);
DCHECK(args.length() == 2);
CONVERT_ARG_HANDLE_CHECKED(JSObject, number_format_holder, 0);
CONVERT_ARG_HANDLE_CHECKED(String, number_string, 1);
isolate->CountUsage(v8::Isolate::UseCounterFeature::kIntlV8Parse);
v8::String::Utf8Value utf8_number(v8::Utils::ToLocal(number_string));
icu::UnicodeString u_number(icu::UnicodeString::fromUTF8(*utf8_number));
icu::DecimalFormat* number_format =
NumberFormat::UnpackNumberFormat(isolate, number_format_holder);
if (!number_format) return isolate->ThrowIllegalOperation();
UErrorCode status = U_ZERO_ERROR;
icu::Formattable result;
// ICU 4.6 doesn't support parseCurrency call. We need to wait for ICU49
// to be part of Chrome.
// TODO(cira): Include currency parsing code using parseCurrency call.
// We need to check if the formatter parses all currencies or only the
// one it was constructed with (it will impact the API - how to return ISO
// code and the value).
number_format->parse(u_number, result, status);
if (U_FAILURE(status)) return isolate->heap()->undefined_value();
switch (result.getType()) {
case icu::Formattable::kDouble:
return *isolate->factory()->NewNumber(result.getDouble());
case icu::Formattable::kLong:
return *isolate->factory()->NewNumberFromInt(result.getLong());
case icu::Formattable::kInt64:
return *isolate->factory()->NewNumber(
static_cast<double>(result.getInt64()));
default:
return isolate->heap()->undefined_value();
}
}
RUNTIME_FUNCTION(Runtime_CreateCollator) {
HandleScope scope(isolate);
......
......@@ -264,10 +264,8 @@ namespace internal {
F(CreateDateTimeFormat, 3, 1) \
F(InternalDateFormat, 2, 1) \
F(InternalDateFormatToParts, 2, 1) \
F(InternalDateParse, 2, 1) \
F(CreateNumberFormat, 3, 1) \
F(InternalNumberFormat, 2, 1) \
F(InternalNumberParse, 2, 1) \
F(CreateCollator, 3, 1) \
F(InternalCompare, 3, 1) \
F(StringNormalize, 2, 1) \
......
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