11cb0ef41Sopenharmony_ci// Copyright 2016 the V8 project authors. All rights reserved.
21cb0ef41Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be
31cb0ef41Sopenharmony_ci// found in the LICENSE file.
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ci#ifndef V8_BUILTINS_BUILTINS_ASYNC_GEN_H_
61cb0ef41Sopenharmony_ci#define V8_BUILTINS_BUILTINS_ASYNC_GEN_H_
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_ci#include "src/builtins/builtins-promise-gen.h"
91cb0ef41Sopenharmony_ci
101cb0ef41Sopenharmony_cinamespace v8 {
111cb0ef41Sopenharmony_cinamespace internal {
121cb0ef41Sopenharmony_ci
131cb0ef41Sopenharmony_ciclass AsyncBuiltinsAssembler : public PromiseBuiltinsAssembler {
141cb0ef41Sopenharmony_ci public:
151cb0ef41Sopenharmony_ci  explicit AsyncBuiltinsAssembler(compiler::CodeAssemblerState* state)
161cb0ef41Sopenharmony_ci      : PromiseBuiltinsAssembler(state) {}
171cb0ef41Sopenharmony_ci
181cb0ef41Sopenharmony_ci protected:
191cb0ef41Sopenharmony_ci  // Perform steps to resume generator after `value` is resolved.
201cb0ef41Sopenharmony_ci  // `on_reject` is the SharedFunctioninfo instance used to create the reject
211cb0ef41Sopenharmony_ci  // closure. `on_resolve` is the SharedFunctioninfo instance used to create the
221cb0ef41Sopenharmony_ci  // resolve closure. Returns the Promise-wrapped `value`.
231cb0ef41Sopenharmony_ci  TNode<Object> Await(TNode<Context> context,
241cb0ef41Sopenharmony_ci                      TNode<JSGeneratorObject> generator, TNode<Object> value,
251cb0ef41Sopenharmony_ci                      TNode<JSPromise> outer_promise,
261cb0ef41Sopenharmony_ci                      TNode<SharedFunctionInfo> on_resolve_sfi,
271cb0ef41Sopenharmony_ci                      TNode<SharedFunctionInfo> on_reject_sfi,
281cb0ef41Sopenharmony_ci                      TNode<Oddball> is_predicted_as_caught);
291cb0ef41Sopenharmony_ci  TNode<Object> Await(TNode<Context> context,
301cb0ef41Sopenharmony_ci                      TNode<JSGeneratorObject> generator, TNode<Object> value,
311cb0ef41Sopenharmony_ci                      TNode<JSPromise> outer_promise,
321cb0ef41Sopenharmony_ci                      TNode<SharedFunctionInfo> on_resolve_sfi,
331cb0ef41Sopenharmony_ci                      TNode<SharedFunctionInfo> on_reject_sfi,
341cb0ef41Sopenharmony_ci                      bool is_predicted_as_caught) {
351cb0ef41Sopenharmony_ci    return Await(context, generator, value, outer_promise, on_resolve_sfi,
361cb0ef41Sopenharmony_ci                 on_reject_sfi, BooleanConstant(is_predicted_as_caught));
371cb0ef41Sopenharmony_ci  }
381cb0ef41Sopenharmony_ci
391cb0ef41Sopenharmony_ci  // Return a new built-in function object as defined in
401cb0ef41Sopenharmony_ci  // Async Iterator Value Unwrap Functions
411cb0ef41Sopenharmony_ci  TNode<JSFunction> CreateUnwrapClosure(TNode<NativeContext> native_context,
421cb0ef41Sopenharmony_ci                                        TNode<Oddball> done);
431cb0ef41Sopenharmony_ci
441cb0ef41Sopenharmony_ci private:
451cb0ef41Sopenharmony_ci  void InitializeNativeClosure(TNode<Context> context,
461cb0ef41Sopenharmony_ci                               TNode<NativeContext> native_context,
471cb0ef41Sopenharmony_ci                               TNode<HeapObject> function,
481cb0ef41Sopenharmony_ci                               TNode<SharedFunctionInfo> shared_info);
491cb0ef41Sopenharmony_ci  TNode<Context> AllocateAsyncIteratorValueUnwrapContext(
501cb0ef41Sopenharmony_ci      TNode<NativeContext> native_context, TNode<Oddball> done);
511cb0ef41Sopenharmony_ci};
521cb0ef41Sopenharmony_ci
531cb0ef41Sopenharmony_ci}  // namespace internal
541cb0ef41Sopenharmony_ci}  // namespace v8
551cb0ef41Sopenharmony_ci
561cb0ef41Sopenharmony_ci#endif  // V8_BUILTINS_BUILTINS_ASYNC_GEN_H_
57