js: Implement pretty-printing of Temporal.Calendar objects

This commit is contained in:
Linus Groh 2021-07-14 21:59:49 +01:00
parent bb86d535a9
commit c82c652ee4

View file

@ -41,6 +41,7 @@
#include <LibJS/Runtime/Set.h>
#include <LibJS/Runtime/Shape.h>
#include <LibJS/Runtime/StringObject.h>
#include <LibJS/Runtime/Temporal/Calendar.h>
#include <LibJS/Runtime/Temporal/Instant.h>
#include <LibJS/Runtime/Temporal/TimeZone.h>
#include <LibJS/Runtime/TypedArray.h>
@ -427,6 +428,14 @@ static void print_data_view(JS::Object const& object, HashTable<JS::Object*>& se
out(" @ {:p}", data_view.viewed_array_buffer());
}
static void print_temporal_calendar(JS::Object const& object, HashTable<JS::Object*>& seen_objects)
{
auto& calendar = static_cast<JS::Temporal::Calendar const&>(object);
print_type("Temporal.Calendar");
out(" ");
print_value(JS::js_string(object.vm(), calendar.identifier()), seen_objects);
}
static void print_temporal_instant(JS::Object const& object, HashTable<JS::Object*>& seen_objects)
{
auto& instant = static_cast<JS::Temporal::Instant const&>(object);
@ -505,6 +514,8 @@ static void print_value(JS::Value value, HashTable<JS::Object*>& seen_objects)
return print_primitive_wrapper_object("Number", object, seen_objects);
if (is<JS::BooleanObject>(object))
return print_primitive_wrapper_object("Boolean", object, seen_objects);
if (is<JS::Temporal::Calendar>(object))
return print_temporal_calendar(object, seen_objects);
if (is<JS::Temporal::Instant>(object))
return print_temporal_instant(object, seen_objects);
if (is<JS::Temporal::TimeZone>(object))