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

Unified Diff: src/parsing/parser-base.h

Issue 2472063002: Preparse lazy function parameters (Closed)
Patch Set: IsArrowFunction Created 4 years, 1 month 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
« no previous file with comments | « src/parsing/parser.cc ('k') | src/parsing/preparse-data.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/parser-base.h
diff --git a/src/parsing/parser-base.h b/src/parsing/parser-base.h
index bd8a8b4882cc20a99236602377d1070b3dbbf733..4f5929c50388fa346407a9e208de5c937a3c67ac 100644
--- a/src/parsing/parser-base.h
+++ b/src/parsing/parser-base.h
@@ -3953,12 +3953,22 @@ ParserBase<Impl>::ParseArrowFunctionLiteral(
if (peek() == Token::LBRACE) {
// Multiple statement body
- Consume(Token::LBRACE);
DCHECK_EQ(scope(), formal_parameters.scope);
if (is_lazy_top_level_function) {
+ // FIXME(marja): Arrow function parameters will be parsed even if the
+ // body is preparsed; move relevant parts of parameter handling to
+ // simulate consistent parameter handling.
Scanner::BookmarkScope bookmark(scanner());
bookmark.Set();
- LazyParsingResult result = impl()->SkipLazyFunctionBody(
+ // For arrow functions, we don't need to retrieve data about function
+ // parameters.
+ int dummy_num_parameters = -1;
+ int dummy_function_length = -1;
+ bool dummy_has_duplicate_parameters = false;
+ DCHECK((kind & FunctionKind::kArrowFunction) != 0);
+ LazyParsingResult result = impl()->SkipFunction(
+ kind, formal_parameters.scope, &dummy_num_parameters,
+ &dummy_function_length, &dummy_has_duplicate_parameters,
&materialized_literal_count, &expected_property_count, false, true,
CHECK_OK);
formal_parameters.scope->ResetAfterPreparsing(
@@ -3982,6 +3992,7 @@ ParserBase<Impl>::ParseArrowFunctionLiteral(
}
}
if (!is_lazy_top_level_function) {
+ Consume(Token::LBRACE);
body = impl()->ParseEagerFunctionBody(
impl()->EmptyIdentifier(), kNoSourcePosition, formal_parameters,
kind, FunctionLiteral::kAnonymousExpression, CHECK_OK);
« no previous file with comments | « src/parsing/parser.cc ('k') | src/parsing/preparse-data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698