diff options
author | Linus Groh <mail@linusgroh.de> | 2022-05-05 20:50:32 +0200 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-05-05 22:40:57 +0200 |
commit | 2ad96413153fb8eda94c033d0702f37de9ecf148 (patch) | |
tree | 556389761a4ba814907d82a65367aabb0d94dc28 /Userland/Utilities | |
parent | 53619176f5d2017e498e5cbecfdc101bf3ca0123 (diff) | |
download | serenity-2ad96413153fb8eda94c033d0702f37de9ecf148.zip |
js: Implement pretty-printing of generator objects
Diffstat (limited to 'Userland/Utilities')
-rw-r--r-- | Userland/Utilities/js.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
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 <kling@serenityos.org> - * Copyright (c) 2020-2021, Linus Groh <linusg@serenityos.org> + * Copyright (c) 2020-2022, Linus Groh <linusg@serenityos.org> * * SPDX-License-Identifier: BSD-2-Clause */ @@ -24,6 +24,7 @@ #include <LibJS/Parser.h> #include <LibJS/Runtime/Array.h> #include <LibJS/Runtime/ArrayBuffer.h> +#include <LibJS/Runtime/AsyncGenerator.h> #include <LibJS/Runtime/BooleanObject.h> #include <LibJS/Runtime/DataView.h> #include <LibJS/Runtime/Date.h> @@ -31,6 +32,7 @@ #include <LibJS/Runtime/ECMAScriptFunctionObject.h> #include <LibJS/Runtime/Error.h> #include <LibJS/Runtime/FunctionObject.h> +#include <LibJS/Runtime/GeneratorObject.h> #include <LibJS/Runtime/GlobalObject.h> #include <LibJS/Runtime/Intl/Collator.h> #include <LibJS/Runtime/Intl/DateTimeFormat.h> @@ -451,6 +453,16 @@ static void print_shadow_realm(JS::Object const&, HashTable<JS::Object*>&) print_type("ShadowRealm"); } +static void print_generator(JS::Object const&, HashTable<JS::Object*>&) +{ + print_type("Generator"); +} + +static void print_async_generator(JS::Object const&, HashTable<JS::Object*>&) +{ + print_type("AsyncGenerator"); +} + template<typename T> static void print_number(T number) requires IsArithmetic<T> { @@ -914,6 +926,10 @@ static void print_value(JS::Value value, HashTable<JS::Object*>& seen_objects) return print_array_buffer(object, seen_objects); if (is<JS::ShadowRealm>(object)) return print_shadow_realm(object, seen_objects); + if (is<JS::GeneratorObject>(object)) + return print_generator(object, seen_objects); + if (is<JS::AsyncGenerator>(object)) + return print_async_generator(object, seen_objects); if (object.is_typed_array()) return print_typed_array(object, seen_objects); if (is<JS::StringObject>(object)) |