tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

BuiltinObjectKind.h (1957B)


      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  Map,
     33  Promise,
     34  RegExp,
     35  Set,
     36  Symbol,
     37 
     38  // Built-in prototypes.
     39  FunctionPrototype,
     40  IteratorPrototype,
     41 
     42  // Built-in Intl prototypes.
     43  DateTimeFormatPrototype,
     44  NumberFormatPrototype,
     45 
     46  // Invalid placeholder.
     47  None,
     48 };
     49 
     50 /**
     51 * Return the BuiltinObjectKind for the given constructor name. Return
     52 * BuiltinObjectKind::None if no matching constructor was found.
     53 */
     54 BuiltinObjectKind BuiltinConstructorForName(
     55    frontend::TaggedParserAtomIndex name);
     56 
     57 /**
     58 * Return the BuiltinObjectKind for the given prototype name. Return
     59 * BuiltinObjectKind::None if no matching prototype was found.
     60 */
     61 BuiltinObjectKind BuiltinPrototypeForName(frontend::TaggedParserAtomIndex name);
     62 
     63 /**
     64 * Return the built-in object if already created for the given global. Otherwise
     65 * return nullptr.
     66 */
     67 JSObject* MaybeGetBuiltinObject(GlobalObject* global, BuiltinObjectKind kind);
     68 
     69 /**
     70 * Return the built-in object for the given global.
     71 */
     72 JSObject* GetOrCreateBuiltinObject(JSContext* cx, BuiltinObjectKind kind);
     73 
     74 /**
     75 * Return the display name for a built-in object.
     76 */
     77 const char* BuiltinObjectName(BuiltinObjectKind kind);
     78 
     79 }  // namespace js
     80 
     81 #endif /* vm_BuiltinObjectKind_h */