Fixed preparser for try statement. Tiny cleanup.

BUG=v8:2109
TBR=jkummerow@chromium.org

Review URL: https://chromiumcodereview.appspot.com/10270007

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@11468 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent a1fe6f3b
...@@ -581,9 +581,8 @@ PreParser::Statement PreParser::ParseWithStatement(bool* ok) { ...@@ -581,9 +581,8 @@ PreParser::Statement PreParser::ParseWithStatement(bool* ok) {
ParseExpression(true, CHECK_OK); ParseExpression(true, CHECK_OK);
Expect(i::Token::RPAREN, CHECK_OK); Expect(i::Token::RPAREN, CHECK_OK);
scope_->EnterWith(); Scope::InsideWith iw(scope_);
ParseStatement(CHECK_OK); ParseStatement(CHECK_OK);
scope_->LeaveWith();
return Statement::Default(); return Statement::Default();
} }
...@@ -749,10 +748,9 @@ PreParser::Statement PreParser::ParseTryStatement(bool* ok) { ...@@ -749,10 +748,9 @@ PreParser::Statement PreParser::ParseTryStatement(bool* ok) {
return Statement::Default(); return Statement::Default();
} }
Expect(i::Token::RPAREN, CHECK_OK); Expect(i::Token::RPAREN, CHECK_OK);
scope_->EnterWith(); { Scope::InsideWith iw(scope_);
ParseBlock(ok); ParseBlock(CHECK_OK);
scope_->LeaveWith(); }
if (!*ok) Statement::Default();
catch_or_finally_seen = true; catch_or_finally_seen = true;
} }
if (peek() == i::Token::FINALLY) { if (peek() == i::Token::FINALLY) {
......
...@@ -470,8 +470,19 @@ class PreParser { ...@@ -470,8 +470,19 @@ class PreParser {
void set_language_mode(i::LanguageMode language_mode) { void set_language_mode(i::LanguageMode language_mode) {
language_mode_ = language_mode; language_mode_ = language_mode;
} }
void EnterWith() { with_nesting_count_++; }
void LeaveWith() { with_nesting_count_--; } class InsideWith {
public:
explicit InsideWith(Scope* scope) : scope_(scope) {
scope->with_nesting_count_++;
}
~InsideWith() { scope_->with_nesting_count_--; }
private:
Scope* scope_;
DISALLOW_COPY_AND_ASSIGN(InsideWith);
};
private: private:
Scope** const variable_; Scope** const variable_;
......
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