mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:57:45 +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:
parent
8d90e137a5
commit
411c72da27
1 changed files with 9 additions and 1 deletions
|
@ -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)
|
static void print_typed_array(const JS::Object& object, HashTable<JS::Object*>& seen_objects)
|
||||||
{
|
{
|
||||||
auto& typed_array_base = static_cast<const JS::TypedArrayBase&>(object);
|
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) { \
|
for (size_t i = 0; i < length; ++i) { \
|
||||||
if (i > 0) \
|
if (i > 0) \
|
||||||
out(", "); \
|
out(", "); \
|
||||||
print_value(JS::Value(data[i]), seen_objects); \
|
print_number(data[i]); \
|
||||||
} \
|
} \
|
||||||
out(" ]"); \
|
out(" ]"); \
|
||||||
return; \
|
return; \
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue