mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:37:37 +00:00
LibJS: Port iterator_next() to NonnullGCPtr
This commit is contained in:
parent
b110258848
commit
e54536421a
4 changed files with 12 additions and 12 deletions
|
@ -68,7 +68,7 @@ ThrowCompletionOr<Iterator> get_iterator(VM& vm, Value value, IteratorHint hint,
|
|||
}
|
||||
|
||||
// 7.4.3 IteratorNext ( iteratorRecord [ , value ] ), https://tc39.es/ecma262/#sec-iteratornext
|
||||
ThrowCompletionOr<Object*> iterator_next(VM& vm, Iterator const& iterator_record, Optional<Value> value)
|
||||
ThrowCompletionOr<NonnullGCPtr<Object>> iterator_next(VM& vm, Iterator const& iterator_record, Optional<Value> value)
|
||||
{
|
||||
Value result;
|
||||
|
||||
|
@ -86,7 +86,7 @@ ThrowCompletionOr<Object*> iterator_next(VM& vm, Iterator const& iterator_record
|
|||
return vm.throw_completion<TypeError>(ErrorType::IterableNextBadReturn);
|
||||
|
||||
// 4. Return result.
|
||||
return &result.as_object();
|
||||
return result.as_object();
|
||||
}
|
||||
|
||||
// 7.4.4 IteratorComplete ( iterResult ), https://tc39.es/ecma262/#sec-iteratorcomplete
|
||||
|
@ -107,17 +107,17 @@ ThrowCompletionOr<Value> iterator_value(VM& vm, Object& iterator_result)
|
|||
ThrowCompletionOr<Object*> iterator_step(VM& vm, Iterator const& iterator_record)
|
||||
{
|
||||
// 1. Let result be ? IteratorNext(iteratorRecord).
|
||||
auto* result = TRY(iterator_next(vm, iterator_record));
|
||||
auto result = TRY(iterator_next(vm, iterator_record));
|
||||
|
||||
// 2. Let done be ? IteratorComplete(result).
|
||||
auto done = TRY(iterator_complete(vm, *result));
|
||||
auto done = TRY(iterator_complete(vm, result));
|
||||
|
||||
// 3. If done is true, return false.
|
||||
if (done)
|
||||
return nullptr;
|
||||
|
||||
// 4. Return result.
|
||||
return result;
|
||||
return result.ptr();
|
||||
}
|
||||
|
||||
// 7.4.7 IteratorClose ( iteratorRecord, completion ), https://tc39.es/ecma262/#sec-iteratorclose
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue