Index: src/ast.h |
diff --git a/src/ast.h b/src/ast.h |
index 8febfee05a2de5ee90e11f9a7f02bda7bce573aa..9a06e8221ec72cbc778bdfcdbcf5ccbad8b5c83b 100644 |
--- a/src/ast.h |
+++ b/src/ast.h |
@@ -259,6 +259,7 @@ class Statement: public AstNode { |
Statement() : statement_pos_(RelocInfo::kNoPosition) {} |
bool IsEmpty() { return AsEmptyStatement() != NULL; } |
+ virtual bool IsJump() const { return false; } |
void set_statement_pos(int statement_pos) { statement_pos_ = statement_pos; } |
int statement_pos() const { return statement_pos_; } |
@@ -459,6 +460,11 @@ class Block: public BreakableStatement { |
ZoneList<Statement*>* statements() { return &statements_; } |
bool is_initializer_block() const { return is_initializer_block_; } |
+ virtual bool IsJump() const { |
+ return !statements_.is_empty() && statements_.last()->IsJump() |
+ && labels() == NULL; // Good enough as an approximation... |
+ } |
+ |
Scope* scope() const { return scope_; } |
void set_scope(Scope* scope) { scope_ = scope; } |
@@ -1009,6 +1015,7 @@ class ExpressionStatement: public Statement { |
void set_expression(Expression* e) { expression_ = e; } |
Expression* expression() const { return expression_; } |
+ virtual bool IsJump() const { return expression_->IsThrow(); } |
protected: |
explicit ExpressionStatement(Expression* expression) |
@@ -1019,7 +1026,16 @@ class ExpressionStatement: public Statement { |
}; |
-class ContinueStatement: public Statement { |
+class JumpStatement: public Statement { |
+ public: |
+ virtual bool IsJump() const { return true; } |
+ |
+ protected: |
+ JumpStatement() {} |
+}; |
+ |
+ |
+class ContinueStatement: public JumpStatement { |
public: |
DECLARE_NODE_TYPE(ContinueStatement) |
@@ -1034,7 +1050,7 @@ class ContinueStatement: public Statement { |
}; |
-class BreakStatement: public Statement { |
+class BreakStatement: public JumpStatement { |
public: |
DECLARE_NODE_TYPE(BreakStatement) |
@@ -1049,7 +1065,7 @@ class BreakStatement: public Statement { |
}; |
-class ReturnStatement: public Statement { |
+class ReturnStatement: public JumpStatement { |
public: |
DECLARE_NODE_TYPE(ReturnStatement) |
@@ -1168,6 +1184,11 @@ class IfStatement: public Statement { |
Statement* then_statement() const { return then_statement_; } |
Statement* else_statement() const { return else_statement_; } |
+ virtual bool IsJump() const { |
+ return HasThenStatement() && then_statement()->IsJump() |
+ && HasElseStatement() && else_statement()->IsJump(); |
+ } |
+ |
BailoutId IfId() const { return if_id_; } |
BailoutId ThenId() const { return then_id_; } |
BailoutId ElseId() const { return else_id_; } |