Debian Codegraph @

js/src/vm/BuiltinObjectKind.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_BuiltinObjectKind_h
8 #define vm_BuiltinObjectKind_h
9
10 #include <stdint.h>
11
12 #include "jstypes.h"
13
14 struct JS_PUBLIC_API JSContext;
15 class JS_PUBLIC_API JSObject;
16
17 namespace js {
18
19 namespace frontend {
20 class TaggedParserAtomIndex;
21 }
22
23 class GlobalObject;
24
25 /**
26 * Built-in objects used by the GetBuiltinConstructor and GetBuiltinPrototype
27 * self-hosted intrinsics.
28 */
29 enum class BuiltinObjectKind : uint8_t {
30 // Built-in constructors.
31 Array,
32 ListFormat,
33 Map,
34 Promise,
35 RegExp,
36 Set,
37 Symbol,
38
39 // Built-in prototypes.
40 FunctionPrototype,
41 IteratorPrototype,
42
43 // Built-in Intl prototypes.
44 DateTimeFormatPrototype,
45 NumberFormatPrototype,
46
47 // Invalid placeholder.
48 None,
49 };
50
51 /**
52 * Return the BuiltinObjectKind for the given constructor name. Return
53 * BuiltinObjectKind::None if no matching constructor was found.
54 */
55 BuiltinObjectKind BuiltinConstructorForName(
56 frontend::TaggedParserAtomIndex name);
57
58 /**
59 * Return the BuiltinObjectKind for the given prototype name. Return
60 * BuiltinObjectKind::None if no matching prototype was found.
61 */
62 BuiltinObjectKind BuiltinPrototypeForName(frontend::TaggedParserAtomIndex name);
63
64 /**
65 * Return the built-in object if already created for the given global. Otherwise
66 * return nullptr.
67 */
68 JSObject* MaybeGetBuiltinObject(GlobalObject* global, BuiltinObjectKind kind);
69
70 /**
71 * Return the built-in object for the given global.
72 */
73 JSObject* GetOrCreateBuiltinObject(JSContext* cx, BuiltinObjectKind kind);
74
75 /**
76 * Return the display name for a built-in object.
77 */
78 const char* BuiltinObjectName(BuiltinObjectKind kind);
79
80 } // namespace js
81
82 #endif /* vm_BuiltinObjectKind_h */