mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:07:45 +00:00
LibJS: Add content type check to IntegerIndexedElementSet()
Resolves a FIXME.
This commit is contained in:
parent
e08702a235
commit
d3fc8652c7
1 changed files with 14 additions and 4 deletions
|
@ -63,9 +63,19 @@ public:
|
|||
// NOTE: In error cases, the function will return as if it succeeded.
|
||||
virtual bool put_by_index(u32 property_index, Value value) override
|
||||
{
|
||||
// FIXME: If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value).
|
||||
// Otherwise, let numValue be ? ToNumber(value).
|
||||
// (set_value currently takes value by itself)
|
||||
auto& vm = this->vm();
|
||||
auto& global_object = this->global_object();
|
||||
|
||||
Value num_value;
|
||||
if (content_type() == TypedArrayBase::ContentType::BigInt) {
|
||||
num_value = value.to_bigint(global_object);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
} else {
|
||||
num_value = value.to_number(global_object);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
}
|
||||
|
||||
if (!is_valid_integer_index(property_index))
|
||||
return true;
|
||||
|
@ -82,7 +92,7 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
viewed_array_buffer()->template set_value<T>(indexed_position.value(), value, true, ArrayBuffer::Order::Unordered);
|
||||
viewed_array_buffer()->template set_value<T>(indexed_position.value(), num_value, true, ArrayBuffer::Order::Unordered);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue