Boolean-inl.h (1258B)
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_Boolean_inl_h 8 #define builtin_Boolean_inl_h 9 10 #include "builtin/Boolean.h" 11 12 #include "vm/JSContext.h" 13 #include "vm/WrapperObject.h" 14 15 namespace js { 16 17 inline bool EmulatesUndefined(JSObject* obj) { 18 // Called from ProcessTryNotes via ToBoolean with a pending exception. 19 AutoUnsafeCallWithABI unsafe(UnsafeABIStrictness::AllowPendingExceptions); 20 JSObject* actual = 21 MOZ_LIKELY(!obj->is<WrapperObject>()) ? obj : UncheckedUnwrap(obj); 22 return actual->getClass()->emulatesUndefined(); 23 } 24 25 inline bool EmulatesUndefinedCheckFuse(JSObject* obj, size_t fuseValue) { 26 AutoUnsafeCallWithABI unsafe; 27 JSObject* actual = 28 MOZ_LIKELY(!obj->is<WrapperObject>()) ? obj : UncheckedUnwrap(obj); 29 bool emulatesUndefined = actual->getClass()->emulatesUndefined(); 30 if (emulatesUndefined) { 31 MOZ_RELEASE_ASSERT(fuseValue != 0); 32 } 33 return emulatesUndefined; 34 } 35 36 } /* namespace js */ 37 38 #endif /* builtin_Boolean_inl_h */