mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:47:34 +00:00
LibJS: Replace all uses of to_size_t() and remove it :^)
Yay for more spec compliance! This is pretty easy as everything using to_size_t() should just be using one of the other abstract operations we already have implemented. This allows us to get rid of get_length() in ArrayPrototype, which is basically a slightly incorrect implementation of length_of_array_like(), and then finally remove to_size_t()! Also fixes a couple of "argument is undefined" vs "argument isn't given" issues along the way.
This commit is contained in:
parent
9be0b664e3
commit
f369229770
6 changed files with 47 additions and 83 deletions
|
@ -513,21 +513,6 @@ u32 Value::to_u32(GlobalObject& global_object) const
|
|||
return number.as_u32();
|
||||
}
|
||||
|
||||
size_t Value::to_size_t(GlobalObject& global_object) const
|
||||
{
|
||||
// FIXME: Replace uses of this function with to_length/to_index for correct behaviour and remove this eventually.
|
||||
if (is_empty())
|
||||
return 0;
|
||||
auto number = to_number(global_object);
|
||||
if (global_object.vm().exception())
|
||||
return INVALID;
|
||||
if (number.is_nan())
|
||||
return 0;
|
||||
if (number.as_double() <= 0)
|
||||
return 0;
|
||||
return number.as_size_t();
|
||||
}
|
||||
|
||||
size_t Value::to_length(GlobalObject& global_object) const
|
||||
{
|
||||
// 7.1.20 ToLength, https://tc39.es/ecma262/#sec-tolength
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue