From 411c72da277ce82490c455712de5a95b8969c75d Mon Sep 17 00:00:00 2001 From: Luke Date: Thu, 17 Jun 2021 01:00:12 +0100 Subject: [PATCH] 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. --- Userland/Utilities/js.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Userland/Utilities/js.cpp b/Userland/Utilities/js.cpp index b13c24048ad..6e2e617a008 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& } } +template +static void print_number(T number) requires IsArithmetic +{ + out("\033[35;1m"); + out("{}", number); + out("\033[0m"); +} + static void print_typed_array(const JS::Object& object, HashTable& seen_objects) { auto& typed_array_base = static_cast(object); @@ -390,7 +398,7 @@ static void print_typed_array(const JS::Object& object, HashTable& 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; \