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

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

Issue 2411793003: Preparse lazy function parameters (Closed)
Patch Set: rebased Created 4 years, 2 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
« 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 25c5230d44fa70cb35e961604c5e0a1c630e2460..df098b5adb7a8bba13c7cae5b6d4636c8f1a47dc 100644
--- a/src/parsing/parser-base.h
+++ b/src/parsing/parser-base.h
@@ -3955,12 +3955,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()->SkipLazyFunction(
+ 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(
@@ -3984,6 +3994,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