Commit eb488c1f authored by jgruber's avatar jgruber Committed by Commit bot

Refactor duplicate logic in Ast{Traversal,Expression}Visitor

Add stack overflow checks to AstTraversalVisitor, and let
AstExpressionVisitor reuse traversal logic from AstTraversalVisitor.

R=yangguo@chromium.org
BUG=

Review-Url: https://codereview.chromium.org/2004363002
Cr-Commit-Position: refs/heads/master@{#36500}
parent 53d4594b
This diff is collapsed.
......@@ -17,7 +17,7 @@ namespace internal {
// A Visitor over a CompilationInfo's AST that invokes
// VisitExpression on each expression node.
class AstExpressionVisitor : public AstVisitor {
class AstExpressionVisitor : public AstTraversalVisitor {
public:
AstExpressionVisitor(Isolate* isolate, Expression* root);
AstExpressionVisitor(uintptr_t stack_limit, Expression* root);
......@@ -25,20 +25,13 @@ class AstExpressionVisitor : public AstVisitor {
protected:
virtual void VisitExpression(Expression* expression) = 0;
int depth() { return depth_; }
void VisitDeclarations(ZoneList<Declaration*>* d) override;
void VisitStatements(ZoneList<Statement*>* s) override;
private:
DEFINE_AST_VISITOR_SUBCLASS_MEMBERS();
#define DECLARE_VISIT(type) void Visit##type(type* node) override;
AST_NODE_LIST(DECLARE_VISIT)
EXPRESSION_NODE_LIST(DECLARE_VISIT)
#undef DECLARE_VISIT
Expression* root_;
int depth_;
DISALLOW_COPY_AND_ASSIGN(AstExpressionVisitor);
};
......
This diff is collapsed.
......@@ -3056,20 +3056,26 @@ class AstVisitor BASE_EMBEDDED {
class AstTraversalVisitor : public AstVisitor {
public:
explicit AstTraversalVisitor(Isolate* isolate);
explicit AstTraversalVisitor(uintptr_t stack_limit);
virtual ~AstTraversalVisitor() {}
// Iteration left-to-right.
void VisitDeclarations(ZoneList<Declaration*>* declarations) override;
void VisitStatements(ZoneList<Statement*>* statements) override;
void VisitExpressions(ZoneList<Expression*>* expressions) override;
// Individual nodes
#define DECLARE_VISIT(type) void Visit##type(type* node) override;
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);
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment