summaryrefslogtreecommitdiff
path: root/Userland/Utilities
diff options
context:
space:
mode:
authorIdan Horowitz <idan.horowitz@gmail.com>2021-06-09 00:08:47 +0300
committerLinus Groh <mail@linusgroh.de>2021-06-09 11:48:04 +0100
commit670be04c816b978e6308e18e8b18a0f784bf577c (patch)
treeb3aaa8e9079f27737d2c5c1052afc95ebbdc5e08 /Userland/Utilities
parentb17a282b4b0a1f2831ea133b42aeec9e3d3e1208 (diff)
downloadserenity-670be04c816b978e6308e18e8b18a0f784bf577c.zip
LibJS: Add the Set built-in object
Diffstat (limited to 'Userland/Utilities')
-rw-r--r--Userland/Utilities/js.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/Userland/Utilities/js.cpp b/Userland/Utilities/js.cpp
index 29a40e9791..ee2efc19f1 100644
--- a/Userland/Utilities/js.cpp
+++ b/Userland/Utilities/js.cpp
@@ -35,6 +35,7 @@
#include <LibJS/Runtime/ProxyObject.h>
#include <LibJS/Runtime/RegExpObject.h>
#include <LibJS/Runtime/ScriptFunction.h>
+#include <LibJS/Runtime/Set.h>
#include <LibJS/Runtime/Shape.h>
#include <LibJS/Runtime/StringObject.h>
#include <LibJS/Runtime/TypedArray.h>
@@ -277,6 +278,22 @@ static void print_proxy_object(const JS::Object& object, HashTable<JS::Object*>&
print_value(&proxy_object.handler(), seen_objects);
}
+static void print_set(const JS::Object& object, HashTable<JS::Object*>& seen_objects)
+{
+ auto& set = static_cast<const JS::Set&>(object);
+ auto& values = set.values();
+ print_type("Set");
+ out(" {{");
+ bool first = true;
+ for (auto& value : values) {
+ print_separator(first);
+ print_value(value, seen_objects);
+ }
+ if (!first)
+ out(" ");
+ out("}}");
+}
+
static void print_promise(const JS::Object& object, HashTable<JS::Object*>& seen_objects)
{
auto& promise = static_cast<const JS::Promise&>(object);
@@ -398,6 +415,8 @@ static void print_value(JS::Value value, HashTable<JS::Object*>& seen_objects)
return print_error(object, seen_objects);
if (is<JS::RegExpObject>(object))
return print_regexp_object(object, seen_objects);
+ if (is<JS::Set>(object))
+ return print_set(object, seen_objects);
if (is<JS::ProxyObject>(object))
return print_proxy_object(object, seen_objects);
if (is<JS::Promise>(object))