| 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 builtin_BigInt_h |
| 8 |
#define builtin_BigInt_h |
| 9 |
|
| 10 |
#include "js/Class.h" |
| 11 |
#include "js/RootingAPI.h" |
| 12 |
#include "vm/NativeObject.h" |
| 13 |
|
| 14 |
namespace js { |
| 15 |
|
| 16 |
class GlobalObject; |
| 17 |
|
| 18 |
class BigIntObject : public NativeObject { |
| 19 |
static const unsigned PRIMITIVE_VALUE_SLOT = 0; |
| 20 |
static const unsigned RESERVED_SLOTS = 1; |
| 21 |
|
| 22 |
public: |
| 23 |
static const ClassSpec classSpec_; |
| 24 |
static const JSClass class_; |
| 25 |
static const JSClass protoClass_; |
| 26 |
|
| 27 |
static JSObject* create(JSContext* cx, JS::Handle<JS::BigInt*> bi); |
| 28 |
|
| 29 |
// Methods defined on BigInt.prototype. |
| 30 |
static bool valueOf_impl(JSContext* cx, const CallArgs& args); |
| 31 |
static bool valueOf(JSContext* cx, unsigned argc, JS::Value* vp); |
| 32 |
static bool toString_impl(JSContext* cx, const CallArgs& args); |
| 33 |
static bool toString(JSContext* cx, unsigned argc, JS::Value* vp); |
| 34 |
#ifndef JS_HAS_INTL_API |
| 35 |
static bool toLocaleString_impl(JSContext* cx, const CallArgs& args); |
| 36 |
static bool toLocaleString(JSContext* cx, unsigned argc, JS::Value* vp); |
| 37 |
#endif |
| 38 |
static bool asUintN(JSContext* cx, unsigned argc, JS::Value* vp); |
| 39 |
static bool asIntN(JSContext* cx, unsigned argc, JS::Value* vp); |
| 40 |
|
| 41 |
JS::BigInt* unbox() const; |
| 42 |
|
| 43 |
private: |
| 44 |
static const JSPropertySpec properties[]; |
| 45 |
static const JSFunctionSpec methods[]; |
| 46 |
static const JSFunctionSpec staticMethods[]; |
| 47 |
}; |
| 48 |
|
| 49 |
extern JSObject* InitBigIntClass(JSContext* cx, Handle<GlobalObject*> global); |
| 50 |
|
| 51 |
} // namespace js |
| 52 |
|
| 53 |
#endif |