tor-browser

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

ThrowMsgKind.cpp (1471B)


      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 "vm/ThrowMsgKind.h"
      8 
      9 #include "mozilla/Assertions.h"  // MOZ_CRASH
     10 
     11 #include "js/friend/ErrorMessages.h"  // JSErrNum, JSMSG_*
     12 
     13 JSErrNum js::ThrowMsgKindToErrNum(ThrowMsgKind kind) {
     14  switch (kind) {
     15    case ThrowMsgKind::AssignToCall:
     16      return JSMSG_ASSIGN_TO_CALL;
     17    case ThrowMsgKind::IteratorNoThrow:
     18      return JSMSG_ITERATOR_NO_THROW;
     19    case ThrowMsgKind::CantDeleteSuper:
     20      return JSMSG_CANT_DELETE_SUPER;
     21    case ThrowMsgKind::PrivateDoubleInit:
     22      return JSMSG_PRIVATE_FIELD_DOUBLE;
     23    case ThrowMsgKind::PrivateBrandDoubleInit:
     24      return JSMSG_PRIVATE_BRAND_DOUBLE;
     25    case ThrowMsgKind::MissingPrivateOnGet:
     26      return JSMSG_GET_MISSING_PRIVATE;
     27    case ThrowMsgKind::MissingPrivateOnSet:
     28      return JSMSG_SET_MISSING_PRIVATE;
     29    case ThrowMsgKind::AssignToPrivateMethod:
     30      return JSMSG_ASSIGN_TO_PRIVATE_METHOD;
     31    case ThrowMsgKind::DecoratorInvalidReturnType:
     32      return JSMSG_DECORATOR_INVALID_RETURN_TYPE;
     33 #ifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT
     34    case ThrowMsgKind::DisposeNotCallable:
     35      return JSMSG_DISPOSE_NOT_CALLABLE;
     36 #endif
     37  }
     38 
     39  MOZ_CRASH("Unexpected message kind");
     40 }