/* * Copyright (c) 2021, Ali Mohammad Pur * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include namespace JS { class AsyncFunctionDriverWrapper final : public Promise { JS_OBJECT(AsyncFunctionDriverWrapper, Promise); GC_DECLARE_ALLOCATOR(AsyncFunctionDriverWrapper); public: [[nodiscard]] static GC::Ref create(Realm&, GeneratorObject*); virtual ~AsyncFunctionDriverWrapper() override = default; void visit_edges(Cell::Visitor&) override; void continue_async_execution(VM&, Value, bool is_successful); private: AsyncFunctionDriverWrapper(Realm&, GC::Ref, GC::Ref top_level_promise); ThrowCompletionOr await(Value); GC::Ref m_generator_object; GC::Ref m_top_level_promise; GC::Ptr m_current_promise { nullptr }; OwnPtr m_suspended_execution_context; }; }