[Intl] Move code from builtins-intl.cc
Move Normalize into intl-objects.* Move V8BreakIterator code to js-break-iterator* Add heap-symbol for breakType of JSBreakIterator Bug: v8:5751 Cq-Include-Trybots: luci.v8.try:v8_linux_noi18n_rel_ng Change-Id: Id25af28770ae3c0b7716f4e3b602d4b040194a7d Reviewed-on: https://chromium-review.googlesource.com/c/1293110 Commit-Queue: Frank Tang <ftang@chromium.org> Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org> Cr-Commit-Position: refs/heads/master@{#56875}
This commit is contained in:
parent
f03b329719
commit
1b4436e7f0
@ -29,18 +29,7 @@
|
||||
#include "src/objects/js-segmenter-inl.h"
|
||||
#include "src/property-descriptor.h"
|
||||
|
||||
#include "unicode/datefmt.h"
|
||||
#include "unicode/decimfmt.h"
|
||||
#include "unicode/fieldpos.h"
|
||||
#include "unicode/fpositer.h"
|
||||
#include "unicode/listformatter.h"
|
||||
#include "unicode/normalizer2.h"
|
||||
#include "unicode/numfmt.h"
|
||||
#include "unicode/smpdtfmt.h"
|
||||
#include "unicode/udat.h"
|
||||
#include "unicode/ufieldpositer.h"
|
||||
#include "unicode/unistr.h"
|
||||
#include "unicode/ustring.h"
|
||||
#include "unicode/brkiter.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
@ -57,72 +46,9 @@ BUILTIN(StringPrototypeNormalizeIntl) {
|
||||
TO_THIS_STRING(string, "String.prototype.normalize");
|
||||
|
||||
Handle<Object> form_input = args.atOrUndefined(isolate, 1);
|
||||
const char* form_name;
|
||||
UNormalization2Mode form_mode;
|
||||
if (form_input->IsUndefined(isolate)) {
|
||||
// default is FNC
|
||||
form_name = "nfc";
|
||||
form_mode = UNORM2_COMPOSE;
|
||||
} else {
|
||||
Handle<String> form;
|
||||
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, form,
|
||||
Object::ToString(isolate, form_input));
|
||||
|
||||
if (String::Equals(isolate, form, isolate->factory()->NFC_string())) {
|
||||
form_name = "nfc";
|
||||
form_mode = UNORM2_COMPOSE;
|
||||
} else if (String::Equals(isolate, form,
|
||||
isolate->factory()->NFD_string())) {
|
||||
form_name = "nfc";
|
||||
form_mode = UNORM2_DECOMPOSE;
|
||||
} else if (String::Equals(isolate, form,
|
||||
isolate->factory()->NFKC_string())) {
|
||||
form_name = "nfkc";
|
||||
form_mode = UNORM2_COMPOSE;
|
||||
} else if (String::Equals(isolate, form,
|
||||
isolate->factory()->NFKD_string())) {
|
||||
form_name = "nfkc";
|
||||
form_mode = UNORM2_DECOMPOSE;
|
||||
} else {
|
||||
Handle<String> valid_forms =
|
||||
isolate->factory()->NewStringFromStaticChars("NFC, NFD, NFKC, NFKD");
|
||||
THROW_NEW_ERROR_RETURN_FAILURE(
|
||||
isolate,
|
||||
NewRangeError(MessageTemplate::kNormalizationForm, valid_forms));
|
||||
}
|
||||
}
|
||||
|
||||
int length = string->length();
|
||||
string = String::Flatten(isolate, string);
|
||||
icu::UnicodeString result;
|
||||
std::unique_ptr<uc16[]> sap;
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
icu::UnicodeString input = Intl::ToICUUnicodeString(isolate, string);
|
||||
// Getting a singleton. Should not free it.
|
||||
const icu::Normalizer2* normalizer =
|
||||
icu::Normalizer2::getInstance(nullptr, form_name, form_mode, status);
|
||||
DCHECK(U_SUCCESS(status));
|
||||
CHECK_NOT_NULL(normalizer);
|
||||
int32_t normalized_prefix_length =
|
||||
normalizer->spanQuickCheckYes(input, status);
|
||||
// Quick return if the input is already normalized.
|
||||
if (length == normalized_prefix_length) return *string;
|
||||
icu::UnicodeString unnormalized =
|
||||
input.tempSubString(normalized_prefix_length);
|
||||
// Read-only alias of the normalized prefix.
|
||||
result.setTo(false, input.getBuffer(), normalized_prefix_length);
|
||||
// copy-on-write; normalize the suffix and append to |result|.
|
||||
normalizer->normalizeSecondAndAppend(result, unnormalized, status);
|
||||
|
||||
if (U_FAILURE(status)) {
|
||||
THROW_NEW_ERROR_RETURN_FAILURE(isolate,
|
||||
NewTypeError(MessageTemplate::kIcuError));
|
||||
}
|
||||
|
||||
RETURN_RESULT_OR_FAILURE(
|
||||
isolate, isolate->factory()->NewStringFromTwoByte(Vector<const uint16_t>(
|
||||
reinterpret_cast<const uint16_t*>(result.getBuffer()),
|
||||
result.length())));
|
||||
RETURN_RESULT_OR_FAILURE(isolate,
|
||||
Intl::Normalize(isolate, string, form_input));
|
||||
}
|
||||
|
||||
BUILTIN(V8BreakIteratorSupportedLocalesOf) {
|
||||
@ -1200,7 +1126,7 @@ BUILTIN(V8BreakIteratorInternalAdoptText) {
|
||||
HandleScope scope(isolate);
|
||||
Handle<Context> context = Handle<Context>(isolate->context(), isolate);
|
||||
|
||||
Handle<JSV8BreakIterator> break_iterator_holder = Handle<JSV8BreakIterator>(
|
||||
Handle<JSV8BreakIterator> break_iterator = Handle<JSV8BreakIterator>(
|
||||
JSV8BreakIterator::cast(context->get(
|
||||
static_cast<int>(Intl::BoundFunctionContextSlot::kBoundFunction))),
|
||||
isolate);
|
||||
@ -1210,7 +1136,7 @@ BUILTIN(V8BreakIteratorInternalAdoptText) {
|
||||
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, text,
|
||||
Object::ToString(isolate, input_text));
|
||||
|
||||
JSV8BreakIterator::AdoptText(isolate, break_iterator_holder, text);
|
||||
JSV8BreakIterator::AdoptText(isolate, break_iterator, text);
|
||||
return ReadOnlyRoots(isolate).undefined_value();
|
||||
}
|
||||
|
||||
@ -1218,18 +1144,17 @@ BUILTIN(V8BreakIteratorPrototypeFirst) {
|
||||
const char* const method = "get Intl.v8BreakIterator.prototype.first";
|
||||
HandleScope scope(isolate);
|
||||
|
||||
CHECK_RECEIVER(JSV8BreakIterator, break_iterator_holder, method);
|
||||
CHECK_RECEIVER(JSV8BreakIterator, break_iterator, method);
|
||||
|
||||
Handle<Object> bound_first(break_iterator_holder->bound_first(), isolate);
|
||||
Handle<Object> bound_first(break_iterator->bound_first(), isolate);
|
||||
if (!bound_first->IsUndefined(isolate)) {
|
||||
DCHECK(bound_first->IsJSFunction());
|
||||
return *bound_first;
|
||||
}
|
||||
|
||||
Handle<JSFunction> new_bound_first_function =
|
||||
CreateBoundFunction(isolate, break_iterator_holder,
|
||||
Builtins::kV8BreakIteratorInternalFirst, 0);
|
||||
break_iterator_holder->set_bound_first(*new_bound_first_function);
|
||||
Handle<JSFunction> new_bound_first_function = CreateBoundFunction(
|
||||
isolate, break_iterator, Builtins::kV8BreakIteratorInternalFirst, 0);
|
||||
break_iterator->set_bound_first(*new_bound_first_function);
|
||||
return *new_bound_first_function;
|
||||
}
|
||||
|
||||
@ -1237,34 +1162,29 @@ BUILTIN(V8BreakIteratorInternalFirst) {
|
||||
HandleScope scope(isolate);
|
||||
Handle<Context> context = Handle<Context>(isolate->context(), isolate);
|
||||
|
||||
Handle<JSV8BreakIterator> break_iterator_holder = Handle<JSV8BreakIterator>(
|
||||
Handle<JSV8BreakIterator> break_iterator = Handle<JSV8BreakIterator>(
|
||||
JSV8BreakIterator::cast(context->get(
|
||||
static_cast<int>(Intl::BoundFunctionContextSlot::kBoundFunction))),
|
||||
isolate);
|
||||
|
||||
icu::BreakIterator* break_iterator =
|
||||
break_iterator_holder->break_iterator()->raw();
|
||||
CHECK_NOT_NULL(break_iterator);
|
||||
|
||||
return *isolate->factory()->NewNumberFromInt(break_iterator->first());
|
||||
return *JSV8BreakIterator::First(isolate, break_iterator);
|
||||
}
|
||||
|
||||
BUILTIN(V8BreakIteratorPrototypeNext) {
|
||||
const char* const method = "get Intl.v8BreakIterator.prototype.next";
|
||||
HandleScope scope(isolate);
|
||||
|
||||
CHECK_RECEIVER(JSV8BreakIterator, break_iterator_holder, method);
|
||||
CHECK_RECEIVER(JSV8BreakIterator, break_iterator, method);
|
||||
|
||||
Handle<Object> bound_next(break_iterator_holder->bound_next(), isolate);
|
||||
Handle<Object> bound_next(break_iterator->bound_next(), isolate);
|
||||
if (!bound_next->IsUndefined(isolate)) {
|
||||
DCHECK(bound_next->IsJSFunction());
|
||||
return *bound_next;
|
||||
}
|
||||
|
||||
Handle<JSFunction> new_bound_next_function =
|
||||
CreateBoundFunction(isolate, break_iterator_holder,
|
||||
Builtins::kV8BreakIteratorInternalNext, 0);
|
||||
break_iterator_holder->set_bound_next(*new_bound_next_function);
|
||||
Handle<JSFunction> new_bound_next_function = CreateBoundFunction(
|
||||
isolate, break_iterator, Builtins::kV8BreakIteratorInternalNext, 0);
|
||||
break_iterator->set_bound_next(*new_bound_next_function);
|
||||
return *new_bound_next_function;
|
||||
}
|
||||
|
||||
@ -1272,34 +1192,28 @@ BUILTIN(V8BreakIteratorInternalNext) {
|
||||
HandleScope scope(isolate);
|
||||
Handle<Context> context = Handle<Context>(isolate->context(), isolate);
|
||||
|
||||
Handle<JSV8BreakIterator> break_iterator_holder = Handle<JSV8BreakIterator>(
|
||||
Handle<JSV8BreakIterator> break_iterator = Handle<JSV8BreakIterator>(
|
||||
JSV8BreakIterator::cast(context->get(
|
||||
static_cast<int>(Intl::BoundFunctionContextSlot::kBoundFunction))),
|
||||
isolate);
|
||||
|
||||
icu::BreakIterator* break_iterator =
|
||||
break_iterator_holder->break_iterator()->raw();
|
||||
CHECK_NOT_NULL(break_iterator);
|
||||
|
||||
return *isolate->factory()->NewNumberFromInt(break_iterator->next());
|
||||
return *JSV8BreakIterator::Next(isolate, break_iterator);
|
||||
}
|
||||
|
||||
BUILTIN(V8BreakIteratorPrototypeCurrent) {
|
||||
const char* const method = "get Intl.v8BreakIterator.prototype.current";
|
||||
HandleScope scope(isolate);
|
||||
|
||||
CHECK_RECEIVER(JSV8BreakIterator, break_iterator_holder, method);
|
||||
CHECK_RECEIVER(JSV8BreakIterator, break_iterator, method);
|
||||
|
||||
Handle<Object> bound_current(break_iterator_holder->bound_current(), isolate);
|
||||
Handle<Object> bound_current(break_iterator->bound_current(), isolate);
|
||||
if (!bound_current->IsUndefined(isolate)) {
|
||||
DCHECK(bound_current->IsJSFunction());
|
||||
return *bound_current;
|
||||
}
|
||||
|
||||
Handle<JSFunction> new_bound_current_function =
|
||||
CreateBoundFunction(isolate, break_iterator_holder,
|
||||
Builtins::kV8BreakIteratorInternalCurrent, 0);
|
||||
break_iterator_holder->set_bound_current(*new_bound_current_function);
|
||||
Handle<JSFunction> new_bound_current_function = CreateBoundFunction(
|
||||
isolate, break_iterator, Builtins::kV8BreakIteratorInternalCurrent, 0);
|
||||
break_iterator->set_bound_current(*new_bound_current_function);
|
||||
return *new_bound_current_function;
|
||||
}
|
||||
|
||||
@ -1307,35 +1221,28 @@ BUILTIN(V8BreakIteratorInternalCurrent) {
|
||||
HandleScope scope(isolate);
|
||||
Handle<Context> context = Handle<Context>(isolate->context(), isolate);
|
||||
|
||||
Handle<JSV8BreakIterator> break_iterator_holder = Handle<JSV8BreakIterator>(
|
||||
Handle<JSV8BreakIterator> break_iterator = Handle<JSV8BreakIterator>(
|
||||
JSV8BreakIterator::cast(context->get(
|
||||
static_cast<int>(Intl::BoundFunctionContextSlot::kBoundFunction))),
|
||||
isolate);
|
||||
|
||||
icu::BreakIterator* break_iterator =
|
||||
break_iterator_holder->break_iterator()->raw();
|
||||
CHECK_NOT_NULL(break_iterator);
|
||||
|
||||
return *isolate->factory()->NewNumberFromInt(break_iterator->current());
|
||||
return *JSV8BreakIterator::Current(isolate, break_iterator);
|
||||
}
|
||||
|
||||
BUILTIN(V8BreakIteratorPrototypeBreakType) {
|
||||
const char* const method = "get Intl.v8BreakIterator.prototype.breakType";
|
||||
HandleScope scope(isolate);
|
||||
|
||||
CHECK_RECEIVER(JSV8BreakIterator, break_iterator_holder, method);
|
||||
CHECK_RECEIVER(JSV8BreakIterator, break_iterator, method);
|
||||
|
||||
Handle<Object> bound_break_type(break_iterator_holder->bound_break_type(),
|
||||
isolate);
|
||||
Handle<Object> bound_break_type(break_iterator->bound_break_type(), isolate);
|
||||
if (!bound_break_type->IsUndefined(isolate)) {
|
||||
DCHECK(bound_break_type->IsJSFunction());
|
||||
return *bound_break_type;
|
||||
}
|
||||
|
||||
Handle<JSFunction> new_bound_break_type_function =
|
||||
CreateBoundFunction(isolate, break_iterator_holder,
|
||||
Builtins::kV8BreakIteratorInternalBreakType, 0);
|
||||
break_iterator_holder->set_bound_break_type(*new_bound_break_type_function);
|
||||
Handle<JSFunction> new_bound_break_type_function = CreateBoundFunction(
|
||||
isolate, break_iterator, Builtins::kV8BreakIteratorInternalBreakType, 0);
|
||||
break_iterator->set_bound_break_type(*new_bound_break_type_function);
|
||||
return *new_bound_break_type_function;
|
||||
}
|
||||
|
||||
@ -1343,30 +1250,11 @@ BUILTIN(V8BreakIteratorInternalBreakType) {
|
||||
HandleScope scope(isolate);
|
||||
Handle<Context> context = Handle<Context>(isolate->context(), isolate);
|
||||
|
||||
Handle<JSV8BreakIterator> break_iterator_holder = Handle<JSV8BreakIterator>(
|
||||
Handle<JSV8BreakIterator> break_iterator = Handle<JSV8BreakIterator>(
|
||||
JSV8BreakIterator::cast(context->get(
|
||||
static_cast<int>(Intl::BoundFunctionContextSlot::kBoundFunction))),
|
||||
isolate);
|
||||
|
||||
icu::BreakIterator* break_iterator =
|
||||
break_iterator_holder->break_iterator()->raw();
|
||||
CHECK_NOT_NULL(break_iterator);
|
||||
|
||||
int32_t status = break_iterator->getRuleStatus();
|
||||
// Keep return values in sync with JavaScript BreakType enum.
|
||||
if (status >= UBRK_WORD_NONE && status < UBRK_WORD_NONE_LIMIT) {
|
||||
return *isolate->factory()->NewStringFromStaticChars("none");
|
||||
} else if (status >= UBRK_WORD_NUMBER && status < UBRK_WORD_NUMBER_LIMIT) {
|
||||
return ReadOnlyRoots(isolate).number_string();
|
||||
} else if (status >= UBRK_WORD_LETTER && status < UBRK_WORD_LETTER_LIMIT) {
|
||||
return *isolate->factory()->NewStringFromStaticChars("letter");
|
||||
} else if (status >= UBRK_WORD_KANA && status < UBRK_WORD_KANA_LIMIT) {
|
||||
return *isolate->factory()->NewStringFromStaticChars("kana");
|
||||
} else if (status >= UBRK_WORD_IDEO && status < UBRK_WORD_IDEO_LIMIT) {
|
||||
return *isolate->factory()->NewStringFromStaticChars("ideo");
|
||||
} else {
|
||||
return *isolate->factory()->NewStringFromStaticChars("unknown");
|
||||
}
|
||||
return JSV8BreakIterator::BreakType(isolate, break_iterator);
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
|
@ -29,9 +29,12 @@
|
||||
V(_, collation_string, "collation") \
|
||||
V(_, currency_string, "currency") \
|
||||
V(_, currencyDisplay_string, "currencyDisplay") \
|
||||
V(_, ideo_string, "ideo") \
|
||||
V(_, ignorePunctuation_string, "ignorePunctuation") \
|
||||
V(_, Invalid_Date_string, "Invalid Date") \
|
||||
V(_, integer_string, "integer") \
|
||||
V(_, kana_string, "kana") \
|
||||
V(_, letter_string, "letter") \
|
||||
V(_, lineBreakStyle_string, "lineBreakStyle") \
|
||||
V(_, literal_string, "literal") \
|
||||
V(_, locale_string, "locale") \
|
||||
@ -66,6 +69,7 @@
|
||||
V(_, timeZone_string, "timeZone") \
|
||||
V(_, timeZoneName_string, "timeZoneName") \
|
||||
V(_, type_string, "type") \
|
||||
V(_, unknown_string, "unknown") \
|
||||
V(_, upper_string, "upper") \
|
||||
V(_, usage_string, "usage") \
|
||||
V(_, useGrouping_string, "useGrouping") \
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "unicode/coll.h"
|
||||
#include "unicode/decimfmt.h"
|
||||
#include "unicode/locid.h"
|
||||
#include "unicode/normalizer2.h"
|
||||
#include "unicode/numfmt.h"
|
||||
#include "unicode/numsys.h"
|
||||
#include "unicode/regex.h"
|
||||
@ -1856,6 +1857,74 @@ Managed<icu::UnicodeString>* Intl::SetTextToBreakIterator(
|
||||
return *new_u_text;
|
||||
}
|
||||
|
||||
// ecma262 #sec-string.prototype.normalize
|
||||
MaybeHandle<String> Intl::Normalize(Isolate* isolate, Handle<String> string,
|
||||
Handle<Object> form_input) {
|
||||
const char* form_name;
|
||||
UNormalization2Mode form_mode;
|
||||
if (form_input->IsUndefined(isolate)) {
|
||||
// default is FNC
|
||||
form_name = "nfc";
|
||||
form_mode = UNORM2_COMPOSE;
|
||||
} else {
|
||||
Handle<String> form;
|
||||
ASSIGN_RETURN_ON_EXCEPTION(isolate, form,
|
||||
Object::ToString(isolate, form_input), String);
|
||||
|
||||
if (String::Equals(isolate, form, isolate->factory()->NFC_string())) {
|
||||
form_name = "nfc";
|
||||
form_mode = UNORM2_COMPOSE;
|
||||
} else if (String::Equals(isolate, form,
|
||||
isolate->factory()->NFD_string())) {
|
||||
form_name = "nfc";
|
||||
form_mode = UNORM2_DECOMPOSE;
|
||||
} else if (String::Equals(isolate, form,
|
||||
isolate->factory()->NFKC_string())) {
|
||||
form_name = "nfkc";
|
||||
form_mode = UNORM2_COMPOSE;
|
||||
} else if (String::Equals(isolate, form,
|
||||
isolate->factory()->NFKD_string())) {
|
||||
form_name = "nfkc";
|
||||
form_mode = UNORM2_DECOMPOSE;
|
||||
} else {
|
||||
Handle<String> valid_forms =
|
||||
isolate->factory()->NewStringFromStaticChars("NFC, NFD, NFKC, NFKD");
|
||||
THROW_NEW_ERROR(
|
||||
isolate,
|
||||
NewRangeError(MessageTemplate::kNormalizationForm, valid_forms),
|
||||
String);
|
||||
}
|
||||
}
|
||||
|
||||
int length = string->length();
|
||||
string = String::Flatten(isolate, string);
|
||||
icu::UnicodeString result;
|
||||
std::unique_ptr<uc16[]> sap;
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
icu::UnicodeString input = ToICUUnicodeString(isolate, string);
|
||||
// Getting a singleton. Should not free it.
|
||||
const icu::Normalizer2* normalizer =
|
||||
icu::Normalizer2::getInstance(nullptr, form_name, form_mode, status);
|
||||
DCHECK(U_SUCCESS(status));
|
||||
CHECK_NOT_NULL(normalizer);
|
||||
int32_t normalized_prefix_length =
|
||||
normalizer->spanQuickCheckYes(input, status);
|
||||
// Quick return if the input is already normalized.
|
||||
if (length == normalized_prefix_length) return string;
|
||||
icu::UnicodeString unnormalized =
|
||||
input.tempSubString(normalized_prefix_length);
|
||||
// Read-only alias of the normalized prefix.
|
||||
result.setTo(false, input.getBuffer(), normalized_prefix_length);
|
||||
// copy-on-write; normalize the suffix and append to |result|.
|
||||
normalizer->normalizeSecondAndAppend(result, unnormalized, status);
|
||||
|
||||
if (U_FAILURE(status)) {
|
||||
THROW_NEW_ERROR(isolate, NewTypeError(MessageTemplate::kIcuError), String);
|
||||
}
|
||||
|
||||
return Intl::ToString(isolate, result);
|
||||
}
|
||||
|
||||
// ICUTimezoneCache calls out to ICU for TimezoneCache
|
||||
// functionality in a straightforward way.
|
||||
class ICUTimezoneCache : public base::TimezoneCache {
|
||||
|
@ -216,6 +216,9 @@ class Intl {
|
||||
Isolate* isolate, Handle<String> text,
|
||||
icu::BreakIterator* break_iterator);
|
||||
|
||||
// ecma262 #sec-string.prototype.normalize
|
||||
V8_WARN_UNUSED_RESULT static MaybeHandle<String> Normalize(
|
||||
Isolate* isolate, Handle<String> string, Handle<Object> form_input);
|
||||
static base::TimezoneCache* CreateTimeZoneCache();
|
||||
|
||||
// Convert a Handle<String> to icu::UnicodeString
|
||||
|
@ -168,5 +168,45 @@ Handle<String> JSV8BreakIterator::TypeAsString() const {
|
||||
}
|
||||
}
|
||||
|
||||
Handle<Object> JSV8BreakIterator::Current(
|
||||
Isolate* isolate, Handle<JSV8BreakIterator> break_iterator) {
|
||||
return isolate->factory()->NewNumberFromInt(
|
||||
break_iterator->break_iterator()->raw()->current());
|
||||
}
|
||||
|
||||
Handle<Object> JSV8BreakIterator::First(
|
||||
Isolate* isolate, Handle<JSV8BreakIterator> break_iterator) {
|
||||
return isolate->factory()->NewNumberFromInt(
|
||||
break_iterator->break_iterator()->raw()->first());
|
||||
}
|
||||
|
||||
Handle<Object> JSV8BreakIterator::Next(
|
||||
Isolate* isolate, Handle<JSV8BreakIterator> break_iterator) {
|
||||
return isolate->factory()->NewNumberFromInt(
|
||||
break_iterator->break_iterator()->raw()->next());
|
||||
}
|
||||
|
||||
String* JSV8BreakIterator::BreakType(Isolate* isolate,
|
||||
Handle<JSV8BreakIterator> break_iterator) {
|
||||
int32_t status = break_iterator->break_iterator()->raw()->getRuleStatus();
|
||||
// Keep return values in sync with JavaScript BreakType enum.
|
||||
if (status >= UBRK_WORD_NONE && status < UBRK_WORD_NONE_LIMIT) {
|
||||
return ReadOnlyRoots(isolate).none_string();
|
||||
}
|
||||
if (status >= UBRK_WORD_NUMBER && status < UBRK_WORD_NUMBER_LIMIT) {
|
||||
return ReadOnlyRoots(isolate).number_string();
|
||||
}
|
||||
if (status >= UBRK_WORD_LETTER && status < UBRK_WORD_LETTER_LIMIT) {
|
||||
return ReadOnlyRoots(isolate).letter_string();
|
||||
}
|
||||
if (status >= UBRK_WORD_KANA && status < UBRK_WORD_KANA_LIMIT) {
|
||||
return ReadOnlyRoots(isolate).kana_string();
|
||||
}
|
||||
if (status >= UBRK_WORD_IDEO && status < UBRK_WORD_IDEO_LIMIT) {
|
||||
return ReadOnlyRoots(isolate).ideo_string();
|
||||
}
|
||||
return ReadOnlyRoots(isolate).unknown_string();
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
@ -26,16 +26,25 @@ namespace internal {
|
||||
class JSV8BreakIterator : public JSObject {
|
||||
public:
|
||||
V8_WARN_UNUSED_RESULT static MaybeHandle<JSV8BreakIterator> Initialize(
|
||||
Isolate* isolate, Handle<JSV8BreakIterator> break_iterator_holder,
|
||||
Isolate* isolate, Handle<JSV8BreakIterator> break_iterator,
|
||||
Handle<Object> input_locales, Handle<Object> input_options);
|
||||
|
||||
static Handle<JSObject> ResolvedOptions(
|
||||
Isolate* isolate, Handle<JSV8BreakIterator> break_iterator);
|
||||
|
||||
static void AdoptText(Isolate* isolate,
|
||||
Handle<JSV8BreakIterator> break_iterator_holder,
|
||||
Handle<JSV8BreakIterator> break_iterator,
|
||||
Handle<String> text);
|
||||
|
||||
static Handle<Object> Current(Isolate* isolate,
|
||||
Handle<JSV8BreakIterator> break_iterator);
|
||||
static Handle<Object> First(Isolate* isolate,
|
||||
Handle<JSV8BreakIterator> break_iterator);
|
||||
static Handle<Object> Next(Isolate* isolate,
|
||||
Handle<JSV8BreakIterator> break_iterator);
|
||||
static String* BreakType(Isolate* isolate,
|
||||
Handle<JSV8BreakIterator> break_iterator);
|
||||
|
||||
enum class Type { CHARACTER, WORD, SENTENCE, LINE, COUNT };
|
||||
inline void set_type(Type type);
|
||||
inline Type type() const;
|
||||
|
@ -296,41 +296,41 @@ KNOWN_MAPS = {
|
||||
("RO_SPACE", 0x02699): (171, "Tuple2Map"),
|
||||
("RO_SPACE", 0x02739): (173, "ArrayBoilerplateDescriptionMap"),
|
||||
("RO_SPACE", 0x02a79): (161, "InterceptorInfoMap"),
|
||||
("RO_SPACE", 0x05001): (153, "AccessCheckInfoMap"),
|
||||
("RO_SPACE", 0x05051): (154, "AccessorInfoMap"),
|
||||
("RO_SPACE", 0x050a1): (155, "AccessorPairMap"),
|
||||
("RO_SPACE", 0x050f1): (156, "AliasedArgumentsEntryMap"),
|
||||
("RO_SPACE", 0x05141): (157, "AllocationMementoMap"),
|
||||
("RO_SPACE", 0x05191): (158, "AsyncGeneratorRequestMap"),
|
||||
("RO_SPACE", 0x051e1): (159, "DebugInfoMap"),
|
||||
("RO_SPACE", 0x05231): (160, "FunctionTemplateInfoMap"),
|
||||
("RO_SPACE", 0x05281): (162, "InterpreterDataMap"),
|
||||
("RO_SPACE", 0x052d1): (163, "ModuleInfoEntryMap"),
|
||||
("RO_SPACE", 0x05321): (164, "ModuleMap"),
|
||||
("RO_SPACE", 0x05371): (165, "ObjectTemplateInfoMap"),
|
||||
("RO_SPACE", 0x053c1): (166, "PromiseCapabilityMap"),
|
||||
("RO_SPACE", 0x05411): (167, "PromiseReactionMap"),
|
||||
("RO_SPACE", 0x05461): (168, "PrototypeInfoMap"),
|
||||
("RO_SPACE", 0x054b1): (169, "ScriptMap"),
|
||||
("RO_SPACE", 0x05501): (170, "StackFrameInfoMap"),
|
||||
("RO_SPACE", 0x05551): (172, "Tuple3Map"),
|
||||
("RO_SPACE", 0x055a1): (174, "WasmDebugInfoMap"),
|
||||
("RO_SPACE", 0x055f1): (175, "WasmExportedFunctionDataMap"),
|
||||
("RO_SPACE", 0x05641): (176, "CallableTaskMap"),
|
||||
("RO_SPACE", 0x05691): (177, "CallbackTaskMap"),
|
||||
("RO_SPACE", 0x056e1): (178, "PromiseFulfillReactionJobTaskMap"),
|
||||
("RO_SPACE", 0x05731): (179, "PromiseRejectReactionJobTaskMap"),
|
||||
("RO_SPACE", 0x05781): (180, "PromiseResolveThenableJobTaskMap"),
|
||||
("RO_SPACE", 0x057d1): (181, "MicrotaskQueueMap"),
|
||||
("RO_SPACE", 0x05821): (182, "AllocationSiteWithWeakNextMap"),
|
||||
("RO_SPACE", 0x05871): (182, "AllocationSiteWithoutWeakNextMap"),
|
||||
("RO_SPACE", 0x058c1): (214, "LoadHandler1Map"),
|
||||
("RO_SPACE", 0x05911): (214, "LoadHandler2Map"),
|
||||
("RO_SPACE", 0x05961): (214, "LoadHandler3Map"),
|
||||
("RO_SPACE", 0x059b1): (221, "StoreHandler0Map"),
|
||||
("RO_SPACE", 0x05a01): (221, "StoreHandler1Map"),
|
||||
("RO_SPACE", 0x05a51): (221, "StoreHandler2Map"),
|
||||
("RO_SPACE", 0x05aa1): (221, "StoreHandler3Map"),
|
||||
("RO_SPACE", 0x05061): (153, "AccessCheckInfoMap"),
|
||||
("RO_SPACE", 0x050b1): (154, "AccessorInfoMap"),
|
||||
("RO_SPACE", 0x05101): (155, "AccessorPairMap"),
|
||||
("RO_SPACE", 0x05151): (156, "AliasedArgumentsEntryMap"),
|
||||
("RO_SPACE", 0x051a1): (157, "AllocationMementoMap"),
|
||||
("RO_SPACE", 0x051f1): (158, "AsyncGeneratorRequestMap"),
|
||||
("RO_SPACE", 0x05241): (159, "DebugInfoMap"),
|
||||
("RO_SPACE", 0x05291): (160, "FunctionTemplateInfoMap"),
|
||||
("RO_SPACE", 0x052e1): (162, "InterpreterDataMap"),
|
||||
("RO_SPACE", 0x05331): (163, "ModuleInfoEntryMap"),
|
||||
("RO_SPACE", 0x05381): (164, "ModuleMap"),
|
||||
("RO_SPACE", 0x053d1): (165, "ObjectTemplateInfoMap"),
|
||||
("RO_SPACE", 0x05421): (166, "PromiseCapabilityMap"),
|
||||
("RO_SPACE", 0x05471): (167, "PromiseReactionMap"),
|
||||
("RO_SPACE", 0x054c1): (168, "PrototypeInfoMap"),
|
||||
("RO_SPACE", 0x05511): (169, "ScriptMap"),
|
||||
("RO_SPACE", 0x05561): (170, "StackFrameInfoMap"),
|
||||
("RO_SPACE", 0x055b1): (172, "Tuple3Map"),
|
||||
("RO_SPACE", 0x05601): (174, "WasmDebugInfoMap"),
|
||||
("RO_SPACE", 0x05651): (175, "WasmExportedFunctionDataMap"),
|
||||
("RO_SPACE", 0x056a1): (176, "CallableTaskMap"),
|
||||
("RO_SPACE", 0x056f1): (177, "CallbackTaskMap"),
|
||||
("RO_SPACE", 0x05741): (178, "PromiseFulfillReactionJobTaskMap"),
|
||||
("RO_SPACE", 0x05791): (179, "PromiseRejectReactionJobTaskMap"),
|
||||
("RO_SPACE", 0x057e1): (180, "PromiseResolveThenableJobTaskMap"),
|
||||
("RO_SPACE", 0x05831): (181, "MicrotaskQueueMap"),
|
||||
("RO_SPACE", 0x05881): (182, "AllocationSiteWithWeakNextMap"),
|
||||
("RO_SPACE", 0x058d1): (182, "AllocationSiteWithoutWeakNextMap"),
|
||||
("RO_SPACE", 0x05921): (214, "LoadHandler1Map"),
|
||||
("RO_SPACE", 0x05971): (214, "LoadHandler2Map"),
|
||||
("RO_SPACE", 0x059c1): (214, "LoadHandler3Map"),
|
||||
("RO_SPACE", 0x05a11): (221, "StoreHandler0Map"),
|
||||
("RO_SPACE", 0x05a61): (221, "StoreHandler1Map"),
|
||||
("RO_SPACE", 0x05ab1): (221, "StoreHandler2Map"),
|
||||
("RO_SPACE", 0x05b01): (221, "StoreHandler3Map"),
|
||||
("MAP_SPACE", 0x00139): (1057, "ExternalMap"),
|
||||
("MAP_SPACE", 0x00189): (1073, "JSMessageObjectMap"),
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user