mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 12:57:34 +00:00
LibJS: Implement proper Iterator records
Instead of using plain objects as Iterator records, causes confusion about the object itself actually being its [[Iterator]] slot, and requires non-standard type conversion shenanigans fpr the [[NextValue]] and [[Done]] internal slots, implement a proper Iterator record struct and use it throughout. Also annotate the remaining Iterator AOs with spec comments while we're here.
This commit is contained in:
parent
e141f1e976
commit
09a11fa6ea
17 changed files with 337 additions and 209 deletions
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2020, Matthew Olsson <mattco@serenityos.org>
|
||||
* Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -9,6 +10,7 @@
|
|||
#include <AK/Function.h>
|
||||
#include <AK/Optional.h>
|
||||
#include <LibJS/Runtime/Completion.h>
|
||||
#include <LibJS/Runtime/Iterator.h>
|
||||
#include <LibJS/Runtime/Object.h>
|
||||
|
||||
namespace JS {
|
||||
|
@ -20,17 +22,17 @@ enum class IteratorHint {
|
|||
Async,
|
||||
};
|
||||
|
||||
ThrowCompletionOr<Object*> get_iterator(GlobalObject&, Value value, IteratorHint hint = IteratorHint::Sync, Optional<Value> method = {});
|
||||
ThrowCompletionOr<Object*> iterator_next(Object& iterator, Optional<Value> value = {});
|
||||
ThrowCompletionOr<Object*> iterator_step(GlobalObject&, Object& iterator);
|
||||
ThrowCompletionOr<Iterator> get_iterator(GlobalObject&, Value, IteratorHint = IteratorHint::Sync, Optional<Value> method = {});
|
||||
ThrowCompletionOr<Object*> iterator_next(GlobalObject&, Iterator const&, Optional<Value> = {});
|
||||
ThrowCompletionOr<Object*> iterator_step(GlobalObject&, Iterator const&);
|
||||
ThrowCompletionOr<bool> iterator_complete(GlobalObject&, Object& iterator_result);
|
||||
ThrowCompletionOr<Value> iterator_value(GlobalObject&, Object& iterator_result);
|
||||
Completion iterator_close(Object& iterator, Completion completion);
|
||||
Completion async_iterator_close(Object& iterator, Completion completion);
|
||||
Object* create_iterator_result_object(GlobalObject&, Value value, bool done);
|
||||
Completion iterator_close(GlobalObject&, Iterator const&, Completion);
|
||||
Completion async_iterator_close(GlobalObject&, Iterator const&, Completion);
|
||||
Object* create_iterator_result_object(GlobalObject&, Value, bool done);
|
||||
ThrowCompletionOr<MarkedValueList> iterable_to_list(GlobalObject&, Value iterable, Optional<Value> method = {});
|
||||
|
||||
using IteratorValueCallback = Function<Optional<Completion>(Value)>;
|
||||
Completion get_iterator_values(GlobalObject& global_object, Value iterable, IteratorValueCallback callback, Optional<Value> method = {});
|
||||
Completion get_iterator_values(GlobalObject&, Value iterable, IteratorValueCallback callback, Optional<Value> method = {});
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue