AsyncFunctionDriverWrapper.h 997 B

1234567891011121314151617181920212223242526272829303132333435
  1. /*
  2. * Copyright (c) 2021, Ali Mohammad Pur <mpfard@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibJS/Bytecode/Interpreter.h>
  8. #include <LibJS/Runtime/ECMAScriptFunctionObject.h>
  9. #include <LibJS/Runtime/GeneratorObject.h>
  10. #include <LibJS/Runtime/Object.h>
  11. #include <LibJS/Runtime/Promise.h>
  12. namespace JS {
  13. class AsyncFunctionDriverWrapper final : public Promise {
  14. JS_OBJECT(AsyncFunctionDriverWrapper, Promise);
  15. public:
  16. static ThrowCompletionOr<Value> create(GlobalObject&, GeneratorObject*);
  17. explicit AsyncFunctionDriverWrapper(GlobalObject&, GeneratorObject*);
  18. virtual ~AsyncFunctionDriverWrapper() override;
  19. void visit_edges(Cell::Visitor&) override;
  20. ThrowCompletionOr<Value> react_to_async_task_completion(VM&, GlobalObject&, Value, bool is_successful);
  21. private:
  22. GeneratorObject* m_generator_object { nullptr };
  23. NativeFunction* m_on_fulfillment { nullptr };
  24. NativeFunction* m_on_rejection { nullptr };
  25. };
  26. }