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

Unified Diff: src/ast.h

Issue 1567007: Move the AstVisitor stack check from Accept to Visit. (Closed)
Patch Set: Created 10 years, 9 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 | « no previous file | src/ast.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ast.h
diff --git a/src/ast.h b/src/ast.h
index 252c8f8c82f7d0a4fa789c0d0f9bd9c4bc905cfb..c6ff7011bdcbce732deded60a2995b54d8a99fc5 100644
--- a/src/ast.h
+++ b/src/ast.h
@@ -2060,29 +2060,23 @@ class AstVisitor BASE_EMBEDDED {
AstVisitor() : stack_overflow_(false) { }
virtual ~AstVisitor() { }
- // Dispatch
- void Visit(AstNode* node) { node->Accept(this); }
+ // Stack overflow check and dynamic dispatch.
+ void Visit(AstNode* node) { if (!CheckStackOverflow()) node->Accept(this); }
- // Iteration
+ // Iteration left-to-right.
virtual void VisitDeclarations(ZoneList<Declaration*>* declarations);
virtual void VisitStatements(ZoneList<Statement*>* statements);
virtual void VisitExpressions(ZoneList<Expression*>* expressions);
// Stack overflow tracking support.
bool HasStackOverflow() const { return stack_overflow_; }
- bool CheckStackOverflow() {
- if (stack_overflow_) return true;
- StackLimitCheck check;
- if (!check.HasOverflowed()) return false;
- return (stack_overflow_ = true);
- }
+ bool CheckStackOverflow();
// If a stack-overflow exception is encountered when visiting a
// node, calling SetStackOverflow will make sure that the visitor
// bails out without visiting more nodes.
void SetStackOverflow() { stack_overflow_ = true; }
-
// Individual nodes
#define DEF_VISIT(type) \
virtual void Visit##type(type* node) = 0;
« no previous file with comments | « no previous file | src/ast.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698