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_INL_H_
6 #define V8_OBJECTS_JS_GENERATOR_INL_H_
7
8 #include "src/objects/js-generator.h"
9
10 #include "src/objects-inl.h" // Needed for write barriers
11
12 // Has to be the last include (doesn't have include guards):
13 #include "src/objects/object-macros.h"
14
15 namespace v8 {
16 namespace internal {
17
18 CAST_ACCESSOR(JSGeneratorObject)
CAST_ACCESSOR(JSAsyncGeneratorObject)19 CAST_ACCESSOR(JSAsyncGeneratorObject)
20
21 ACCESSORS(JSGeneratorObject, function, JSFunction, kFunctionOffset)
22 ACCESSORS(JSGeneratorObject, context, Context, kContextOffset)
23 ACCESSORS(JSGeneratorObject, receiver, Object, kReceiverOffset)
24 ACCESSORS(JSGeneratorObject, input_or_debug_pos, Object, kInputOrDebugPosOffset)
25 SMI_ACCESSORS(JSGeneratorObject, resume_mode, kResumeModeOffset)
26 SMI_ACCESSORS(JSGeneratorObject, continuation, kContinuationOffset)
27 ACCESSORS(JSGeneratorObject, parameters_and_registers, FixedArray,
28 kParametersAndRegistersOffset)
29
30 bool JSGeneratorObject::is_suspended() const {
31 DCHECK_LT(kGeneratorExecuting, 0);
32 DCHECK_LT(kGeneratorClosed, 0);
33 return continuation() >= 0;
34 }
35
is_closed()36 bool JSGeneratorObject::is_closed() const {
37 return continuation() == kGeneratorClosed;
38 }
39
is_executing()40 bool JSGeneratorObject::is_executing() const {
41 return continuation() == kGeneratorExecuting;
42 }
43
44 ACCESSORS(JSAsyncGeneratorObject, queue, HeapObject, kQueueOffset)
45 SMI_ACCESSORS(JSAsyncGeneratorObject, is_awaiting, kIsAwaitingOffset)
46
47 } // namespace internal
48 } // namespace v8
49
50 #include "src/objects/object-macros-undef.h"
51
52 #endif // V8_OBJECTS_JS_GENERATOR_INL_H_
53