mirror of
https://github.com/SerenityOS/serenity
synced 2024-07-24 03:25:02 +00:00
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.
This commit is contained in:
parent
2ad9641315
commit
88f637a505
|
@ -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))
|
||||
|
|
Loading…
Reference in a new issue