tor-browser

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

ParseNodeVerify.h (1520B)


      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 frontend_ParseNodeVerify_h
      8 #define frontend_ParseNodeVerify_h
      9 
     10 #include "frontend/SyntaxParseHandler.h"  // SyntaxParseHandler::Node
     11 
     12 namespace js {
     13 
     14 class FrontendContext;
     15 class LifoAlloc;
     16 
     17 namespace frontend {
     18 
     19 class ParseNode;
     20 
     21 // In most builds, examine the given ParseNode and crash if it's not
     22 // well-formed. (In late beta and shipping builds of Firefox, this does
     23 // nothing.)
     24 //
     25 // This returns true on success, and false only if we hit the recursion limit.
     26 // If the ParseNode is actually bad, we crash.
     27 
     28 #ifdef DEBUG
     29 [[nodiscard]] extern bool CheckParseTree(FrontendContext* fc,
     30                                         const LifoAlloc& alloc, ParseNode* pn);
     31 #else
     32 [[nodiscard]] inline bool CheckParseTree(FrontendContext* fc,
     33                                         const LifoAlloc& alloc,
     34                                         ParseNode* pn) {
     35  return true;
     36 }
     37 #endif
     38 
     39 [[nodiscard]] inline bool CheckParseTree(FrontendContext* fc,
     40                                         const LifoAlloc& alloc,
     41                                         SyntaxParseHandler::Node pn) {
     42  return true;
     43 }
     44 
     45 } /* namespace frontend */
     46 } /* namespace js */
     47 
     48 #endif  // frontend_ParseNodeVerify_h