Reviewers: Jakob,
Message:
Landing...
http://codereview.chromium.org/10270007/diff/1/src/preparser.h
File src/preparser.h (right):
http://codereview.chromium.org/10270007/diff/1/src/preparser.h#newcode474
src/preparser.h:474: class WithinWith {
On 2012/04/30 12:52:32, Jakob wrote:
nit: not sure I like the name... how about InsideWith?
Done.
http://codereview.chromium.org/10270007/diff/1/src/preparser.h#newcode476
src/preparser.h:476: explicit WithinWith(Scope* scope): scope_(scope) {
On 2012/04/30 12:52:32, Jakob wrote:
nit: space before ':'
Done.
Description:
Fixed preparser for try statement. Tiny cleanup.
BUG=v8:2109
[email protected]
Please review this at http://codereview.chromium.org/10270007/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/preparser.h
M src/preparser.cc
Index: src/preparser.cc
diff --git a/src/preparser.cc b/src/preparser.cc
index
20d3b9c59c40916ea5eabad11fc8dcd8bf5fae65..0c17eecd6a432a6d24efe93247acabcdbb6d13ff
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) {
Index: src/preparser.h
diff --git a/src/preparser.h b/src/preparser.h
index
f3a43475dfe96bb3d3fd78abfecbf42862883b3c..13261f7a5b945f6b278a5ac9d450557bdce3e168
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_;
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev