Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Unified Diff: src/ast/ast-expression-rewriter.h

Issue 1565153002: Add a generic mechanism for expression rewriting (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rewrite according to comments and small fix Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/ast/ast-expression-rewriter.h
diff --git a/src/ast/ast-expression-rewriter.h b/src/ast/ast-expression-rewriter.h
new file mode 100644
index 0000000000000000000000000000000000000000..916842ab20ee69462e1a76f2b76c63bea3e1a267
--- /dev/null
+++ b/src/ast/ast-expression-rewriter.h
@@ -0,0 +1,54 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef V8_AST_AST_EXPRESSION_REWRITER_H_
+#define V8_AST_AST_EXPRESSION_REWRITER_H_
+
+#include "src/allocation.h"
+#include "src/ast/ast.h"
+#include "src/ast/scopes.h"
+#include "src/effects.h"
+#include "src/type-info.h"
+#include "src/types.h"
+#include "src/zone.h"
+
+namespace v8 {
+namespace internal {
+
+// A rewriting Visitor over a CompilationInfo's AST that invokes
+// VisitExpression on each expression node.
+
+class AstExpressionRewriter : public AstVisitor {
+ public:
+ explicit AstExpressionRewriter(Isolate* isolate) : AstVisitor() {
+ InitializeAstRewriter(isolate);
+ }
+ explicit AstExpressionRewriter(uintptr_t stack_limit) : AstVisitor() {
+ InitializeAstRewriter(stack_limit);
+ }
+ ~AstExpressionRewriter() override {}
+
+ void VisitDeclarations(ZoneList<Declaration*>* declarations) override;
+ void VisitStatements(ZoneList<Statement*>* statements) override;
+ void VisitExpressions(ZoneList<Expression*>* expressions) override;
+
+ virtual void VisitObjectLiteralProperty(ObjectLiteralProperty* property);
+
+ protected:
+ virtual bool RewriteExpression(Expression* expr) = 0;
+
+ private:
+ DEFINE_AST_REWRITER_SUBCLASS_MEMBERS();
+
+#define DECLARE_VISIT(type) void Visit##type(type* node) override;
+ AST_NODE_LIST(DECLARE_VISIT)
+#undef DECLARE_VISIT
+
+ DISALLOW_COPY_AND_ASSIGN(AstExpressionRewriter);
+};
+
+} // namespace internal
+} // namespace v8
+
+#endif // V8_AST_AST_EXPRESSION_REWRITER_H_
« src/ast/ast.h ('K') | « src/ast/ast.h ('k') | src/ast/ast-expression-rewriter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698