• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2018 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef V8_OBJECTS_JS_GENERATOR_H_
6 #define V8_OBJECTS_JS_GENERATOR_H_
7 
8 #include "src/objects/js-objects.h"
9 #include "src/objects/struct.h"
10 
11 // Has to be the last include (doesn't have include guards):
12 #include "src/objects/object-macros.h"
13 
14 namespace v8 {
15 namespace internal {
16 
17 // Forward declarations.
18 class JSPromise;
19 
20 #include "torque-generated/src/objects/js-generator-tq.inc"
21 
22 class JSGeneratorObject
23     : public TorqueGeneratedJSGeneratorObject<JSGeneratorObject, JSObject> {
24  public:
25   enum ResumeMode { kNext, kReturn, kThrow };
26 
27   inline bool is_closed() const;
28   inline bool is_executing() const;
29   inline bool is_suspended() const;
30 
31   // For suspended generators: the source position at which the generator
32   // is suspended.
33   int source_position() const;
34 
35   // Dispatched behavior.
36   DECL_PRINTER(JSGeneratorObject)
37 
38   // Magic sentinel values for the continuation.
39   static const int kGeneratorExecuting = -2;
40   static const int kGeneratorClosed = -1;
41 
42   TQ_OBJECT_CONSTRUCTORS(JSGeneratorObject)
43 };
44 
45 class JSAsyncFunctionObject
46     : public TorqueGeneratedJSAsyncFunctionObject<JSAsyncFunctionObject,
47                                                   JSGeneratorObject> {
48  public:
49   // Dispatched behavior.
50   DECL_VERIFIER(JSAsyncFunctionObject)
51   DECL_PRINTER(JSAsyncFunctionObject)
52 
53   TQ_OBJECT_CONSTRUCTORS(JSAsyncFunctionObject)
54 };
55 
56 class JSAsyncGeneratorObject
57     : public TorqueGeneratedJSAsyncGeneratorObject<JSAsyncGeneratorObject,
58                                                    JSGeneratorObject> {
59  public:
60   // Dispatched behavior.
61   DECL_VERIFIER(JSAsyncGeneratorObject)
62   DECL_PRINTER(JSAsyncGeneratorObject)
63 
64   TQ_OBJECT_CONSTRUCTORS(JSAsyncGeneratorObject)
65 };
66 
67 class AsyncGeneratorRequest
68     : public TorqueGeneratedAsyncGeneratorRequest<AsyncGeneratorRequest,
69                                                   Struct> {
70  public:
71   DECL_PRINTER(AsyncGeneratorRequest)
72   DECL_VERIFIER(AsyncGeneratorRequest)
73 
74   TQ_OBJECT_CONSTRUCTORS(AsyncGeneratorRequest)
75 };
76 
77 }  // namespace internal
78 }  // namespace v8
79 
80 #include "src/objects/object-macros-undef.h"
81 
82 #endif  // V8_OBJECTS_JS_GENERATOR_H_
83