1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 11:18:13 +00:00

LibJS: Add Float{32,64}Array

This commit is contained in:
Linus Groh 2020-12-05 22:28:10 +00:00 committed by Andreas Kling
parent 4dcd23c2be
commit a70aacd7c3
6 changed files with 48 additions and 15 deletions

View file

@ -80,7 +80,7 @@ public:
if (vm().exception())
return {};
data()[property_index] = number;
} else if constexpr (sizeof(T) == 4) {
} else if constexpr (sizeof(T) == 4 || sizeof(T) == 8) {
auto number = value.to_double(global_object());
if (vm().exception())
return {};
@ -99,9 +99,11 @@ public:
if constexpr (sizeof(T) < 4) {
return Value((i32)data()[property_index]);
} else if constexpr (sizeof(T) == 4) {
} else if constexpr (sizeof(T) == 4 || sizeof(T) == 8) {
auto value = data()[property_index];
if constexpr (NumericLimits<T>::is_signed()) {
if constexpr (IsFloatingPoint<T>::value) {
return Value((double)value);
} else if constexpr (NumericLimits<T>::is_signed()) {
if (value > NumericLimits<i32>::max() || value < NumericLimits<i32>::min())
return Value((double)value);
} else {