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

Unified Diff: src/parsing/parser.cc

Issue 2169833002: [parser] Refactor AstTraversalVisitor (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase Created 4 years, 5 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
« no previous file with comments | « src/parsing/parser.h ('k') | src/v8.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/parser.cc
diff --git a/src/parsing/parser.cc b/src/parsing/parser.cc
index 14322778d686ed049f85b7dde39d9884a9dec092..502551843363c9ed4b21684e611c7f0554d07919 100644
--- a/src/parsing/parser.cc
+++ b/src/parsing/parser.cc
@@ -7,8 +7,8 @@
#include "src/api.h"
#include "src/ast/ast.h"
#include "src/ast/ast-expression-rewriter.h"
-#include "src/ast/ast-expression-visitor.h"
#include "src/ast/ast-literal-reindexer.h"
+#include "src/ast/ast-traversal-visitor.h"
#include "src/ast/scopeinfo.h"
#include "src/bailout-reason.h"
#include "src/base/platform/platform.h"
@@ -4631,28 +4631,31 @@ Statement* Parser::BuildAssertIsCoercible(Variable* var) {
}
-class InitializerRewriter : public AstExpressionVisitor {
+class InitializerRewriter final
+ : public AstTraversalVisitor<InitializerRewriter> {
public:
InitializerRewriter(uintptr_t stack_limit, Expression* root, Parser* parser,
Scope* scope)
- : AstExpressionVisitor(stack_limit, root),
+ : AstTraversalVisitor(stack_limit, root),
parser_(parser),
scope_(scope) {}
private:
- void VisitExpression(Expression* expr) override {
- RewritableExpression* to_rewrite = expr->AsRewritableExpression();
- if (to_rewrite == nullptr || to_rewrite->is_rewritten()) return;
+ // This is required so that the overriden Visit* methods can be
+ // called by the base class (template).
+ friend class AstTraversalVisitor<InitializerRewriter>;
+ // Just rewrite destructuring assignments wrapped in RewritableExpressions.
+ void VisitRewritableExpression(RewritableExpression* to_rewrite) {
+ if (to_rewrite->is_rewritten()) return;
Parser::PatternRewriter::RewriteDestructuringAssignment(parser_, to_rewrite,
scope_);
}
// Code in function literals does not need to be eagerly rewritten, it will be
// rewritten when scheduled.
- void VisitFunctionLiteral(FunctionLiteral* expr) override {}
+ void VisitFunctionLiteral(FunctionLiteral* expr) {}
- private:
Parser* parser_;
Scope* scope_;
};
« no previous file with comments | « src/parsing/parser.h ('k') | src/v8.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698