瀏覽代碼

js: Implement pretty-printing of Temporal.Calendar objects

Linus Groh 4 年之前
父節點
當前提交
c82c652ee4
共有 1 個文件被更改,包括 11 次插入0 次删除
  1. 11 0
      Userland/Utilities/js.cpp

+ 11 - 0
Userland/Utilities/js.cpp

@@ -41,6 +41,7 @@
 #include <LibJS/Runtime/Set.h>
 #include <LibJS/Runtime/Set.h>
 #include <LibJS/Runtime/Shape.h>
 #include <LibJS/Runtime/Shape.h>
 #include <LibJS/Runtime/StringObject.h>
 #include <LibJS/Runtime/StringObject.h>
+#include <LibJS/Runtime/Temporal/Calendar.h>
 #include <LibJS/Runtime/Temporal/Instant.h>
 #include <LibJS/Runtime/Temporal/Instant.h>
 #include <LibJS/Runtime/Temporal/TimeZone.h>
 #include <LibJS/Runtime/Temporal/TimeZone.h>
 #include <LibJS/Runtime/TypedArray.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());
     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)
 static void print_temporal_instant(JS::Object const& object, HashTable<JS::Object*>& seen_objects)
 {
 {
     auto& instant = static_cast<JS::Temporal::Instant const&>(object);
     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);
             return print_primitive_wrapper_object("Number", object, seen_objects);
         if (is<JS::BooleanObject>(object))
         if (is<JS::BooleanObject>(object))
             return print_primitive_wrapper_object("Boolean", object, seen_objects);
             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))
         if (is<JS::Temporal::Instant>(object))
             return print_temporal_instant(object, seen_objects);
             return print_temporal_instant(object, seen_objects);
         if (is<JS::Temporal::TimeZone>(object))
         if (is<JS::Temporal::TimeZone>(object))