From 098310f4259024ba82dab7390e65cf5bdcb89bba Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Thu, 30 Jun 2022 19:30:18 +0100 Subject: [PATCH] js: Move static_cast responsibility out of the pretty-print functions This is something the caller should do. --- Userland/Utilities/js.cpp | 341 +++++++++++++++++--------------------- 1 file changed, 156 insertions(+), 185 deletions(-) diff --git a/Userland/Utilities/js.cpp b/Userland/Utilities/js.cpp index 82e708aa8c..a72f30c1ed 100644 --- a/Userland/Utilities/js.cpp +++ b/Userland/Utilities/js.cpp @@ -318,11 +318,11 @@ static void print_object(JS::Object& object, HashTable& seen_object js_out("}}"); } -static void print_function(JS::Object const& object, HashTable&) +static void print_function(JS::FunctionObject const& function_object, HashTable&) { - if (is(object)) { - auto const& function = static_cast(object); - switch (function.kind()) { + if (is(function_object)) { + auto const& ecmascript_function_object = static_cast(function_object); + switch (ecmascript_function_object.kind()) { case JS::FunctionKind::Normal: print_type("Function"); break; @@ -339,18 +339,18 @@ static void print_function(JS::Object const& object, HashTable&) VERIFY_NOT_REACHED(); } } else { - print_type(object.class_name()); + print_type(function_object.class_name()); } - if (is(object)) - js_out(" {}", static_cast(object).name()); - else if (is(object)) - js_out(" {}", static_cast(object).name()); + if (is(function_object)) + js_out(" {}", static_cast(function_object).name()); + else if (is(function_object)) + js_out(" {}", static_cast(function_object).name()); } -static void print_date(JS::Object const& object, HashTable&) +static void print_date(JS::Date const& date, HashTable&) { print_type("Date"); - js_out(" \033[34;1m{}\033[0m", JS::to_date_string(static_cast(object).date_value())); + js_out(" \033[34;1m{}\033[0m", JS::to_date_string(date.date_value())); } static void print_error(JS::Object const& object, HashTable& seen_objects) @@ -368,16 +368,14 @@ static void print_error(JS::Object const& object, HashTable& seen_o } } -static void print_regexp_object(JS::Object const& object, HashTable&) +static void print_regexp_object(JS::RegExpObject const& regexp_object, HashTable&) { - auto& regexp_object = static_cast(object); print_type("RegExp"); js_out(" \033[34;1m/{}/{}\033[0m", regexp_object.escape_regexp_pattern(), regexp_object.flags()); } -static void print_proxy_object(JS::Object const& object, HashTable& seen_objects) +static void print_proxy_object(JS::ProxyObject const& proxy_object, HashTable& seen_objects) { - auto& proxy_object = static_cast(object); print_type("Proxy"); js_out("\n target: "); print_value(&proxy_object.target(), seen_objects); @@ -385,9 +383,8 @@ static void print_proxy_object(JS::Object const& object, HashTable& print_value(&proxy_object.handler(), seen_objects); } -static void print_map(JS::Object const& object, HashTable& seen_objects) +static void print_map(JS::Map const& map, HashTable& seen_objects) { - auto& map = static_cast(object); print_type("Map"); js_out(" {{"); bool first = true; @@ -402,9 +399,8 @@ static void print_map(JS::Object const& object, HashTable& seen_obj js_out("}}"); } -static void print_set(JS::Object const& object, HashTable& seen_objects) +static void print_set(JS::Set const& set, HashTable& seen_objects) { - auto& set = static_cast(object); print_type("Set"); js_out(" {{"); bool first = true; @@ -417,9 +413,8 @@ static void print_set(JS::Object const& object, HashTable& seen_obj js_out("}}"); } -static void print_promise(JS::Object const& object, HashTable& seen_objects) +static void print_promise(JS::Promise const& promise, HashTable& seen_objects) { - auto& promise = static_cast(object); print_type("Promise"); switch (promise.state()) { case JS::Promise::State::Pending: @@ -443,9 +438,8 @@ static void print_promise(JS::Object const& object, HashTable& seen } } -static void print_array_buffer(JS::Object const& object, HashTable& seen_objects) +static void print_array_buffer(JS::ArrayBuffer const& array_buffer, HashTable& seen_objects) { - auto& array_buffer = static_cast(object); auto& buffer = array_buffer.buffer(); auto byte_length = array_buffer.byte_length(); print_type("ArrayBuffer"); @@ -471,18 +465,18 @@ static void print_array_buffer(JS::Object const& object, HashTable& } } -static void print_shadow_realm(JS::Object const&, HashTable&) +static void print_shadow_realm(JS::ShadowRealm const&, HashTable&) { // Not much we can show here that would be useful. Realm pointer address?! print_type("ShadowRealm"); } -static void print_generator(JS::Object const&, HashTable&) +static void print_generator(JS::GeneratorObject const&, HashTable&) { print_type("Generator"); } -static void print_async_generator(JS::Object const&, HashTable&) +static void print_async_generator(JS::AsyncGenerator const&, HashTable&) { print_type("AsyncGenerator"); } @@ -495,12 +489,11 @@ static void print_number(T number) requires IsArithmetic js_out("\033[0m"); } -static void print_typed_array(JS::Object const& object, HashTable& seen_objects) +static void print_typed_array(JS::TypedArrayBase const& typed_array_base, HashTable& seen_objects) { - auto& typed_array_base = static_cast(object); auto& array_buffer = *typed_array_base.viewed_array_buffer(); auto length = typed_array_base.array_length(); - print_type(object.class_name()); + print_type(typed_array_base.class_name()); js_out("\n length: "); print_value(JS::Value(length), seen_objects); js_out("\n byteLength: "); @@ -515,7 +508,7 @@ static void print_typed_array(JS::Object const& object, HashTable& js_outln(); // FIXME: This kinda sucks. #define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \ - if (is(object)) { \ + if (is(typed_array_base)) { \ js_out("[ "); \ auto& typed_array = static_cast(typed_array_base); \ auto data = typed_array.data(); \ @@ -532,9 +525,8 @@ static void print_typed_array(JS::Object const& object, HashTable& VERIFY_NOT_REACHED(); } -static void print_data_view(JS::Object const& object, HashTable& seen_objects) +static void print_data_view(JS::DataView const& data_view, HashTable& seen_objects) { - auto& data_view = static_cast(object); print_type("DataView"); js_out("\n byteLength: "); print_value(JS::Value(data_view.byte_length()), seen_objects); @@ -545,51 +537,45 @@ static void print_data_view(JS::Object const& object, HashTable& se js_out(" @ {:p}", data_view.viewed_array_buffer()); } -static void print_temporal_calendar(JS::Object const& object, HashTable& seen_objects) +static void print_temporal_calendar(JS::Temporal::Calendar const& calendar, HashTable& seen_objects) { - auto& calendar = static_cast(object); print_type("Temporal.Calendar"); js_out(" "); - print_value(JS::js_string(object.vm(), calendar.identifier()), seen_objects); + print_value(JS::js_string(calendar.vm(), calendar.identifier()), seen_objects); } -static void print_temporal_duration(JS::Object const& object, HashTable&) +static void print_temporal_duration(JS::Temporal::Duration const& duration, HashTable&) { - auto& duration = static_cast(object); print_type("Temporal.Duration"); js_out(" \033[34;1m{} y, {} M, {} w, {} d, {} h, {} m, {} s, {} ms, {} us, {} ns\033[0m", duration.years(), duration.months(), duration.weeks(), duration.days(), duration.hours(), duration.minutes(), duration.seconds(), duration.milliseconds(), duration.microseconds(), duration.nanoseconds()); } -static void print_temporal_instant(JS::Object const& object, HashTable& seen_objects) +static void print_temporal_instant(JS::Temporal::Instant const& instant, HashTable& seen_objects) { - auto& instant = static_cast(object); print_type("Temporal.Instant"); js_out(" "); // FIXME: Print human readable date and time, like in print_date() - ideally handling arbitrarily large values since we get a bigint. print_value(&instant.nanoseconds(), seen_objects); } -static void print_temporal_plain_date(JS::Object const& object, HashTable& seen_objects) +static void print_temporal_plain_date(JS::Temporal::PlainDate const& plain_date, HashTable& seen_objects) { - auto& plain_date = static_cast(object); print_type("Temporal.PlainDate"); js_out(" \033[34;1m{:04}-{:02}-{:02}\033[0m", plain_date.iso_year(), plain_date.iso_month(), plain_date.iso_day()); js_out("\n calendar: "); print_value(&plain_date.calendar(), seen_objects); } -static void print_temporal_plain_date_time(JS::Object const& object, HashTable& seen_objects) +static void print_temporal_plain_date_time(JS::Temporal::PlainDateTime const& plain_date_time, HashTable& seen_objects) { - auto& plain_date_time = static_cast(object); print_type("Temporal.PlainDateTime"); js_out(" \033[34;1m{:04}-{:02}-{:02} {:02}:{:02}:{:02}.{:03}{:03}{:03}\033[0m", plain_date_time.iso_year(), plain_date_time.iso_month(), plain_date_time.iso_day(), plain_date_time.iso_hour(), plain_date_time.iso_minute(), plain_date_time.iso_second(), plain_date_time.iso_millisecond(), plain_date_time.iso_microsecond(), plain_date_time.iso_nanosecond()); js_out("\n calendar: "); print_value(&plain_date_time.calendar(), seen_objects); } -static void print_temporal_plain_month_day(JS::Object const& object, HashTable& seen_objects) +static void print_temporal_plain_month_day(JS::Temporal::PlainMonthDay const& plain_month_day, HashTable& seen_objects) { - auto& plain_month_day = static_cast(object); print_type("Temporal.PlainMonthDay"); // Also has an [[ISOYear]] internal slot, but showing that here seems rather unexpected. js_out(" \033[34;1m{:02}-{:02}\033[0m", plain_month_day.iso_month(), plain_month_day.iso_day()); @@ -597,18 +583,16 @@ static void print_temporal_plain_month_day(JS::Object const& object, HashTable& seen_objects) +static void print_temporal_plain_time(JS::Temporal::PlainTime const& plain_time, HashTable& seen_objects) { - auto& plain_time = static_cast(object); print_type("Temporal.PlainTime"); js_out(" \033[34;1m{:02}:{:02}:{:02}.{:03}{:03}{:03}\033[0m", plain_time.iso_hour(), plain_time.iso_minute(), plain_time.iso_second(), plain_time.iso_millisecond(), plain_time.iso_microsecond(), plain_time.iso_nanosecond()); js_out("\n calendar: "); print_value(&plain_time.calendar(), seen_objects); } -static void print_temporal_plain_year_month(JS::Object const& object, HashTable& seen_objects) +static void print_temporal_plain_year_month(JS::Temporal::PlainYearMonth const& plain_year_month, HashTable& seen_objects) { - auto& plain_year_month = static_cast(object); print_type("Temporal.PlainYearMonth"); // Also has an [[ISODay]] internal slot, but showing that here seems rather unexpected. js_out(" \033[34;1m{:04}-{:02}\033[0m", plain_year_month.iso_year(), plain_year_month.iso_month()); @@ -616,21 +600,19 @@ static void print_temporal_plain_year_month(JS::Object const& object, HashTable< print_value(&plain_year_month.calendar(), seen_objects); } -static void print_temporal_time_zone(JS::Object const& object, HashTable& seen_objects) +static void print_temporal_time_zone(JS::Temporal::TimeZone const& time_zone, HashTable& seen_objects) { - auto& time_zone = static_cast(object); print_type("Temporal.TimeZone"); js_out(" "); - print_value(JS::js_string(object.vm(), time_zone.identifier()), seen_objects); + print_value(JS::js_string(time_zone.vm(), time_zone.identifier()), seen_objects); if (time_zone.offset_nanoseconds().has_value()) { js_out("\n offset (ns): "); print_value(JS::Value(*time_zone.offset_nanoseconds()), seen_objects); } } -static void print_temporal_zoned_date_time(JS::Object const& object, HashTable& seen_objects) +static void print_temporal_zoned_date_time(JS::Temporal::ZonedDateTime const& zoned_date_time, HashTable& seen_objects) { - auto& zoned_date_time = static_cast(object); print_type("Temporal.ZonedDateTime"); js_out("\n epochNanoseconds: "); print_value(&zoned_date_time.nanoseconds(), seen_objects); @@ -640,97 +622,93 @@ static void print_temporal_zoned_date_time(JS::Object const& object, HashTable& seen_objects) +static void print_intl_display_names(JS::Intl::DisplayNames const& display_names, HashTable& seen_objects) { - auto& display_names = static_cast(object); print_type("Intl.DisplayNames"); js_out("\n locale: "); - print_value(js_string(object.vm(), display_names.locale()), seen_objects); + print_value(js_string(display_names.vm(), display_names.locale()), seen_objects); js_out("\n type: "); - print_value(js_string(object.vm(), display_names.type_string()), seen_objects); + print_value(js_string(display_names.vm(), display_names.type_string()), seen_objects); js_out("\n style: "); - print_value(js_string(object.vm(), display_names.style_string()), seen_objects); + print_value(js_string(display_names.vm(), display_names.style_string()), seen_objects); js_out("\n fallback: "); - print_value(js_string(object.vm(), display_names.fallback_string()), seen_objects); + print_value(js_string(display_names.vm(), display_names.fallback_string()), seen_objects); if (display_names.has_language_display()) { js_out("\n languageDisplay: "); - print_value(js_string(object.vm(), display_names.language_display_string()), seen_objects); + print_value(js_string(display_names.vm(), display_names.language_display_string()), seen_objects); } } -static void print_intl_locale(JS::Object const& object, HashTable& seen_objects) +static void print_intl_locale(JS::Intl::Locale const& locale, HashTable& seen_objects) { - auto& locale = static_cast(object); print_type("Intl.Locale"); js_out("\n locale: "); - print_value(js_string(object.vm(), locale.locale()), seen_objects); + print_value(js_string(locale.vm(), locale.locale()), seen_objects); if (locale.has_calendar()) { js_out("\n calendar: "); - print_value(js_string(object.vm(), locale.calendar()), seen_objects); + print_value(js_string(locale.vm(), locale.calendar()), seen_objects); } if (locale.has_case_first()) { js_out("\n caseFirst: "); - print_value(js_string(object.vm(), locale.case_first()), seen_objects); + print_value(js_string(locale.vm(), locale.case_first()), seen_objects); } if (locale.has_collation()) { js_out("\n collation: "); - print_value(js_string(object.vm(), locale.collation()), seen_objects); + print_value(js_string(locale.vm(), locale.collation()), seen_objects); } if (locale.has_hour_cycle()) { js_out("\n hourCycle: "); - print_value(js_string(object.vm(), locale.hour_cycle()), seen_objects); + print_value(js_string(locale.vm(), locale.hour_cycle()), seen_objects); } if (locale.has_numbering_system()) { js_out("\n numberingSystem: "); - print_value(js_string(object.vm(), locale.numbering_system()), seen_objects); + print_value(js_string(locale.vm(), locale.numbering_system()), seen_objects); } js_out("\n numeric: "); print_value(JS::Value(locale.numeric()), seen_objects); } -static void print_intl_list_format(JS::Object const& object, HashTable& seen_objects) +static void print_intl_list_format(JS::Intl::ListFormat const& list_format, HashTable& seen_objects) { - auto& list_format = static_cast(object); print_type("Intl.ListFormat"); js_out("\n locale: "); - print_value(js_string(object.vm(), list_format.locale()), seen_objects); + print_value(js_string(list_format.vm(), list_format.locale()), seen_objects); js_out("\n type: "); - print_value(js_string(object.vm(), list_format.type_string()), seen_objects); + print_value(js_string(list_format.vm(), list_format.type_string()), seen_objects); js_out("\n style: "); - print_value(js_string(object.vm(), list_format.style_string()), seen_objects); + print_value(js_string(list_format.vm(), list_format.style_string()), seen_objects); } -static void print_intl_number_format(JS::Object const& object, HashTable& seen_objects) +static void print_intl_number_format(JS::Intl::NumberFormat const& number_format, HashTable& seen_objects) { - auto& number_format = static_cast(object); print_type("Intl.NumberFormat"); js_out("\n locale: "); - print_value(js_string(object.vm(), number_format.locale()), seen_objects); + print_value(js_string(number_format.vm(), number_format.locale()), seen_objects); js_out("\n dataLocale: "); - print_value(js_string(object.vm(), number_format.data_locale()), seen_objects); + print_value(js_string(number_format.vm(), number_format.data_locale()), seen_objects); js_out("\n numberingSystem: "); - print_value(js_string(object.vm(), number_format.numbering_system()), seen_objects); + print_value(js_string(number_format.vm(), number_format.numbering_system()), seen_objects); js_out("\n style: "); - print_value(js_string(object.vm(), number_format.style_string()), seen_objects); + print_value(js_string(number_format.vm(), number_format.style_string()), seen_objects); if (number_format.has_currency()) { js_out("\n currency: "); - print_value(js_string(object.vm(), number_format.currency()), seen_objects); + print_value(js_string(number_format.vm(), number_format.currency()), seen_objects); } if (number_format.has_currency_display()) { js_out("\n currencyDisplay: "); - print_value(js_string(object.vm(), number_format.currency_display_string()), seen_objects); + print_value(js_string(number_format.vm(), number_format.currency_display_string()), seen_objects); } if (number_format.has_currency_sign()) { js_out("\n currencySign: "); - print_value(js_string(object.vm(), number_format.currency_sign_string()), seen_objects); + print_value(js_string(number_format.vm(), number_format.currency_sign_string()), seen_objects); } if (number_format.has_unit()) { js_out("\n unit: "); - print_value(js_string(object.vm(), number_format.unit()), seen_objects); + print_value(js_string(number_format.vm(), number_format.unit()), seen_objects); } if (number_format.has_unit_display()) { js_out("\n unitDisplay: "); - print_value(js_string(object.vm(), number_format.unit_display_string()), seen_objects); + print_value(js_string(number_format.vm(), number_format.unit_display_string()), seen_objects); } js_out("\n minimumIntegerDigits: "); print_value(JS::Value(number_format.min_integer_digits()), seen_objects); @@ -753,42 +731,41 @@ static void print_intl_number_format(JS::Object const& object, HashTable& seen_objects) +static void print_intl_date_time_format(JS::Intl::DateTimeFormat& date_time_format, HashTable& seen_objects) { - auto& date_time_format = static_cast(object); print_type("Intl.DateTimeFormat"); js_out("\n locale: "); - print_value(js_string(object.vm(), date_time_format.locale()), seen_objects); + print_value(js_string(date_time_format.vm(), date_time_format.locale()), seen_objects); js_out("\n pattern: "); - print_value(js_string(object.vm(), date_time_format.pattern()), seen_objects); + print_value(js_string(date_time_format.vm(), date_time_format.pattern()), seen_objects); js_out("\n calendar: "); - print_value(js_string(object.vm(), date_time_format.calendar()), seen_objects); + print_value(js_string(date_time_format.vm(), date_time_format.calendar()), seen_objects); js_out("\n numberingSystem: "); - print_value(js_string(object.vm(), date_time_format.numbering_system()), seen_objects); + print_value(js_string(date_time_format.vm(), date_time_format.numbering_system()), seen_objects); if (date_time_format.has_hour_cycle()) { js_out("\n hourCycle: "); - print_value(js_string(object.vm(), date_time_format.hour_cycle_string()), seen_objects); + print_value(js_string(date_time_format.vm(), date_time_format.hour_cycle_string()), seen_objects); } js_out("\n timeZone: "); - print_value(js_string(object.vm(), date_time_format.time_zone()), seen_objects); + print_value(js_string(date_time_format.vm(), date_time_format.time_zone()), seen_objects); if (date_time_format.has_date_style()) { js_out("\n dateStyle: "); - print_value(js_string(object.vm(), date_time_format.date_style_string()), seen_objects); + print_value(js_string(date_time_format.vm(), date_time_format.date_style_string()), seen_objects); } if (date_time_format.has_time_style()) { js_out("\n timeStyle: "); - print_value(js_string(object.vm(), date_time_format.time_style_string()), seen_objects); + print_value(js_string(date_time_format.vm(), date_time_format.time_style_string()), seen_objects); } JS::Intl::for_each_calendar_field(date_time_format.global_object(), date_time_format, [&](auto& option, auto const& property, auto const&) -> JS::ThrowCompletionOr { @@ -803,35 +780,33 @@ static void print_intl_date_time_format(JS::Object& object, HashTable& seen_objects) +static void print_intl_relative_time_format(JS::Intl::RelativeTimeFormat& date_time_format, HashTable& seen_objects) { - auto& date_time_format = static_cast(object); print_type("Intl.RelativeTimeFormat"); js_out("\n locale: "); - print_value(js_string(object.vm(), date_time_format.locale()), seen_objects); + print_value(js_string(date_time_format.vm(), date_time_format.locale()), seen_objects); js_out("\n numberingSystem: "); - print_value(js_string(object.vm(), date_time_format.numbering_system()), seen_objects); + print_value(js_string(date_time_format.vm(), date_time_format.numbering_system()), seen_objects); js_out("\n style: "); - print_value(js_string(object.vm(), date_time_format.style_string()), seen_objects); + print_value(js_string(date_time_format.vm(), date_time_format.style_string()), seen_objects); js_out("\n numeric: "); - print_value(js_string(object.vm(), date_time_format.numeric_string()), seen_objects); + print_value(js_string(date_time_format.vm(), date_time_format.numeric_string()), seen_objects); } -static void print_intl_plural_rules(JS::Object const& object, HashTable& seen_objects) +static void print_intl_plural_rules(JS::Intl::PluralRules const& plural_rules, HashTable& seen_objects) { - auto& plural_rules = static_cast(object); print_type("Intl.PluralRules"); js_out("\n locale: "); - print_value(js_string(object.vm(), plural_rules.locale()), seen_objects); + print_value(js_string(plural_rules.vm(), plural_rules.locale()), seen_objects); js_out("\n type: "); - print_value(js_string(object.vm(), plural_rules.type_string()), seen_objects); + print_value(js_string(plural_rules.vm(), plural_rules.type_string()), seen_objects); js_out("\n minimumIntegerDigits: "); print_value(JS::Value(plural_rules.min_integer_digits()), seen_objects); if (plural_rules.has_min_fraction_digits()) { @@ -851,101 +826,97 @@ static void print_intl_plural_rules(JS::Object const& object, HashTable& seen_objects) +static void print_intl_collator(JS::Intl::Collator const& collator, HashTable& seen_objects) { - auto& collator = static_cast(object); print_type("Intl.Collator"); out("\n locale: "); - print_value(js_string(object.vm(), collator.locale()), seen_objects); + print_value(js_string(collator.vm(), collator.locale()), seen_objects); out("\n usage: "); - print_value(js_string(object.vm(), collator.usage_string()), seen_objects); + print_value(js_string(collator.vm(), collator.usage_string()), seen_objects); out("\n sensitivity: "); - print_value(js_string(object.vm(), collator.sensitivity_string()), seen_objects); + print_value(js_string(collator.vm(), collator.sensitivity_string()), seen_objects); out("\n caseFirst: "); - print_value(js_string(object.vm(), collator.case_first_string()), seen_objects); + print_value(js_string(collator.vm(), collator.case_first_string()), seen_objects); out("\n collation: "); - print_value(js_string(object.vm(), collator.collation()), seen_objects); + print_value(js_string(collator.vm(), collator.collation()), seen_objects); out("\n ignorePunctuation: "); print_value(JS::Value(collator.ignore_punctuation()), seen_objects); out("\n numeric: "); print_value(JS::Value(collator.numeric()), seen_objects); } -static void print_intl_segmenter(JS::Object const& object, HashTable& seen_objects) +static void print_intl_segmenter(JS::Intl::Segmenter const& segmenter, HashTable& seen_objects) { - auto& segmenter = static_cast(object); print_type("Intl.Segmenter"); out("\n locale: "); - print_value(js_string(object.vm(), segmenter.locale()), seen_objects); + print_value(js_string(segmenter.vm(), segmenter.locale()), seen_objects); out("\n granularity: "); - print_value(js_string(object.vm(), segmenter.segmenter_granularity_string()), seen_objects); + print_value(js_string(segmenter.vm(), segmenter.segmenter_granularity_string()), seen_objects); } -static void print_intl_segments(JS::Object const& object, HashTable& seen_objects) +static void print_intl_segments(JS::Intl::Segments const& segments, HashTable& seen_objects) { - auto& segments = static_cast(object); print_type("Segments"); out("\n string: "); - print_value(js_string(object.vm(), segments.segments_string()), seen_objects); + print_value(js_string(segments.vm(), segments.segments_string()), seen_objects); out("\n segmenter: "); print_value(&segments.segments_segmenter(), seen_objects); } -static void print_intl_duration_format(JS::Object const& object, HashTable& seen_objects) +static void print_intl_duration_format(JS::Intl::DurationFormat const& duration_format, HashTable& seen_objects) { - auto& duration_format = static_cast(object); print_type("Intl.DurationFormat"); out("\n locale: "); - print_value(js_string(object.vm(), duration_format.locale()), seen_objects); + print_value(js_string(duration_format.vm(), duration_format.locale()), seen_objects); out("\n dataLocale: "); - print_value(js_string(object.vm(), duration_format.data_locale()), seen_objects); + print_value(js_string(duration_format.vm(), duration_format.data_locale()), seen_objects); out("\n numberingSystem: "); - print_value(js_string(object.vm(), duration_format.numbering_system()), seen_objects); + print_value(js_string(duration_format.vm(), duration_format.numbering_system()), seen_objects); out("\n style: "); - print_value(js_string(object.vm(), duration_format.style_string()), seen_objects); + print_value(js_string(duration_format.vm(), duration_format.style_string()), seen_objects); out("\n years: "); - print_value(js_string(object.vm(), duration_format.years_style_string()), seen_objects); + print_value(js_string(duration_format.vm(), duration_format.years_style_string()), seen_objects); out("\n yearsDisplay: "); - print_value(js_string(object.vm(), duration_format.years_display_string()), seen_objects); + print_value(js_string(duration_format.vm(), duration_format.years_display_string()), seen_objects); out("\n months: "); - print_value(js_string(object.vm(), duration_format.months_style_string()), seen_objects); + print_value(js_string(duration_format.vm(), duration_format.months_style_string()), seen_objects); out("\n monthsDisplay: "); - print_value(js_string(object.vm(), duration_format.months_display_string()), seen_objects); + print_value(js_string(duration_format.vm(), duration_format.months_display_string()), seen_objects); out("\n weeks: "); - print_value(js_string(object.vm(), duration_format.weeks_style_string()), seen_objects); + print_value(js_string(duration_format.vm(), duration_format.weeks_style_string()), seen_objects); out("\n weeksDisplay: "); - print_value(js_string(object.vm(), duration_format.weeks_display_string()), seen_objects); + print_value(js_string(duration_format.vm(), duration_format.weeks_display_string()), seen_objects); out("\n days: "); - print_value(js_string(object.vm(), duration_format.days_style_string()), seen_objects); + print_value(js_string(duration_format.vm(), duration_format.days_style_string()), seen_objects); out("\n daysDisplay: "); - print_value(js_string(object.vm(), duration_format.days_display_string()), seen_objects); + print_value(js_string(duration_format.vm(), duration_format.days_display_string()), seen_objects); out("\n hours: "); - print_value(js_string(object.vm(), duration_format.hours_style_string()), seen_objects); + print_value(js_string(duration_format.vm(), duration_format.hours_style_string()), seen_objects); out("\n hoursDisplay: "); - print_value(js_string(object.vm(), duration_format.hours_display_string()), seen_objects); + print_value(js_string(duration_format.vm(), duration_format.hours_display_string()), seen_objects); out("\n minutes: "); - print_value(js_string(object.vm(), duration_format.minutes_style_string()), seen_objects); + print_value(js_string(duration_format.vm(), duration_format.minutes_style_string()), seen_objects); out("\n minutesDisplay: "); - print_value(js_string(object.vm(), duration_format.minutes_display_string()), seen_objects); + print_value(js_string(duration_format.vm(), duration_format.minutes_display_string()), seen_objects); out("\n seconds: "); - print_value(js_string(object.vm(), duration_format.seconds_style_string()), seen_objects); + print_value(js_string(duration_format.vm(), duration_format.seconds_style_string()), seen_objects); out("\n secondsDisplay: "); - print_value(js_string(object.vm(), duration_format.seconds_display_string()), seen_objects); + print_value(js_string(duration_format.vm(), duration_format.seconds_display_string()), seen_objects); out("\n milliseconds: "); - print_value(js_string(object.vm(), duration_format.milliseconds_style_string()), seen_objects); + print_value(js_string(duration_format.vm(), duration_format.milliseconds_style_string()), seen_objects); out("\n millisecondsDisplay: "); - print_value(js_string(object.vm(), duration_format.milliseconds_display_string()), seen_objects); + print_value(js_string(duration_format.vm(), duration_format.milliseconds_display_string()), seen_objects); out("\n microseconds: "); - print_value(js_string(object.vm(), duration_format.microseconds_style_string()), seen_objects); + print_value(js_string(duration_format.vm(), duration_format.microseconds_style_string()), seen_objects); out("\n microsecondsDisplay: "); - print_value(js_string(object.vm(), duration_format.microseconds_display_string()), seen_objects); + print_value(js_string(duration_format.vm(), duration_format.microseconds_display_string()), seen_objects); out("\n nanoseconds: "); - print_value(js_string(object.vm(), duration_format.nanoseconds_style_string()), seen_objects); + print_value(js_string(duration_format.vm(), duration_format.nanoseconds_style_string()), seen_objects); out("\n nanosecondsDisplay: "); - print_value(js_string(object.vm(), duration_format.nanoseconds_display_string()), seen_objects); + print_value(js_string(duration_format.vm(), duration_format.nanoseconds_display_string()), seen_objects); if (duration_format.has_fractional_digits()) { out("\n fractionalDigits: "); print_value(JS::Value(duration_format.fractional_digits()), seen_objects); @@ -982,9 +953,9 @@ static void print_value(JS::Value value, HashTable& seen_objects) if (is(object)) return print_array(static_cast(object), seen_objects); if (object.is_function()) - return print_function(object, seen_objects); + return print_function(static_cast(object), seen_objects); if (is(object)) - return print_date(object, seen_objects); + return print_date(static_cast(object), seen_objects); if (is(object)) return print_error(object, seen_objects); @@ -993,27 +964,27 @@ static void print_value(JS::Value value, HashTable& seen_objects) return print_error(object, seen_objects); if (is(object)) - return print_regexp_object(object, seen_objects); + return print_regexp_object(static_cast(object), seen_objects); if (is(object)) - return print_map(object, seen_objects); + return print_map(static_cast(object), seen_objects); if (is(object)) - return print_set(object, seen_objects); + return print_set(static_cast(object), seen_objects); if (is(object)) - return print_data_view(object, seen_objects); + return print_data_view(static_cast(object), seen_objects); if (is(object)) - return print_proxy_object(object, seen_objects); + return print_proxy_object(static_cast(object), seen_objects); if (is(object)) - return print_promise(object, seen_objects); + return print_promise(static_cast(object), seen_objects); if (is(object)) - return print_array_buffer(object, seen_objects); + return print_array_buffer(static_cast(object), seen_objects); if (is(object)) - return print_shadow_realm(object, seen_objects); + return print_shadow_realm(static_cast(object), seen_objects); if (is(object)) - return print_generator(object, seen_objects); + return print_generator(static_cast(object), seen_objects); if (is(object)) - return print_async_generator(object, seen_objects); + return print_async_generator(static_cast(object), seen_objects); if (object.is_typed_array()) - return print_typed_array(object, seen_objects); + return print_typed_array(static_cast(object), seen_objects); if (is(object)) return print_primitive_wrapper_object("String", object, seen_objects); if (is(object)) @@ -1021,47 +992,47 @@ static void print_value(JS::Value value, HashTable& seen_objects) if (is(object)) return print_primitive_wrapper_object("Boolean", object, seen_objects); if (is(object)) - return print_temporal_calendar(object, seen_objects); + return print_temporal_calendar(static_cast(object), seen_objects); if (is(object)) - return print_temporal_duration(object, seen_objects); + return print_temporal_duration(static_cast(object), seen_objects); if (is(object)) - return print_temporal_instant(object, seen_objects); + return print_temporal_instant(static_cast(object), seen_objects); if (is(object)) - return print_temporal_plain_date(object, seen_objects); + return print_temporal_plain_date(static_cast(object), seen_objects); if (is(object)) - return print_temporal_plain_date_time(object, seen_objects); + return print_temporal_plain_date_time(static_cast(object), seen_objects); if (is(object)) - return print_temporal_plain_month_day(object, seen_objects); + return print_temporal_plain_month_day(static_cast(object), seen_objects); if (is(object)) - return print_temporal_plain_time(object, seen_objects); + return print_temporal_plain_time(static_cast(object), seen_objects); if (is(object)) - return print_temporal_plain_year_month(object, seen_objects); + return print_temporal_plain_year_month(static_cast(object), seen_objects); if (is(object)) - return print_temporal_time_zone(object, seen_objects); + return print_temporal_time_zone(static_cast(object), seen_objects); if (is(object)) - return print_temporal_zoned_date_time(object, seen_objects); + return print_temporal_zoned_date_time(static_cast(object), seen_objects); if (is(object)) - return print_intl_display_names(object, seen_objects); + return print_intl_display_names(static_cast(object), seen_objects); if (is(object)) - return print_intl_locale(object, seen_objects); + return print_intl_locale(static_cast(object), seen_objects); if (is(object)) - return print_intl_list_format(object, seen_objects); + return print_intl_list_format(static_cast(object), seen_objects); if (is(object)) - return print_intl_number_format(object, seen_objects); + return print_intl_number_format(static_cast(object), seen_objects); if (is(object)) - return print_intl_date_time_format(object, seen_objects); + return print_intl_date_time_format(static_cast(object), seen_objects); if (is(object)) - return print_intl_relative_time_format(object, seen_objects); + return print_intl_relative_time_format(static_cast(object), seen_objects); if (is(object)) - return print_intl_plural_rules(object, seen_objects); + return print_intl_plural_rules(static_cast(object), seen_objects); if (is(object)) - return print_intl_collator(object, seen_objects); + return print_intl_collator(static_cast(object), seen_objects); if (is(object)) - return print_intl_segmenter(object, seen_objects); + return print_intl_segmenter(static_cast(object), seen_objects); if (is(object)) - return print_intl_segments(object, seen_objects); + return print_intl_segments(static_cast(object), seen_objects); if (is(object)) - return print_intl_duration_format(object, seen_objects); + return print_intl_duration_format(static_cast(object), seen_objects); return print_object(object, seen_objects); }