Line data Source code
1 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 : * vim: set ts=8 sts=4 et sw=4 tw=99:
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/SyntaxParseHandler.h"
11 :
12 : namespace js {
13 : namespace frontend {
14 :
15 : class FullParseHandler;
16 : template <class ParseHandler, typename CharT> class Parser;
17 :
18 : // Perform constant folding on the given AST. For example, the program
19 : // `print(2 + 2)` would become `print(4)`.
20 : //
21 : // pnp is the address of a pointer variable that points to the root node of the
22 : // AST. On success, *pnp points to the root node of the new tree, which may be
23 : // the same node (unchanged or modified in place) or a new node.
24 : //
25 : // Usage:
26 : // pn = parser->statement();
27 : // if (!pn)
28 : // return false;
29 : // if (!FoldConstants(cx, &pn, parser))
30 : // return false;
31 : template<typename CharT>
32 : MOZ_MUST_USE bool
33 : FoldConstants(JSContext* cx, ParseNode** pnp, Parser<FullParseHandler, CharT>* parser);
34 :
35 : template<typename CharT>
36 : inline MOZ_MUST_USE bool
37 0 : FoldConstants(JSContext* cx, typename SyntaxParseHandler::Node* pnp,
38 : Parser<SyntaxParseHandler, CharT>* parser)
39 : {
40 0 : return true;
41 : }
42 :
43 : } /* namespace frontend */
44 : } /* namespace js */
45 :
46 : #endif /* frontend_FoldConstants_h */
|