/src/hermes/lib/VM/JSDate.cpp
Line | Count | Source |
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/JSDate.h" |
9 | | |
10 | | #include "hermes/VM/BuildMetadata.h" |
11 | | #include "hermes/VM/Runtime-inline.h" |
12 | | |
13 | | namespace hermes { |
14 | | namespace vm { |
15 | | |
16 | | //===----------------------------------------------------------------------===// |
17 | | // class JSDate |
18 | | |
19 | | const ObjectVTable JSDate::vt{ |
20 | | VTable(CellKind::JSDateKind, cellSize<JSDate>()), |
21 | | JSDate::_getOwnIndexedRangeImpl, |
22 | | JSDate::_haveOwnIndexedImpl, |
23 | | JSDate::_getOwnIndexedPropertyFlagsImpl, |
24 | | JSDate::_getOwnIndexedImpl, |
25 | | JSDate::_setOwnIndexedImpl, |
26 | | JSDate::_deleteOwnIndexedImpl, |
27 | | JSDate::_checkAllOwnIndexedImpl, |
28 | | }; |
29 | | |
30 | 1 | void JSDateBuildMeta(const GCCell *cell, Metadata::Builder &mb) { |
31 | 1 | mb.addJSObjectOverlapSlots(JSObject::numOverlapSlots<JSDate>()); |
32 | 1 | JSObjectBuildMeta(cell, mb); |
33 | 1 | mb.setVTable(&JSDate::vt); |
34 | 1 | } |
35 | | |
36 | | PseudoHandle<JSDate> |
37 | 0 | JSDate::create(Runtime &runtime, double value, Handle<JSObject> parentHandle) { |
38 | 0 | auto *cell = runtime.makeAFixed<JSDate>( |
39 | 0 | runtime, |
40 | 0 | value, |
41 | 0 | parentHandle, |
42 | 0 | runtime.getHiddenClassForPrototype( |
43 | 0 | *parentHandle, numOverlapSlots<JSDate>())); |
44 | 0 | return JSObjectInit::initToPseudoHandle(runtime, cell); |
45 | 0 | } |
46 | | |
47 | | } // namespace vm |
48 | | } // namespace hermes |