mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:47:34 +00:00
LibJS: Replace GlobalObject with VM in Iterator AOs [Part 7/19]
This commit is contained in:
parent
ae9e031f56
commit
ccdfa2320c
30 changed files with 171 additions and 182 deletions
|
@ -240,9 +240,6 @@ Array* format_list_to_parts(VM& vm, ListFormat const& list_format, Vector<String
|
|||
// 13.5.5 StringListFromIterable ( iterable ), https://tc39.es/ecma402/#sec-createstringlistfromiterable
|
||||
ThrowCompletionOr<Vector<String>> string_list_from_iterable(VM& vm, Value iterable)
|
||||
{
|
||||
auto& realm = *vm.current_realm();
|
||||
auto& global_object = realm.global_object();
|
||||
|
||||
// 1. If iterable is undefined, then
|
||||
if (iterable.is_undefined()) {
|
||||
// a. Return a new empty List.
|
||||
|
@ -250,7 +247,7 @@ ThrowCompletionOr<Vector<String>> string_list_from_iterable(VM& vm, Value iterab
|
|||
}
|
||||
|
||||
// 2. Let iteratorRecord be ? GetIterator(iterable).
|
||||
auto iterator_record = TRY(get_iterator(global_object, iterable));
|
||||
auto iterator_record = TRY(get_iterator(vm, iterable));
|
||||
|
||||
// 3. Let list be a new empty List.
|
||||
Vector<String> list;
|
||||
|
@ -261,12 +258,12 @@ ThrowCompletionOr<Vector<String>> string_list_from_iterable(VM& vm, Value iterab
|
|||
// 5. Repeat, while next is not false,
|
||||
do {
|
||||
// a. Set next to ? IteratorStep(iteratorRecord).
|
||||
next = TRY(iterator_step(global_object, iterator_record));
|
||||
next = TRY(iterator_step(vm, iterator_record));
|
||||
|
||||
// b. If next is not false, then
|
||||
if (next != nullptr) {
|
||||
// i. Let nextValue be ? IteratorValue(next).
|
||||
auto next_value = TRY(iterator_value(global_object, *next));
|
||||
auto next_value = TRY(iterator_value(vm, *next));
|
||||
|
||||
// ii. If Type(nextValue) is not String, then
|
||||
if (!next_value.is_string()) {
|
||||
|
@ -274,7 +271,7 @@ ThrowCompletionOr<Vector<String>> string_list_from_iterable(VM& vm, Value iterab
|
|||
auto error = vm.throw_completion<TypeError>(ErrorType::NotAString, next_value);
|
||||
|
||||
// 2. Return ? IteratorClose(iteratorRecord, error).
|
||||
return iterator_close(global_object, iterator_record, move(error));
|
||||
return iterator_close(vm, iterator_record, move(error));
|
||||
}
|
||||
|
||||
// iii. Append nextValue to the end of the List list.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue