mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:07:45 +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
1 changed files with 21 additions and 1 deletions
|
@ -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*>&)
|
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))
|
if (is<JS::ECMAScriptFunctionObject>(object))
|
||||||
js_out(" {}", static_cast<JS::ECMAScriptFunctionObject const&>(object).name());
|
js_out(" {}", static_cast<JS::ECMAScriptFunctionObject const&>(object).name());
|
||||||
else if (is<JS::NativeFunction>(object))
|
else if (is<JS::NativeFunction>(object))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue