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/ast/ast.h

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 | « BUILD.gn ('k') | src/ast/ast.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ast/ast.h
diff --git a/src/ast/ast.h b/src/ast/ast.h
index a238eacd11a9599ef48836e24bed7e6285245cb6..982795e5eecf6793972d48f6b28000c8bd1ea44d 100644
--- a/src/ast/ast.h
+++ b/src/ast/ast.h
@@ -2893,7 +2893,7 @@ class EmptyParentheses final : public Expression {
template <class Subclass>
class AstVisitor BASE_EMBEDDED {
public:
- void Visit(AstNode* node) { This()->Visit(node); }
+ void Visit(AstNode* node) { impl()->Visit(node); }
void VisitDeclarations(ZoneList<Declaration*>* declarations) {
for (int i = 0; i < declarations->length(); i++) {
@@ -2920,13 +2920,13 @@ class AstVisitor BASE_EMBEDDED {
}
}
- private:
- Subclass* This() { return static_cast<Subclass*>(this); }
+ protected:
+ Subclass* impl() { return static_cast<Subclass*>(this); }
};
-#define GENERATE_VISIT_CASE(NodeType) \
- case AstNode::k##NodeType: \
- return Visit##NodeType(static_cast<NodeType*>(node));
+#define GENERATE_VISIT_CASE(NodeType) \
+ case AstNode::k##NodeType: \
+ return this->impl()->Visit##NodeType(static_cast<NodeType*>(node));
#define GENERATE_AST_VISITOR_SWITCH() \
switch (node->node_type()) { \
@@ -3039,38 +3039,6 @@ class AstVisitor BASE_EMBEDDED {
// ----------------------------------------------------------------------------
-// Traversing visitor
-// - fully traverses the entire AST.
-
-// This AstVistor is not final, and provides the AstVisitor methods as virtual
-// methods so they can be specialized by subclasses.
-class AstTraversalVisitor : public AstVisitor<AstTraversalVisitor> {
- public:
- explicit AstTraversalVisitor(Isolate* isolate);
- explicit AstTraversalVisitor(uintptr_t stack_limit);
- virtual ~AstTraversalVisitor() {}
-
- // Iteration left-to-right.
- void VisitDeclarations(ZoneList<Declaration*>* declarations);
- void VisitStatements(ZoneList<Statement*>* statements);
-
-// Individual nodes
-#define DECLARE_VISIT(type) virtual void Visit##type(type* node);
- AST_NODE_LIST(DECLARE_VISIT)
-#undef DECLARE_VISIT
-
- protected:
- int depth() { return depth_; }
-
- private:
- DEFINE_AST_VISITOR_SUBCLASS_MEMBERS();
-
- int depth_;
-
- DISALLOW_COPY_AND_ASSIGN(AstTraversalVisitor);
-};
-
-// ----------------------------------------------------------------------------
// AstNode factory
class AstNodeFactory final BASE_EMBEDDED {
« no previous file with comments | « BUILD.gn ('k') | src/ast/ast.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698