mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 10:57:35 +00:00
LibJS: Extract named vm variables in ArrayBufferPrototype::slice
This commit is contained in:
parent
3781948f0c
commit
e7435d68b0
1 changed files with 5 additions and 2 deletions
|
@ -41,6 +41,9 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayBufferPrototype::slice)
|
|||
{
|
||||
auto& realm = *vm.current_realm();
|
||||
|
||||
auto start = vm.argument(0);
|
||||
auto end = vm.argument(1);
|
||||
|
||||
// 1. Let O be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(O, [[ArrayBufferData]]).
|
||||
auto array_buffer_object = TRY(typed_this_value(vm));
|
||||
|
@ -56,7 +59,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayBufferPrototype::slice)
|
|||
auto length = array_buffer_object->byte_length();
|
||||
|
||||
// 6. Let relativeStart be ? ToIntegerOrInfinity(start).
|
||||
auto relative_start = TRY(vm.argument(0).to_integer_or_infinity(vm));
|
||||
auto relative_start = TRY(start.to_integer_or_infinity(vm));
|
||||
|
||||
double first;
|
||||
// 7. If relativeStart is -∞, let first be 0.
|
||||
|
@ -70,7 +73,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayBufferPrototype::slice)
|
|||
first = min(relative_start, (double)length);
|
||||
|
||||
// 10. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end).
|
||||
auto relative_end = vm.argument(1).is_undefined() ? length : TRY(vm.argument(1).to_integer_or_infinity(vm));
|
||||
auto relative_end = end.is_undefined() ? length : TRY(end.to_integer_or_infinity(vm));
|
||||
|
||||
double final;
|
||||
// 11. If relativeEnd is -∞, let final be 0.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue