| Index: src/ast/ast.h
|
| diff --git a/src/ast/ast.h b/src/ast/ast.h
|
| index d75294ecc4ce8023258808d4d2ffebb9f6260c79..18aa597847a58acb98c99a8de11a03e9c9fb6659 100644
|
| --- a/src/ast/ast.h
|
| +++ b/src/ast/ast.h
|
| @@ -2886,7 +2886,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++) {
|
| @@ -2913,12 +2913,12 @@ 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: \
|
| +#define GENERATE_VISIT_CASE(NodeType) \
|
| + case AstNode::k##NodeType: \
|
| return Visit##NodeType(static_cast<NodeType*>(node));
|
|
|
| #define GENERATE_AST_VISITOR_SWITCH() \
|
| @@ -2928,13 +2928,8 @@ class AstVisitor BASE_EMBEDDED {
|
| UNREACHABLE(); \
|
| }
|
|
|
| -#define DEFINE_AST_VISITOR_SUBCLASS_MEMBERS() \
|
| +#define DEFINE_AST_VISITOR_STACKOVERFLOW_MEMBERS() \
|
| public: \
|
| - void Visit(AstNode* node) { \
|
| - if (CheckStackOverflow()) return; \
|
| - GENERATE_AST_VISITOR_SWITCH() \
|
| - } \
|
| - \
|
| void SetStackOverflow() { stack_overflow_ = true; } \
|
| void ClearStackOverflow() { stack_overflow_ = false; } \
|
| bool HasStackOverflow() const { return stack_overflow_; } \
|
| @@ -2962,11 +2957,21 @@ class AstVisitor BASE_EMBEDDED {
|
| uintptr_t stack_limit_; \
|
| bool stack_overflow_
|
|
|
| -#define DEFINE_AST_VISITOR_MEMBERS_WITHOUT_STACKOVERFLOW() \
|
| - public: \
|
| - void Visit(AstNode* node) { GENERATE_AST_VISITOR_SWITCH() } \
|
| - \
|
| - private:
|
| +#define DEFINE_AST_VISITOR_DISPATCH() \
|
| + public: \
|
| + void Visit(AstNode* node) { \
|
| + if (CheckStackOverflow()) return; \
|
| + GENERATE_AST_VISITOR_SWITCH() \
|
| + }
|
| +
|
| +#define DEFINE_AST_VISITOR_MEMBERS_WITHOUT_STACKOVERFLOW() \
|
| + public: \
|
| + void Visit(AstNode* node) { GENERATE_AST_VISITOR_SWITCH() }
|
| +
|
| +#define DEFINE_AST_VISITOR_SUBCLASS_MEMBERS() \
|
| + public: \
|
| + DEFINE_AST_VISITOR_DISPATCH() \
|
| + DEFINE_AST_VISITOR_STACKOVERFLOW_MEMBERS()
|
|
|
| #define DEFINE_AST_REWRITER_SUBCLASS_MEMBERS() \
|
| public: \
|
| @@ -2996,6 +3001,7 @@ class AstVisitor BASE_EMBEDDED {
|
| \
|
| protected: \
|
| AstNode* replacement_
|
| +
|
| // Generic macro for rewriting things; `GET` is the expression to be
|
| // rewritten; `SET` is a command that should do the rewriting, i.e.
|
| // something sensible with the variable called `replacement`.
|
| @@ -3032,38 +3038,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 {
|
|
|