tor-browser

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

FoldConstants.h (1913B)


      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_FoldConstants_h
      8 #define frontend_FoldConstants_h
      9 
     10 #include "frontend/Stencil.h"
     11 #include "frontend/SyntaxParseHandler.h"
     12 
     13 namespace js {
     14 
     15 class FrontendContext;
     16 
     17 namespace frontend {
     18 
     19 class FullParseHandler;
     20 template <class ParseHandler>
     21 class PerHandlerParser;
     22 class ParserAtomsTable;
     23 
     24 // Perform constant folding on the given AST. For example, the program
     25 // `print(2 + 2)` would become `print(4)`.
     26 //
     27 // pnp is the address of a pointer variable that points to the root node of the
     28 // AST. On success, *pnp points to the root node of the new tree, which may be
     29 // the same node (unchanged or modified in place) or a new node.
     30 //
     31 // Usage:
     32 //    pn = MOZ_TRY(parser->statement());
     33 //    if (!FoldConstants(fc, parserAtoms, bigInts, &pn, parser)) {
     34 //        return errorResult();
     35 //    }
     36 [[nodiscard]] extern bool FoldConstants(FrontendContext* fc,
     37                                        ParserAtomsTable& parserAtoms,
     38                                        BigIntStencilVector& bigInts,
     39                                        ParseNode** pnp,
     40                                        FullParseHandler* handler);
     41 
     42 [[nodiscard]] inline bool FoldConstants(FrontendContext* fc,
     43                                        ParserAtomsTable& parserAtoms,
     44                                        BigIntStencilVector& bigInts,
     45                                        typename SyntaxParseHandler::Node* pnp,
     46                                        SyntaxParseHandler* handler) {
     47  return true;
     48 }
     49 
     50 } /* namespace frontend */
     51 } /* namespace js */
     52 
     53 #endif /* frontend_FoldConstants_h */