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

Unified Diff: src/preparser.cc

Issue 1104223002: [es6] implement optional parameters via desugaring (with scoping) (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Finalize function body scope if it's not needed Created 5 years, 8 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
Index: src/preparser.cc
diff --git a/src/preparser.cc b/src/preparser.cc
index 95339dac33ca08b6b87bdf4bfed467c294a93280..02b7b18a89c784a800085becc829ec4d687d5ae6 100644
--- a/src/preparser.cc
+++ b/src/preparser.cc
@@ -108,13 +108,19 @@ PreParser::PreParseResult PreParser::PreParseLazyFunction(
&top_factory);
scope_->SetLanguageMode(language_mode);
Scope* function_scope = NewScope(scope_, FUNCTION_SCOPE);
+ Scope* function_body = NewScope(function_scope, FUNCTION_BODY_SCOPE);
+ DCHECK_EQ(function_scope->function_body(), function_body);
PreParserFactory function_factory(NULL);
FunctionState function_state(&function_state_, &scope_, function_scope, kind,
&function_factory);
DCHECK_EQ(Token::LBRACE, scanner()->current_token());
bool ok = true;
int start_position = peek_position();
- ParseLazyFunctionLiteralBody(&ok);
+ {
+ DCHECK(scope_->is_function_scope());
+ BlockState(&scope_, function_body);
+ ParseLazyFunctionLiteralBody(&ok);
+ }
if (stack_overflow()) return kPreParseStackOverflow;
if (!ok) {
ReportUnexpectedToken(scanner()->current_token());
@@ -996,6 +1002,8 @@ PreParser::Expression PreParser::ParseFunctionLiteral(
// Parse function body.
bool outer_is_script_scope = scope_->is_script_scope();
Scope* function_scope = NewScope(scope_, FUNCTION_SCOPE);
+ Scope* function_body = NewScope(function_scope, FUNCTION_BODY_SCOPE);
arv (Not doing code reviews) 2015/05/01 18:31:33 I wonder if it is not better to change the order o
caitp (gmail) 2015/05/01 19:03:35 Is what you're saying "make the parameter scope a
+ DCHECK_EQ(function_scope->function_body(), function_body);
PreParserFactory factory(NULL);
FunctionState function_state(&function_state_, &scope_, function_scope, kind,
&factory);
@@ -1008,8 +1016,12 @@ PreParser::Expression PreParser::ParseFunctionLiteral(
int num_parameters;
{
DuplicateFinder duplicate_finder(scanner()->unicode_cache());
- num_parameters = ParseFormalParameterList(&duplicate_finder, &error_locs,
- &is_rest, CHECK_OK);
+ PreParserExpressionList initializers = NewExpressionList(0, zone());
+ bool has_initializers = false;
+
+ num_parameters =
+ ParseFormalParameterList(&duplicate_finder, &error_locs, initializers,
+ &has_initializers, &is_rest, CHECK_OK);
}
Expect(Token::RPAREN, CHECK_OK);
int formals_end_position = scanner()->location().end_pos;
@@ -1024,10 +1036,13 @@ PreParser::Expression PreParser::ParseFunctionLiteral(
parenthesized_function_ = false;
Expect(Token::LBRACE, CHECK_OK);
- if (is_lazily_parsed) {
- ParseLazyFunctionLiteralBody(CHECK_OK);
- } else {
- ParseStatementList(Token::RBRACE, CHECK_OK);
+ {
+ BlockState function_body_state(&scope_, function_body);
+ if (is_lazily_parsed) {
+ ParseLazyFunctionLiteralBody(CHECK_OK);
+ } else {
+ ParseStatementList(Token::RBRACE, CHECK_OK);
+ }
}
Expect(Token::RBRACE, CHECK_OK);
« src/parser.cc ('K') | « src/preparser.h ('k') | src/runtime/runtime-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698