rewriter.h 1.06 KB
Newer Older
1
// Copyright 2011 the V8 project authors. All rights reserved.
2 3
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
4 5 6 7

#ifndef V8_REWRITER_H_
#define V8_REWRITER_H_

8 9
namespace v8 {
namespace internal {
10

11 12
class AstValueFactory;
class DoExpression;
13
class ParseInfo;
14
class Parser;
15 16 17

class Rewriter {
 public:
18 19 20 21 22 23
  // Rewrite top-level code (ECMA 262 "programs") so as to conservatively
  // include an assignment of the value of the last statement in the code to
  // a compiler-generated temporary variable wherever needed.
  //
  // Assumes code has been parsed and scopes have been analyzed.  Mutates the
  // AST, so the AST should not continue to be used in the case of failure.
24
  static bool Rewrite(ParseInfo* info);
25 26 27 28 29

  // Rewrite a list of statements, using the same rules as a top-level program,
  // to  ensure identical behaviour of completion result.
  static bool Rewrite(Parser* parser, DoExpression* expr,
                      AstValueFactory* factory);
30 31 32
};


33 34
}  // namespace internal
}  // namespace v8
35 36

#endif  // V8_REWRITER_H_