From: svenpanne@chromium.org Date: Mon, 30 Apr 2012 13:04:08 +0000 (+0000) Subject: Fixed preparser for try statement. Tiny cleanup. X-Git-Tag: upstream/4.7.83~16777 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6aceff1fa9985c44fc4afb81fb5dc7de2877d18a;p=platform%2Fupstream%2Fv8.git 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 --- diff --git a/src/preparser.cc b/src/preparser.cc index 20d3b9c..0c17eec 100644 --- a/src/preparser.cc +++ b/src/preparser.cc @@ -581,9 +581,8 @@ PreParser::Statement PreParser::ParseWithStatement(bool* ok) { ParseExpression(true, CHECK_OK); Expect(i::Token::RPAREN, CHECK_OK); - scope_->EnterWith(); + Scope::InsideWith iw(scope_); ParseStatement(CHECK_OK); - scope_->LeaveWith(); return Statement::Default(); } @@ -749,10 +748,9 @@ PreParser::Statement PreParser::ParseTryStatement(bool* ok) { return Statement::Default(); } Expect(i::Token::RPAREN, CHECK_OK); - scope_->EnterWith(); - ParseBlock(ok); - scope_->LeaveWith(); - if (!*ok) Statement::Default(); + { Scope::InsideWith iw(scope_); + ParseBlock(CHECK_OK); + } catch_or_finally_seen = true; } if (peek() == i::Token::FINALLY) { diff --git a/src/preparser.h b/src/preparser.h index f3a4347..13261f7 100644 --- a/src/preparser.h +++ b/src/preparser.h @@ -470,8 +470,19 @@ class PreParser { void set_language_mode(i::LanguageMode 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: Scope** const variable_;