From 2ad96413153fb8eda94c033d0702f37de9ecf148 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Thu, 5 May 2022 20:50:32 +0200 Subject: [PATCH] js: Implement pretty-printing of generator objects --- Userland/Utilities/js.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Userland/Utilities/js.cpp b/Userland/Utilities/js.cpp index bb15a89691..8aec97372f 100644 --- a/Userland/Utilities/js.cpp +++ b/Userland/Utilities/js.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2020-2021, Andreas Kling - * Copyright (c) 2020-2021, Linus Groh + * Copyright (c) 2020-2022, Linus Groh * * SPDX-License-Identifier: BSD-2-Clause */ @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -31,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -451,6 +453,16 @@ static void print_shadow_realm(JS::Object const&, HashTable&) print_type("ShadowRealm"); } +static void print_generator(JS::Object const&, HashTable&) +{ + print_type("Generator"); +} + +static void print_async_generator(JS::Object const&, HashTable&) +{ + print_type("AsyncGenerator"); +} + template static void print_number(T number) requires IsArithmetic { @@ -914,6 +926,10 @@ static void print_value(JS::Value value, HashTable& seen_objects) return print_array_buffer(object, seen_objects); if (is(object)) return print_shadow_realm(object, seen_objects); + if (is(object)) + return print_generator(object, seen_objects); + if (is(object)) + return print_async_generator(object, seen_objects); if (object.is_typed_array()) return print_typed_array(object, seen_objects); if (is(object))