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 class StructBodyDescriptor; 20 21 #include "torque-generated/src/objects/js-generator-tq.inc" 22 23 class JSGeneratorObject 24 : public TorqueGeneratedJSGeneratorObject<JSGeneratorObject, JSObject> { 25 public: 26 enum ResumeMode { kNext, kReturn, kThrow }; 27 28 inline bool is_closed() const; 29 inline bool is_executing() const; 30 inline bool is_suspended() const; 31 32 // For suspended generators: the source position at which the generator 33 // is suspended. 34 int source_position() const; 35 36 // Dispatched behavior. 37 DECL_PRINTER(JSGeneratorObject) 38 39 // Magic sentinel values for the continuation. 40 static const int kGeneratorExecuting = -2; 41 static const int kGeneratorClosed = -1; 42 43 TQ_OBJECT_CONSTRUCTORS(JSGeneratorObject) 44 }; 45 46 class JSAsyncFunctionObject 47 : public TorqueGeneratedJSAsyncFunctionObject<JSAsyncFunctionObject, 48 JSGeneratorObject> { 49 public: 50 // Dispatched behavior. 51 DECL_VERIFIER(JSAsyncFunctionObject) 52 DECL_PRINTER(JSAsyncFunctionObject) 53 54 TQ_OBJECT_CONSTRUCTORS(JSAsyncFunctionObject) 55 }; 56 57 class JSAsyncGeneratorObject 58 : public TorqueGeneratedJSAsyncGeneratorObject<JSAsyncGeneratorObject, 59 JSGeneratorObject> { 60 public: 61 // Dispatched behavior. 62 DECL_VERIFIER(JSAsyncGeneratorObject) 63 DECL_PRINTER(JSAsyncGeneratorObject) 64 65 TQ_OBJECT_CONSTRUCTORS(JSAsyncGeneratorObject) 66 }; 67 68 class AsyncGeneratorRequest 69 : public TorqueGeneratedAsyncGeneratorRequest<AsyncGeneratorRequest, 70 Struct> { 71 public: 72 DECL_PRINTER(AsyncGeneratorRequest) 73 DECL_VERIFIER(AsyncGeneratorRequest) 74 75 using BodyDescriptor = StructBodyDescriptor; 76 77 TQ_OBJECT_CONSTRUCTORS(AsyncGeneratorRequest) 78 }; 79 80 } // namespace internal 81 } // namespace v8 82 83 #include "src/objects/object-macros-undef.h" 84 85 #endif // V8_OBJECTS_JS_GENERATOR_H_ 86