blob: 477644a7567f92a09a74d67677d62059331dcfbf [file] [log] [blame]
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001// Copyright 2011 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef V8_PARSING_REWRITER_H_
6#define V8_PARSING_REWRITER_H_
7
8namespace v8 {
9namespace internal {
10
11class AstValueFactory;
12class DoExpression;
13class ParseInfo;
14class Parser;
15
16class Rewriter {
17 public:
18 // Rewrite top-level code (ECMA 262 "programs") so as to conservatively
19 // include an assignment of the value of the last statement in the code to
20 // a compiler-generated temporary variable wherever needed.
21 //
22 // Assumes code has been parsed and scopes have been analyzed. Mutates the
23 // AST, so the AST should not continue to be used in the case of failure.
24 static bool Rewrite(ParseInfo* info);
25
26 // Rewrite a list of statements, using the same rules as a top-level program,
27 // to ensure identical behaviour of completion result.
28 static bool Rewrite(Parser* parser, DoExpression* expr,
29 AstValueFactory* factory);
30};
31
32
33} // namespace internal
34} // namespace v8
35
36#endif // V8_PARSING_REWRITER_H_