Bug 1842773 - Part 32: Allow constructing growable SharedArrayBuffers. r=sfink
[gecko.git] / js / src / vm / Value.cpp
blob94f5f8673123fb106509c6e8d94426e743a600c2
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/. */
7 #include "js/Value.h"
9 #include "mozilla/Assertions.h"
11 #include <inttypes.h>
13 static const JS::Value JSVAL_NULL =
14 JS::Value::fromTagAndPayload(JSVAL_TAG_NULL, 0);
15 static const JS::Value JSVAL_FALSE =
16 JS::Value::fromTagAndPayload(JSVAL_TAG_BOOLEAN, false);
17 static const JS::Value JSVAL_TRUE =
18 JS::Value::fromTagAndPayload(JSVAL_TAG_BOOLEAN, true);
19 static const JS::Value JSVAL_VOID =
20 JS::Value::fromTagAndPayload(JSVAL_TAG_UNDEFINED, 0);
21 static const mozilla::Maybe<JS::Value> JSVAL_NOTHING;
23 namespace JS {
25 const HandleValue NullHandleValue =
26 HandleValue::fromMarkedLocation(&JSVAL_NULL);
27 const HandleValue UndefinedHandleValue =
28 HandleValue::fromMarkedLocation(&JSVAL_VOID);
29 const HandleValue TrueHandleValue =
30 HandleValue::fromMarkedLocation(&JSVAL_TRUE);
31 const HandleValue FalseHandleValue =
32 HandleValue::fromMarkedLocation(&JSVAL_FALSE);
33 const Handle<mozilla::Maybe<Value>> NothingHandleValue =
34 Handle<mozilla::Maybe<Value>>::fromMarkedLocation(&JSVAL_NOTHING);
36 } // namespace JS
38 void js::ReportBadValueTypeAndCrash(const JS::Value& value) {
39 MOZ_CRASH_UNSAFE_PRINTF("JS::Value has illegal type: 0x%" PRIx64,
40 value.asRawBits());