mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 00:37:35 +00:00
js: Implement pretty-printing of WeakRef objects
This commit is contained in:
parent
dee8e53773
commit
8b9f5b0286
1 changed files with 10 additions and 0 deletions
|
@ -73,6 +73,7 @@
|
||||||
#include <LibJS/Runtime/TypedArray.h>
|
#include <LibJS/Runtime/TypedArray.h>
|
||||||
#include <LibJS/Runtime/Value.h>
|
#include <LibJS/Runtime/Value.h>
|
||||||
#include <LibJS/Runtime/WeakMap.h>
|
#include <LibJS/Runtime/WeakMap.h>
|
||||||
|
#include <LibJS/Runtime/WeakRef.h>
|
||||||
#include <LibJS/Runtime/WeakSet.h>
|
#include <LibJS/Runtime/WeakSet.h>
|
||||||
#include <LibJS/SourceTextModule.h>
|
#include <LibJS/SourceTextModule.h>
|
||||||
#include <LibLine/Editor.h>
|
#include <LibLine/Editor.h>
|
||||||
|
@ -429,6 +430,13 @@ static void print_weak_set(JS::WeakSet const& weak_set, HashTable<JS::Object*>&)
|
||||||
// Note: We could tell you what's actually inside, but not in insertion order.
|
// Note: We could tell you what's actually inside, but not in insertion order.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void print_weak_ref(JS::WeakRef const& weak_ref, HashTable<JS::Object*>& seen_objects)
|
||||||
|
{
|
||||||
|
print_type("WeakRef");
|
||||||
|
js_out(" ");
|
||||||
|
print_value(weak_ref.value().visit([](Empty) -> JS::Value { return JS::js_undefined(); }, [](auto* value) -> JS::Value { return value; }), seen_objects);
|
||||||
|
}
|
||||||
|
|
||||||
static void print_promise(JS::Promise const& promise, HashTable<JS::Object*>& seen_objects)
|
static void print_promise(JS::Promise const& promise, HashTable<JS::Object*>& seen_objects)
|
||||||
{
|
{
|
||||||
print_type("Promise");
|
print_type("Promise");
|
||||||
|
@ -1002,6 +1010,8 @@ static void print_value(JS::Value value, HashTable<JS::Object*>& seen_objects)
|
||||||
return print_weak_map(static_cast<JS::WeakMap&>(object), seen_objects);
|
return print_weak_map(static_cast<JS::WeakMap&>(object), seen_objects);
|
||||||
if (is<JS::WeakSet>(object))
|
if (is<JS::WeakSet>(object))
|
||||||
return print_weak_set(static_cast<JS::WeakSet&>(object), seen_objects);
|
return print_weak_set(static_cast<JS::WeakSet&>(object), seen_objects);
|
||||||
|
if (is<JS::WeakRef>(object))
|
||||||
|
return print_weak_ref(static_cast<JS::WeakRef&>(object), seen_objects);
|
||||||
if (is<JS::DataView>(object))
|
if (is<JS::DataView>(object))
|
||||||
return print_data_view(static_cast<JS::DataView&>(object), seen_objects);
|
return print_data_view(static_cast<JS::DataView&>(object), seen_objects);
|
||||||
if (is<JS::ProxyObject>(object))
|
if (is<JS::ProxyObject>(object))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue