summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2022-05-05 22:42:10 +0200
committerLinus Groh <mail@linusgroh.de>2022-05-05 22:42:10 +0200
commit88f637a5059990694cdca38bd3a555e573e176e9 (patch)
tree0c9a88895498e574d8c9b50fe910ae9a942069db
parent2ad96413153fb8eda94c033d0702f37de9ecf148 (diff)
downloadserenity-88f637a5059990694cdca38bd3a555e573e176e9.zip
js: Print different type for each kind of ECMAScript function object
Instead of just printing 'ECMAScriptFunctionObject' (and leaking an implementation detail in the process - this is not a public facing name) let's instead print a different type string for each function kind, and only keep the old class_name() printing for other JS::FunctionObject subclasses.
-rw-r--r--Userland/Utilities/js.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/Userland/Utilities/js.cpp b/Userland/Utilities/js.cpp
index 8aec97372f..bd840cbfcb 100644
--- a/Userland/Utilities/js.cpp
+++ b/Userland/Utilities/js.cpp
@@ -316,7 +316,27 @@ static void print_object(JS::Object& object, HashTable<JS::Object*>& seen_object
static void print_function(JS::Object const& object, HashTable<JS::Object*>&)
{
- print_type(object.class_name());
+ if (is<JS::ECMAScriptFunctionObject>(object)) {
+ auto const& function = static_cast<JS::ECMAScriptFunctionObject const&>(object);
+ switch (function.kind()) {
+ case JS::FunctionKind::Normal:
+ print_type("Function");
+ break;
+ case JS::FunctionKind::Generator:
+ print_type("GeneratorFunction");
+ break;
+ case JS::FunctionKind::Async:
+ print_type("AsyncFunction");
+ break;
+ case JS::FunctionKind::AsyncGenerator:
+ print_type("AsyncGeneratorFunction");
+ break;
+ default:
+ VERIFY_NOT_REACHED();
+ }
+ } else {
+ print_type(object.class_name());
+ }
if (is<JS::ECMAScriptFunctionObject>(object))
js_out(" {}", static_cast<JS::ECMAScriptFunctionObject const&>(object).name());
else if (is<JS::NativeFunction>(object))