1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/frontend/FoldConstants.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,41 @@ 1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- 1.5 + * vim: set ts=8 sts=4 et sw=4 tw=99: 1.6 + * This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#ifndef frontend_FoldConstants_h 1.11 +#define frontend_FoldConstants_h 1.12 + 1.13 +#include "frontend/SyntaxParseHandler.h" 1.14 + 1.15 +namespace js { 1.16 +namespace frontend { 1.17 + 1.18 +// Perform constant folding on the given AST. For example, the program 1.19 +// `print(2 + 2)` would become `print(4)`. 1.20 +// 1.21 +// pnp is the address of a pointer variable that points to the root node of the 1.22 +// AST. On success, *pnp points to the root node of the new tree, which may be 1.23 +// the same node (unchanged or modified in place) or a new node. 1.24 +// 1.25 +// Usage: 1.26 +// pn = parser->statement(); 1.27 +// if (!pn) 1.28 +// return false; 1.29 +// if (!FoldConstants(cx, &pn, parser)) 1.30 +// return false; 1.31 +bool 1.32 +FoldConstants(ExclusiveContext *cx, ParseNode **pnp, Parser<FullParseHandler> *parser); 1.33 + 1.34 +inline bool 1.35 +FoldConstants(ExclusiveContext *cx, SyntaxParseHandler::Node *pnp, 1.36 + Parser<SyntaxParseHandler> *parser) 1.37 +{ 1.38 + return true; 1.39 +} 1.40 + 1.41 +} /* namespace frontend */ 1.42 +} /* namespace js */ 1.43 + 1.44 +#endif /* frontend_FoldConstants_h */