v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
js-relative-time-format.cc
Go to the documentation of this file.
1// Copyright 2018 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef V8_INTL_SUPPORT
6#error Internationalization is expected to be enabled.
7#endif // V8_INTL_SUPPORT
8
10
11#include <map>
12#include <memory>
13#include <string>
14
16#include "src/heap/factory.h"
23#include "unicode/decimfmt.h"
24#include "unicode/numfmt.h"
25#include "unicode/reldatefmt.h"
26#include "unicode/unum.h"
27
28namespace v8 {
29namespace internal {
30
31namespace {
32// Style: identifying the relative time format style used.
33//
34// ecma402/#sec-properties-of-intl-relativetimeformat-instances
35
36enum class Style {
37 LONG, // Everything spelled out.
38 SHORT, // Abbreviations used when possible.
39 NARROW // Use the shortest possible form.
40};
41
42UDateRelativeDateTimeFormatterStyle toIcuStyle(Style style) {
43 switch (style) {
44 case Style::LONG:
45 return UDAT_STYLE_LONG;
46 case Style::SHORT:
47 return UDAT_STYLE_SHORT;
48 case Style::NARROW:
49 return UDAT_STYLE_NARROW;
50 }
52}
53
54Style fromIcuStyle(UDateRelativeDateTimeFormatterStyle icu_style) {
55 switch (icu_style) {
56 case UDAT_STYLE_LONG:
57 return Style::LONG;
58 case UDAT_STYLE_SHORT:
59 return Style::SHORT;
60 case UDAT_STYLE_NARROW:
61 return Style::NARROW;
62 case UDAT_STYLE_COUNT:
64 }
66}
67} // namespace
68
70 Isolate* isolate, DirectHandle<Map> map, DirectHandle<Object> locales,
71 DirectHandle<Object> input_options) {
72 // 1. Let requestedLocales be ? CanonicalizeLocaleList(locales).
73 Maybe<std::vector<std::string>> maybe_requested_locales =
74 Intl::CanonicalizeLocaleList(isolate, locales);
75 MAYBE_RETURN(maybe_requested_locales, DirectHandle<JSRelativeTimeFormat>());
76 std::vector<std::string> requested_locales =
77 maybe_requested_locales.FromJust();
78
79 // 2. Set options to ? CoerceOptionsToObject(options).
81 const char* service = "Intl.RelativeTimeFormat";
83 isolate, options, CoerceOptionsToObject(isolate, input_options, service));
84
85 // 4. Let opt be a new Record.
86 // 5. Let matcher be ? GetOption(options, "localeMatcher", "string", «
87 // "lookup", "best fit" », "best fit").
88 // 6. Set opt.[[localeMatcher]] to matcher.
89 Maybe<Intl::MatcherOption> maybe_locale_matcher =
90 Intl::GetLocaleMatcher(isolate, options, service);
92 Intl::MatcherOption matcher = maybe_locale_matcher.FromJust();
93
94 // 7. Let _numberingSystem_ be ? GetOption(_options_, `"numberingSystem"`,
95 // `"string"`, *undefined*, *undefined*).
96 std::unique_ptr<char[]> numbering_system_str = nullptr;
97 Maybe<bool> maybe_numberingSystem = Intl::GetNumberingSystem(
98 isolate, options, service, &numbering_system_str);
99 // 8. If _numberingSystem_ is not *undefined*, then
100 // a. If _numberingSystem_ does not match the
101 // `(3*8alphanum) *("-" (3*8alphanum))` sequence, throw a *RangeError*
102 // exception.
103 MAYBE_RETURN(maybe_numberingSystem,
105
106 // 9. Set _opt_.[[nu]] to _numberingSystem_.
107
108 // 10. Let localeData be %RelativeTimeFormat%.[[LocaleData]].
109 // 11. Let r be
110 // ResolveLocale(%RelativeTimeFormat%.[[AvailableLocales]],
111 // requestedLocales, opt,
112 // %RelativeTimeFormat%.[[RelevantExtensionKeys]], localeData).
113 Maybe<Intl::ResolvedLocale> maybe_resolve_locale =
115 requested_locales, matcher, {"nu"});
116 if (maybe_resolve_locale.IsNothing()) {
117 THROW_NEW_ERROR(isolate, NewRangeError(MessageTemplate::kIcuError));
118 }
119 Intl::ResolvedLocale r = maybe_resolve_locale.FromJust();
120
121 UErrorCode status = U_ZERO_ERROR;
122
123 icu::Locale icu_locale = r.icu_locale;
124 if (numbering_system_str != nullptr) {
125 auto nu_extension_it = r.extensions.find("nu");
126 if (nu_extension_it != r.extensions.end() &&
127 nu_extension_it->second != numbering_system_str.get()) {
128 icu_locale.setUnicodeKeywordValue("nu", nullptr, status);
129 DCHECK(U_SUCCESS(status));
130 }
131 }
132 // 12. Let locale be r.[[Locale]].
133 Maybe<std::string> maybe_locale_str = Intl::ToLanguageTag(icu_locale);
135
136 // 13. Set relativeTimeFormat.[[Locale]] to locale.
137 DirectHandle<String> locale_str =
138 isolate->factory()->NewStringFromAsciiChecked(
139 maybe_locale_str.FromJust().c_str());
140
141 // 14. Set relativeTimeFormat.[[NumberingSystem]] to r.[[nu]].
142 if (numbering_system_str != nullptr &&
143 Intl::IsValidNumberingSystem(numbering_system_str.get())) {
144 icu_locale.setUnicodeKeywordValue("nu", numbering_system_str.get(), status);
145 DCHECK(U_SUCCESS(status));
146 }
147 // 15. Let dataLocale be r.[[DataLocale]].
148
149 // 16. Let s be ? GetOption(options, "style", "string",
150 // «"long", "short", "narrow"», "long").
152 isolate, options, "style", service, {"long", "short", "narrow"},
153 {Style::LONG, Style::SHORT, Style::NARROW}, Style::LONG);
155 Style style_enum = maybe_style.FromJust();
156
157 // 17. Set relativeTimeFormat.[[Style]] to s.
158
159 // 18. Let numeric be ? GetOption(options, "numeric", "string",
160 // «"always", "auto"», "always").
162 isolate, options, "numeric", service, {"always", "auto"},
163 {Numeric::ALWAYS, Numeric::AUTO}, Numeric::ALWAYS);
165 Numeric numeric_enum = maybe_numeric.FromJust();
166
167 // 19. Set relativeTimeFormat.[[Numeric]] to numeric.
168
169 // 23. Let relativeTimeFormat.[[NumberFormat]] be
170 // ? Construct(%NumberFormat%, « nfLocale, nfOptions »).
171 icu::NumberFormat* number_format =
172 icu::NumberFormat::createInstance(icu_locale, UNUM_DECIMAL, status);
173 if (U_FAILURE(status)) {
174 // Data build filter files excluded data in "rbnf_tree" since ECMA402 does
175 // not support "algorithmic" numbering systems. Therefore we may get the
176 // U_MISSING_RESOURCE_ERROR here. Fallback to locale without the numbering
177 // system and create the object again.
178 if (status == U_MISSING_RESOURCE_ERROR) {
179 delete number_format;
180 status = U_ZERO_ERROR;
181 icu_locale.setUnicodeKeywordValue("nu", nullptr, status);
182 DCHECK(U_SUCCESS(status));
183 number_format =
184 icu::NumberFormat::createInstance(icu_locale, UNUM_DECIMAL, status);
185 }
186 if (U_FAILURE(status) || number_format == nullptr) {
187 delete number_format;
188 THROW_NEW_ERROR(isolate, NewRangeError(MessageTemplate::kIcuError));
189 }
190 }
191
192 if (number_format->getDynamicClassID() ==
193 icu::DecimalFormat::getStaticClassID()) {
194 icu::DecimalFormat* decimal_format =
195 static_cast<icu::DecimalFormat*>(number_format);
196 decimal_format->setMinimumGroupingDigits(-2);
197 }
198
199 // Change UDISPCTX_CAPITALIZATION_NONE to other values if
200 // ECMA402 later include option to change capitalization.
201 // Ref: https://github.com/tc39/proposal-intl-relative-time/issues/11
202 std::shared_ptr<icu::RelativeDateTimeFormatter> icu_formatter =
203 std::make_shared<icu::RelativeDateTimeFormatter>(
204 icu_locale, number_format, toIcuStyle(style_enum),
205 UDISPCTX_CAPITALIZATION_NONE, status);
206 if (U_FAILURE(status) || icu_formatter == nullptr) {
207 THROW_NEW_ERROR(isolate, NewRangeError(MessageTemplate::kIcuError));
208 }
209
210 DirectHandle<String> numbering_system_string =
211 isolate->factory()->NewStringFromAsciiChecked(
212 Intl::GetNumberingSystem(icu_locale).c_str());
213
216 std::move(icu_formatter));
217
218 DirectHandle<JSRelativeTimeFormat> relative_time_format_holder =
220 isolate->factory()->NewFastOrSlowJSObjectFromMap(map));
221
223 relative_time_format_holder->set_flags(0);
224 relative_time_format_holder->set_locale(*locale_str);
225 relative_time_format_holder->set_numberingSystem(*numbering_system_string);
226 relative_time_format_holder->set_numeric(numeric_enum);
227 relative_time_format_holder->set_icu_formatter(*managed_formatter);
228
229 // 25. Return relativeTimeFormat.
230 return relative_time_format_holder;
231}
232
233namespace {
234
235DirectHandle<String> StyleAsString(Isolate* isolate, Style style) {
236 switch (style) {
237 case Style::LONG:
238 return isolate->factory()->long_string();
239 case Style::SHORT:
240 return isolate->factory()->short_string();
241 case Style::NARROW:
242 return isolate->factory()->narrow_string();
243 }
244 UNREACHABLE();
245}
246
247} // namespace
248
250 Isolate* isolate, DirectHandle<JSRelativeTimeFormat> format_holder) {
251 Factory* factory = isolate->factory();
252 icu::RelativeDateTimeFormatter* formatter =
253 format_holder->icu_formatter()->raw();
254 DCHECK_NOT_NULL(formatter);
256 factory->NewJSObject(isolate->object_function());
257 DirectHandle<String> locale(format_holder->locale(), isolate);
258 DirectHandle<String> numberingSystem(format_holder->numberingSystem(),
259 isolate);
260 JSObject::AddProperty(isolate, result, factory->locale_string(), locale,
261 NONE);
263 isolate, result, factory->style_string(),
264 StyleAsString(isolate, fromIcuStyle(formatter->getFormatStyle())), NONE);
265 JSObject::AddProperty(isolate, result, factory->numeric_string(),
266 format_holder->NumericAsString(isolate), NONE);
267 JSObject::AddProperty(isolate, result, factory->numberingSystem_string(),
268 numberingSystem, NONE);
269 return result;
270}
271
273 switch (numeric()) {
274 case Numeric::ALWAYS:
275 return isolate->factory()->always_string();
276 case Numeric::AUTO:
277 return isolate->factory()->auto_string();
278 }
279 UNREACHABLE();
280}
281
282namespace {
283
284DirectHandle<String> UnitAsString(Isolate* isolate,
285 URelativeDateTimeUnit unit_enum) {
286 Factory* factory = isolate->factory();
287 switch (unit_enum) {
288 case UDAT_REL_UNIT_SECOND:
289 return factory->second_string();
290 case UDAT_REL_UNIT_MINUTE:
291 return factory->minute_string();
292 case UDAT_REL_UNIT_HOUR:
293 return factory->hour_string();
294 case UDAT_REL_UNIT_DAY:
295 return factory->day_string();
296 case UDAT_REL_UNIT_WEEK:
297 return factory->week_string();
298 case UDAT_REL_UNIT_MONTH:
299 return factory->month_string();
300 case UDAT_REL_UNIT_QUARTER:
301 return factory->quarter_string();
302 case UDAT_REL_UNIT_YEAR:
303 return factory->year_string();
304 default:
305 UNREACHABLE();
306 }
307}
308
309bool GetURelativeDateTimeUnit(DirectHandle<String> unit,
310 URelativeDateTimeUnit* unit_enum) {
311 std::unique_ptr<char[]> unit_str = unit->ToCString();
312 if ((strcmp("second", unit_str.get()) == 0) ||
313 (strcmp("seconds", unit_str.get()) == 0)) {
314 *unit_enum = UDAT_REL_UNIT_SECOND;
315 } else if ((strcmp("minute", unit_str.get()) == 0) ||
316 (strcmp("minutes", unit_str.get()) == 0)) {
317 *unit_enum = UDAT_REL_UNIT_MINUTE;
318 } else if ((strcmp("hour", unit_str.get()) == 0) ||
319 (strcmp("hours", unit_str.get()) == 0)) {
320 *unit_enum = UDAT_REL_UNIT_HOUR;
321 } else if ((strcmp("day", unit_str.get()) == 0) ||
322 (strcmp("days", unit_str.get()) == 0)) {
323 *unit_enum = UDAT_REL_UNIT_DAY;
324 } else if ((strcmp("week", unit_str.get()) == 0) ||
325 (strcmp("weeks", unit_str.get()) == 0)) {
326 *unit_enum = UDAT_REL_UNIT_WEEK;
327 } else if ((strcmp("month", unit_str.get()) == 0) ||
328 (strcmp("months", unit_str.get()) == 0)) {
329 *unit_enum = UDAT_REL_UNIT_MONTH;
330 } else if ((strcmp("quarter", unit_str.get()) == 0) ||
331 (strcmp("quarters", unit_str.get()) == 0)) {
332 *unit_enum = UDAT_REL_UNIT_QUARTER;
333 } else if ((strcmp("year", unit_str.get()) == 0) ||
334 (strcmp("years", unit_str.get()) == 0)) {
335 *unit_enum = UDAT_REL_UNIT_YEAR;
336 } else {
337 return false;
338 }
339 return true;
340}
341
342template <typename T>
343MaybeDirectHandle<T> FormatCommon(
344 Isolate* isolate, DirectHandle<JSRelativeTimeFormat> format,
345 Handle<Object> value_obj, Handle<Object> unit_obj, const char* func_name,
346 MaybeDirectHandle<T> (*formatToResult)(
347 Isolate*, const icu::FormattedRelativeDateTime&, DirectHandle<String>,
348 bool)) {
349 // 3. Let value be ? ToNumber(value).
350 DirectHandle<Object> value;
351 ASSIGN_RETURN_ON_EXCEPTION(isolate, value,
352 Object::ToNumber(isolate, value_obj));
353 double number = Object::NumberValue(*value);
354 // 4. Let unit be ? ToString(unit).
355 Handle<String> unit;
357 Object::ToString(isolate, unit_obj));
358 // 4. If isFinite(value) is false, then throw a RangeError exception.
359 if (!std::isfinite(number)) {
361 isolate, NewRangeError(
362 MessageTemplate::kNotFiniteNumber,
363 isolate->factory()->NewStringFromAsciiChecked(func_name)));
364 }
365 icu::RelativeDateTimeFormatter* formatter = format->icu_formatter()->raw();
366 DCHECK_NOT_NULL(formatter);
367 URelativeDateTimeUnit unit_enum;
368 if (!GetURelativeDateTimeUnit(unit, &unit_enum)) {
370 isolate,
371 NewRangeError(MessageTemplate::kInvalidUnit,
372 isolate->factory()->NewStringFromAsciiChecked(func_name),
373 unit));
374 }
375 UErrorCode status = U_ZERO_ERROR;
376 icu::FormattedRelativeDateTime formatted =
377 (format->numeric() == JSRelativeTimeFormat::Numeric::ALWAYS)
378 ? formatter->formatNumericToValue(number, unit_enum, status)
379 : formatter->formatToValue(number, unit_enum, status);
380 if (U_FAILURE(status)) {
381 THROW_NEW_ERROR(isolate, NewTypeError(MessageTemplate::kIcuError));
382 }
383 return formatToResult(isolate, formatted, UnitAsString(isolate, unit_enum),
384 IsNaN(*value));
385}
386
387MaybeDirectHandle<String> FormatToString(
388 Isolate* isolate, const icu::FormattedRelativeDateTime& formatted,
389 DirectHandle<String> unit, bool is_nan) {
390 UErrorCode status = U_ZERO_ERROR;
391 icu::UnicodeString result = formatted.toString(status);
392 if (U_FAILURE(status)) {
393 THROW_NEW_ERROR(isolate, NewTypeError(MessageTemplate::kIcuError));
394 }
395 return Intl::ToString(isolate, result);
396}
397
398Maybe<bool> AddLiteral(Isolate* isolate, DirectHandle<JSArray> array,
399 const icu::UnicodeString& string, int32_t index,
400 int32_t start, int32_t limit) {
401 DirectHandle<String> substring;
403 isolate, substring, Intl::ToString(isolate, string, start, limit),
404 Nothing<bool>());
405 Intl::AddElement(isolate, array, index, isolate->factory()->literal_string(),
406 substring);
407 return Just(true);
408}
409
410Maybe<bool> AddUnit(Isolate* isolate, DirectHandle<JSArray> array,
411 const icu::UnicodeString& string, int32_t index,
412 const NumberFormatSpan& part, DirectHandle<String> unit,
413 bool is_nan) {
414 DirectHandle<String> substring;
416 isolate, substring,
417 Intl::ToString(isolate, string, part.begin_pos, part.end_pos),
418 Nothing<bool>());
419 Intl::AddElement(isolate, array, index,
420 Intl::NumberFieldToType(isolate, part, string, is_nan),
421 substring, isolate->factory()->unit_string(), unit);
422 return Just(true);
423}
424
425MaybeDirectHandle<JSArray> FormatToJSArray(
426 Isolate* isolate, const icu::FormattedRelativeDateTime& formatted,
427 DirectHandle<String> unit, bool is_nan) {
428 UErrorCode status = U_ZERO_ERROR;
429 icu::UnicodeString string = formatted.toString(status);
430
431 Factory* factory = isolate->factory();
432 DirectHandle<JSArray> array = factory->NewJSArray(0);
433 icu::ConstrainedFieldPosition cfpos;
434 cfpos.constrainCategory(UFIELD_CATEGORY_NUMBER);
435 int32_t index = 0;
436
437 int32_t previous_end = 0;
438 DirectHandle<String> substring;
439 std::vector<std::pair<int32_t, int32_t>> groups;
440 while (formatted.nextPosition(cfpos, status) && U_SUCCESS(status)) {
441 int32_t category = cfpos.getCategory();
442 int32_t field = cfpos.getField();
443 int32_t start = cfpos.getStart();
444 int32_t limit = cfpos.getLimit();
445 if (category == UFIELD_CATEGORY_NUMBER) {
446 if (field == UNUM_GROUPING_SEPARATOR_FIELD) {
447 groups.push_back(std::pair<int32_t, int32_t>(start, limit));
448 continue;
449 }
450 if (start > previous_end) {
451 Maybe<bool> maybe_added =
452 AddLiteral(isolate, array, string, index++, previous_end, start);
453 MAYBE_RETURN(maybe_added, DirectHandle<JSArray>());
454 }
455 if (field == UNUM_INTEGER_FIELD) {
456 for (auto start_limit : groups) {
457 if (start_limit.first > start) {
458 Maybe<bool> maybe_added =
459 AddUnit(isolate, array, string, index++,
460 NumberFormatSpan(field, start, start_limit.first), unit,
461 is_nan);
462 MAYBE_RETURN(maybe_added, DirectHandle<JSArray>());
463 maybe_added =
464 AddUnit(isolate, array, string, index++,
465 NumberFormatSpan(UNUM_GROUPING_SEPARATOR_FIELD,
466 start_limit.first, start_limit.second),
467 unit, is_nan);
468 MAYBE_RETURN(maybe_added, DirectHandle<JSArray>());
469 start = start_limit.second;
470 }
471 }
472 }
473 Maybe<bool> maybe_added =
474 AddUnit(isolate, array, string, index++,
475 NumberFormatSpan(field, start, limit), unit, is_nan);
476 MAYBE_RETURN(maybe_added, DirectHandle<JSArray>());
477 previous_end = limit;
478 }
479 }
480 if (U_FAILURE(status)) {
481 THROW_NEW_ERROR(isolate, NewTypeError(MessageTemplate::kIcuError));
482 }
483 if (string.length() > previous_end) {
484 Maybe<bool> maybe_added = AddLiteral(isolate, array, string, index,
485 previous_end, string.length());
486 MAYBE_RETURN(maybe_added, DirectHandle<JSArray>());
487 }
488
490 return array;
491}
492
493} // namespace
494
496 Isolate* isolate, Handle<Object> value_obj, Handle<Object> unit_obj,
498 return FormatCommon<String>(isolate, format, value_obj, unit_obj,
499 "Intl.RelativeTimeFormat.prototype.format",
500 FormatToString);
501}
502
504 Isolate* isolate, Handle<Object> value_obj, Handle<Object> unit_obj,
506 return FormatCommon<JSArray>(
507 isolate, format, value_obj, unit_obj,
508 "Intl.RelativeTimeFormat.prototype.formatToParts", FormatToJSArray);
509}
510
511const std::set<std::string>& JSRelativeTimeFormat::GetAvailableLocales() {
512 // Since RelativeTimeFormatter does not have a method to list all
513 // available locales, work around by calling the DateFormat.
515}
516
517} // namespace internal
518} // namespace v8
V8_INLINE T FromJust() const &
Definition v8-maybe.h:64
V8_INLINE bool IsNothing() const
Definition v8-maybe.h:35
Handle< JSArray > NewJSArray(ElementsKind elements_kind, int length, int capacity, ArrayStorageAllocationMode mode=ArrayStorageAllocationMode::DONT_INITIALIZE_ARRAY_ELEMENTS, AllocationType allocation=AllocationType::kYoung)
Definition factory.cc:3211
Handle< JSObject > NewJSObject(DirectHandle< JSFunction > constructor, AllocationType allocation=AllocationType::kYoung, NewJSObjectType=NewJSObjectType::kNoAPIWrapper)
Definition factory.cc:2985
static void AddElement(Isolate *isolate, DirectHandle< JSArray > array, int index, DirectHandle< String > field_type_string, DirectHandle< String > value)
static std::string GetNumberingSystem(const icu::Locale &icu_locale)
static V8_WARN_UNUSED_RESULT MaybeHandle< String > ToString(Isolate *isolate, const icu::UnicodeString &string)
static Maybe< std::vector< std::string > > CanonicalizeLocaleList(Isolate *isolate, DirectHandle< Object > locales, bool only_return_one_result=false)
static const std::set< std::string > & GetAvailableLocalesForDateFormat()
static Maybe< ResolvedLocale > ResolveLocale(Isolate *isolate, const std::set< std::string > &available_locales, const std::vector< std::string > &requested_locales, MatcherOption options, const std::set< std::string > &relevant_extension_keys)
static V8_WARN_UNUSED_RESULT Maybe< MatcherOption > GetLocaleMatcher(Isolate *isolate, DirectHandle< JSReceiver > options, const char *method_name)
static Maybe< std::string > ToLanguageTag(const icu::Locale &locale)
static bool IsValidNumberingSystem(const std::string &value)
static DirectHandle< String > NumberFieldToType(Isolate *isolate, const NumberFormatSpan &part, const icu::UnicodeString &text, bool is_nan)
static V8_EXPORT_PRIVATE void AddProperty(Isolate *isolate, DirectHandle< JSObject > object, DirectHandle< Name > name, DirectHandle< Object > value, PropertyAttributes attributes)
static void ValidateElements(Tagged< JSObject > object)
static V8_WARN_UNUSED_RESULT MaybeDirectHandle< JSArray > FormatToParts(Isolate *isolate, Handle< Object > value_obj, Handle< Object > unit_obj, DirectHandle< JSRelativeTimeFormat > format)
static V8_WARN_UNUSED_RESULT MaybeDirectHandle< String > Format(Isolate *isolate, Handle< Object > value_obj, Handle< Object > unit_obj, DirectHandle< JSRelativeTimeFormat > format)
static V8_WARN_UNUSED_RESULT DirectHandle< JSObject > ResolvedOptions(Isolate *isolate, DirectHandle< JSRelativeTimeFormat > format_holder)
static V8_EXPORT_PRIVATE const std::set< std::string > & GetAvailableLocales()
static V8_WARN_UNUSED_RESULT MaybeDirectHandle< JSRelativeTimeFormat > New(Isolate *isolate, DirectHandle< Map > map, DirectHandle< Object > locales, DirectHandle< Object > options)
Handle< String > NumericAsString(Isolate *isolate) const
static DirectHandle< Managed< CppType > > From(Isolate *isolate, size_t estimated_size, std::shared_ptr< CppType > shared_ptr, AllocationType allocation_type=AllocationType::kYoung)
Definition managed-inl.h:27
static V8_WARN_UNUSED_RESULT HandleType< String >::MaybeType ToString(Isolate *isolate, HandleType< T > input)
static V8_WARN_UNUSED_RESULT HandleType< Number >::MaybeType ToNumber(Isolate *isolate, HandleType< T > input)
static double NumberValue(Tagged< Number > obj)
int start
#define ASSIGN_RETURN_ON_EXCEPTION(isolate, dst, call)
Definition isolate.h:291
#define THROW_NEW_ERROR(isolate, call)
Definition isolate.h:307
#define ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, dst, call, value)
Definition isolate.h:276
#define MAYBE_RETURN(call, value)
Definition isolate.h:408
icu::number::FormattedNumber formatted
JSDurationFormat::FieldStyle style
DirectHandle< JSReceiver > options
ZoneVector< RpoNumber > & result
int r
Definition mul-fft.cc:298
int int32_t
Definition unicode.cc:40
bool IsNaN(Tagged< Object > obj)
return value
Definition map-inl.h:893
MaybeDirectHandle< JSReceiver > CoerceOptionsToObject(Isolate *isolate, DirectHandle< Object > options, const char *method_name)
Maybe< bool > GetStringOption(Isolate *isolate, DirectHandle< JSReceiver > options, const char *property, const std::vector< const char * > &values, const char *method_name, std::unique_ptr< char[]> *result)
Tagged< To > Cast(Tagged< From > value, const v8::SourceLocation &loc=INIT_SOURCE_LOCATION_IN_DEBUG)
Definition casting.h:150
Maybe< T > Nothing()
Definition v8-maybe.h:112
Maybe< T > Just(const T &t)
Definition v8-maybe.h:117
uint32_t substring
#define DCHECK_NOT_NULL(val)
Definition logging.h:492
#define DCHECK(condition)
Definition logging.h:482
long LONG