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

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

Issue 2089733002: [parser] only parse async arrow function when necessary (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 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 | « no previous file | test/cctest/test-parsing.cc » ('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 2cf04fa568a73fadcdc0cef3c4c8a1f8a105140e..dc08f5c5803923dd9ee29bf92228af10d5f0efe3 100644
--- a/src/parsing/parser-base.h
+++ b/src/parsing/parser-base.h
@@ -669,13 +669,13 @@ class ParserBase : public Traits {
Expect(Token::SEMICOLON, ok);
}
- bool peek_any_identifier() {
- Token::Value next = peek();
- return next == Token::IDENTIFIER || next == Token::ENUM ||
- next == Token::AWAIT || next == Token::ASYNC ||
- next == Token::FUTURE_STRICT_RESERVED_WORD || next == Token::LET ||
- next == Token::STATIC || next == Token::YIELD;
+ bool is_any_identifier(Token::Value token) {
+ return token == Token::IDENTIFIER || token == Token::ENUM ||
+ token == Token::AWAIT || token == Token::ASYNC ||
+ token == Token::FUTURE_STRICT_RESERVED_WORD || token == Token::LET ||
+ token == Token::STATIC || token == Token::YIELD;
}
+ bool peek_any_identifier() { return is_any_identifier(peek()); }
bool CheckContextualKeyword(Vector<const char> keyword) {
if (PeekContextualKeyword(keyword)) {
@@ -888,6 +888,10 @@ class ParserBase : public Traits {
}
}
+ bool IsValidArrowFormalParametersStart(Token::Value token) {
+ return is_any_identifier(token) || token == Token::LPAREN;
+ }
+
void ValidateArrowFormalParameters(const ExpressionClassifier* classifier,
ExpressionT expr,
bool parenthesized_formals, bool is_async,
@@ -2231,7 +2235,8 @@ ParserBase<Traits>::ParseAssignmentExpression(bool accept_IN,
classifier->duplicate_finder());
bool is_async = allow_harmony_async_await() && peek() == Token::ASYNC &&
- !scanner()->HasAnyLineTerminatorAfterNext();
+ !scanner()->HasAnyLineTerminatorAfterNext() &&
+ IsValidArrowFormalParametersStart(PeekAhead());
bool parenthesized_formals = peek() == Token::LPAREN;
if (!is_async && !parenthesized_formals) {
« no previous file with comments | « no previous file | test/cctest/test-parsing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698