summaryrefslogtreecommitdiff
path: root/Userland/Utilities
diff options
context:
space:
mode:
authorLuke <luke.wilde@live.co.uk>2021-06-17 01:00:12 +0100
committerLinus Groh <mail@linusgroh.de>2021-06-17 02:20:03 +0100
commit411c72da277ce82490c455712de5a95b8969c75d (patch)
tree0bc94c4a2a2db4db354f9fd996856183587a7c20 /Userland/Utilities
parent8d90e137a5aa703f1089369895af4656e8567e3a (diff)
downloadserenity-411c72da277ce82490c455712de5a95b8969c75d.zip
js: Add print_number method and use it to print out TypedArray values
We can't construct Values with u64 and i64. I tried adding these constructors, but then it refuses to build in lagom.
Diffstat (limited to 'Userland/Utilities')
-rw-r--r--Userland/Utilities/js.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/Userland/Utilities/js.cpp b/Userland/Utilities/js.cpp
index b13c24048a..6e2e617a00 100644
--- a/Userland/Utilities/js.cpp
+++ b/Userland/Utilities/js.cpp
@@ -366,6 +366,14 @@ static void print_array_buffer(const JS::Object& object, HashTable<JS::Object*>&
}
}
+template<typename T>
+static void print_number(T number) requires IsArithmetic<T>
+{
+ out("\033[35;1m");
+ out("{}", number);
+ out("\033[0m");
+}
+
static void print_typed_array(const JS::Object& object, HashTable<JS::Object*>& seen_objects)
{
auto& typed_array_base = static_cast<const JS::TypedArrayBase&>(object);
@@ -390,7 +398,7 @@ static void print_typed_array(const JS::Object& object, HashTable<JS::Object*>&
for (size_t i = 0; i < length; ++i) { \
if (i > 0) \
out(", "); \
- print_value(JS::Value(data[i]), seen_objects); \
+ print_number(data[i]); \
} \
out(" ]"); \
return; \