mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 17:17:35 +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.
|
// NOTE: In error cases, the function will return as if it succeeded.
|
||||||
virtual bool put_by_index(u32 property_index, Value value) override
|
virtual bool put_by_index(u32 property_index, Value value) override
|
||||||
{
|
{
|
||||||
// FIXME: If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value).
|
auto& vm = this->vm();
|
||||||
// Otherwise, let numValue be ? ToNumber(value).
|
auto& global_object = this->global_object();
|
||||||
// (set_value currently takes value by itself)
|
|
||||||
|
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))
|
if (!is_valid_integer_index(property_index))
|
||||||
return true;
|
return true;
|
||||||
|
@ -82,7 +92,7 @@ public:
|
||||||
return true;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue