Debian Codegraph @

js/src/vm/DisposableRecord.h

raw
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: set ts=8 sts=2 et sw=2 tw=80:
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7 #ifndef vm_DisposableRecord_h
8 #define vm_DisposableRecord_h
9
10 #include "NamespaceImports.h"
11 #include "js/Value.h"
12 #include "vm/NativeObject.h"
13 #include "vm/UsingHint.h"
14
15 namespace js {
16
17 /**
18 * Explicit Resource Management Proposal
19 * DisposableResource Records
20 * https://arai-a.github.io/ecma262-compare/?pr=3000&id=sec-disposableresource-records
21 */
22
23 class DisposableRecordObject : public NativeObject {
24 public:
25 static const JSClass class_;
26
27 static constexpr uint32_t VALUE_SLOT = 0;
28 static constexpr uint32_t METHOD_SLOT = 1;
29 static constexpr uint32_t HINT_SLOT = 2;
30
31 static constexpr uint32_t RESERVED_SLOTS = 3;
32
33 [[nodiscard]] inline static DisposableRecordObject* create(
34 JSContext* cx, JS::Handle<JS::Value> value, JS::Handle<JS::Value> method,
35 UsingHint hint);
36
37 Value getObject() { return getReservedSlot(VALUE_SLOT); }
38
39 Value getMethod() { return getReservedSlot(METHOD_SLOT); }
40
41 UsingHint getHint() {
42 Value hint = getReservedSlot(HINT_SLOT);
43 UsingHint hintVal = UsingHint(hint.toInt32());
44 return hintVal;
45 }
46
47 static SharedShape* assignInitialShape(JSContext* cx,
48 Handle<DisposableRecordObject*> self);
49 };
50
51 } // namespace js
52
53 #endif // vm_DisposableRecord_h