2021-11-23 15:01:35 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2021, David Tuin <davidot@serenityos.org>
|
2023-04-13 00:47:15 +02:00
|
|
|
* Copyright (c) 2022-2023, Linus Groh <linusg@serenityos.org>
|
2021-11-23 15:01:35 +01:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <LibJS/Runtime/AsyncFromSyncIterator.h>
|
|
|
|
#include <LibJS/Runtime/AsyncFromSyncIteratorPrototype.h>
|
|
|
|
#include <LibJS/Runtime/GlobalObject.h>
|
|
|
|
|
|
|
|
namespace JS {
|
|
|
|
|
2022-12-13 20:49:50 +00:00
|
|
|
NonnullGCPtr<AsyncFromSyncIterator> AsyncFromSyncIterator::create(Realm& realm, Iterator sync_iterator_record)
|
2021-11-23 15:01:35 +01:00
|
|
|
{
|
2023-01-28 13:39:44 -05:00
|
|
|
return realm.heap().allocate<AsyncFromSyncIterator>(realm, realm, sync_iterator_record).release_allocated_value_but_fixme_should_propagate_errors();
|
2021-11-23 15:01:35 +01:00
|
|
|
}
|
|
|
|
|
2022-08-16 00:20:49 +01:00
|
|
|
AsyncFromSyncIterator::AsyncFromSyncIterator(Realm& realm, Iterator sync_iterator_record)
|
2023-04-13 00:47:15 +02:00
|
|
|
: Object(ConstructWithPrototypeTag::Tag, realm.intrinsics().async_from_sync_iterator_prototype())
|
2021-11-23 15:01:35 +01:00
|
|
|
, m_sync_iterator_record(sync_iterator_record)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2023-01-28 12:33:35 -05:00
|
|
|
ThrowCompletionOr<void> AsyncFromSyncIterator::initialize(Realm& realm)
|
2021-11-23 15:01:35 +01:00
|
|
|
{
|
2023-01-28 12:33:35 -05:00
|
|
|
MUST_OR_THROW_OOM(Base::initialize(realm));
|
|
|
|
return {};
|
2021-11-23 15:01:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void AsyncFromSyncIterator::visit_edges(Cell::Visitor& visitor)
|
|
|
|
{
|
2023-03-21 10:08:44 -07:00
|
|
|
Base::visit_edges(visitor);
|
2022-01-09 19:12:24 +01:00
|
|
|
visitor.visit(m_sync_iterator_record.iterator);
|
|
|
|
visitor.visit(m_sync_iterator_record.next_method);
|
2021-11-23 15:01:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|