1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 19:58:11 +00:00

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.
This commit is contained in:
Luke 2021-06-17 01:00:12 +01:00 committed by Linus Groh
parent 8d90e137a5
commit 411c72da27

View file

@ -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; \