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 #include "js/Value.h" 8 9 #include "mozilla/Assertions.h" 10 11 #include <inttypes.h> 12 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; 22 23 namespace JS { 24 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); 35 36 } // namespace JS 37 ReportBadValueTypeAndCrash(const JS::Value & value)38void js::ReportBadValueTypeAndCrash(const JS::Value& value) { 39 MOZ_CRASH_UNSAFE_PRINTF("JS::Value has illegal type: 0x%" PRIx64, 40 value.asRawBits()); 41 } 42