/src/hermes/lib/VM/JSGenerator.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright (c) Meta Platforms, Inc. and affiliates. |
3 | | * |
4 | | * This source code is licensed under the MIT license found in the |
5 | | * LICENSE file in the root directory of this source tree. |
6 | | */ |
7 | | |
8 | | #include "hermes/VM/JSGenerator.h" |
9 | | |
10 | | #include "hermes/VM/BuildMetadata.h" |
11 | | |
12 | | namespace hermes { |
13 | | namespace vm { |
14 | | |
15 | | //===----------------------------------------------------------------------===// |
16 | | // class JSGenerator |
17 | | |
18 | | const ObjectVTable JSGenerator::vt{ |
19 | | VTable(CellKind::JSGeneratorKind, cellSize<JSGenerator>()), |
20 | | JSGenerator::_getOwnIndexedRangeImpl, |
21 | | JSGenerator::_haveOwnIndexedImpl, |
22 | | JSGenerator::_getOwnIndexedPropertyFlagsImpl, |
23 | | JSGenerator::_getOwnIndexedImpl, |
24 | | JSGenerator::_setOwnIndexedImpl, |
25 | | JSGenerator::_deleteOwnIndexedImpl, |
26 | | JSGenerator::_checkAllOwnIndexedImpl, |
27 | | }; |
28 | | |
29 | 1 | void JSGeneratorBuildMeta(const GCCell *cell, Metadata::Builder &mb) { |
30 | 1 | mb.addJSObjectOverlapSlots(JSObject::numOverlapSlots<JSGenerator>()); |
31 | 1 | JSObjectBuildMeta(cell, mb); |
32 | 1 | const auto *self = static_cast<const JSGenerator *>(cell); |
33 | 1 | mb.setVTable(&JSGenerator::vt); |
34 | 1 | mb.addField("innerFunction", &self->innerFunction_); |
35 | 1 | } |
36 | | |
37 | | CallResult<PseudoHandle<JSGenerator>> JSGenerator::create( |
38 | | Runtime &runtime, |
39 | | Handle<GeneratorInnerFunction> innerFunction, |
40 | 0 | Handle<JSObject> parentHandle) { |
41 | 0 | auto *cell = runtime.makeAFixed<JSGenerator>( |
42 | 0 | runtime, |
43 | 0 | parentHandle, |
44 | 0 | runtime.getHiddenClassForPrototype( |
45 | 0 | *parentHandle, numOverlapSlots<JSGenerator>())); |
46 | 0 | cell->innerFunction_.set(runtime, *innerFunction, runtime.getHeap()); |
47 | 0 | return JSObjectInit::initToPseudoHandle(runtime, cell); |
48 | 0 | } |
49 | | |
50 | | } // namespace vm |
51 | | } // namespace hermes |