1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 05:47:34 +00:00

LibJS: Rename IterableToList to IteratorToList

This is an editorial change in the ECMA-262 spec. See:
ff60140

In doing so, as the new name implies, callsites are updated to pass in
an IteratorRecord themselves, rather than an iterable value.
This commit is contained in:
Timothy Flynn 2023-07-18 15:02:28 -04:00 committed by Andreas Kling
parent 1760361304
commit a7a109062a
6 changed files with 12 additions and 25 deletions

View file

@ -208,29 +208,16 @@ NonnullGCPtr<Object> create_iterator_result_object(VM& vm, Value value, bool don
return object;
}
// 7.4.13 IterableToList ( items [ , method ] ), https://tc39.es/ecma262/#sec-iterabletolist
ThrowCompletionOr<MarkedVector<Value>> iterable_to_list(VM& vm, Value items, GCPtr<FunctionObject> method)
// 7.4.13 IteratorToList ( iteratorRecord ), https://tc39.es/ecma262/#sec-iteratortolist
ThrowCompletionOr<MarkedVector<Value>> iterator_to_list(VM& vm, IteratorRecord const& iterator_record)
{
IteratorRecord iterator_record;
// 1. If method is present, then
if (method) {
// a. Let iteratorRecord be ? GetIteratorFromMethod(items, method).
iterator_record = TRY(get_iterator_from_method(vm, items, *method));
}
// 2. Else,
else {
// b. Let iteratorRecord be ? GetIterator(items, sync).
iterator_record = TRY(get_iterator(vm, items, IteratorHint::Sync));
}
// 3. Let values be a new empty List.
// 1. Let values be a new empty List.
MarkedVector<Value> values(vm.heap());
// 4. Let next be true.
// 2. Let next be true.
GCPtr<Object> next;
// 5. Repeat, while next is not false,
// 3. Repeat, while next is not false,
do {
// a. Set next to ? IteratorStep(iteratorRecord).
next = TRY(iterator_step(vm, iterator_record));
@ -245,7 +232,7 @@ ThrowCompletionOr<MarkedVector<Value>> iterable_to_list(VM& vm, Value items, GCP
}
} while (next);
// 6. Return values.
// 4. Return values.
return values;
}