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

Issue 383983002: Implement handling of arrow functions in the parser (Closed)

Created:
6 years, 5 months ago by aperez
Modified:
6 years, 5 months ago
CC:
v8-dev
Project:
v8
Visibility:
Public.

Description

Implement handling of arrow functions in the parser Arrow functions are parsed from ParseAssignmentExpression(). Handling the parameter list is done by letting ParseConditionalExpression() parse a comma separated list of identifiers, and it returns a tree of BinaryOperation nodes with VariableProxy leaves, or a single VariableProxy if there is only one parameter. When the arrow token "=>" is found, the VariableProxy nodes are passed to ParseArrowFunctionLiteral(), which will then skip parsing the paramaeter list. This avoids having to rewind when the arrow is found and restart parsing the parameter list. Note that the empty parameter list "()" is handled directly in ParsePrimaryExpression(): after is has consumed the opening parenthesis, if a closing parenthesis follows, then the only valid input is an arrow function. In this case, ParsePrimaryExpression() directly calls ParseArrowFunctionLiteral(), to avoid needing to return a sentinel value to signal the empty parameter list. Because it will consume the body of the arrow function, ParseAssignmentExpression() will not see the arrow "=>" token as next, and return the already-parser expression. The implementation is done in ParserBase, so it was needed to do some additions to ParserBase, ParserTraits and PreParserTraits. Some of the glue code can be removed later on when more more functionality is moved to ParserBase. Additionally, this adds a runtime flag "harmony_arrow_functions" (disabled by default); enabling "harmony" will enable it as well. BUG=v8:2700 LOG=N R=marja@chromium.org Committed: https://code.google.com/p/v8/source/detail?r=22366

Patch Set 1 #

Patch Set 2 : Declares params as AST is traversed, avoids leaks reported by ASAN #

Patch Set 3 : Fix int/unsigned comparison warning #

Unified diffs Side-by-side diffs Delta from patch set Stats (+876 lines, -182 lines) Patch
M src/ast.h View 3 chunks +7 lines, -0 lines 0 comments Download
M src/flag-definitions.h View 2 chunks +2 lines, -0 lines 0 comments Download
M src/messages.js View 1 chunk +1 line, -0 lines 0 comments Download
M src/parser.h View 1 2 6 chunks +69 lines, -0 lines 0 comments Download
M src/parser.cc View 1 2 3 chunks +64 lines, -0 lines 0 comments Download
M src/preparser.h View 1 2 30 chunks +389 lines, -41 lines 0 comments Download
M src/scanner.h View 1 chunk +2 lines, -0 lines 0 comments Download
M src/scanner.cc View 2 chunks +13 lines, -1 line 0 comments Download
M src/token.h View 1 chunk +133 lines, -132 lines 0 comments Download
M test/cctest/test-parsing.cc View 23 chunks +196 lines, -8 lines 0 comments Download

Messages

Total messages: 4 (0 generated)
marja
fix LGTM (Original review here: https://codereview.chromium.org/160073006 )
6 years, 5 months ago (2014-07-11 10:56:44 UTC) #1
marja
Can't land, doesn't pass make qc: .././src/preparser.h:2455:3: error: comparison between signed and unsigned integer expressions ...
6 years, 5 months ago (2014-07-11 11:18:38 UTC) #2
marja
Committed patchset #3 manually as r22366 (presubmit successful).
6 years, 5 months ago (2014-07-14 07:55:59 UTC) #3
Sven Panne
6 years, 5 months ago (2014-07-23 07:56:35 UTC) #4
Message was sent while issue was closed.
On 2014/07/14 07:55:59, marja (ooo until 18th of Aug) wrote:
> Committed patchset #3 manually as r22366 (presubmit successful).

NOTE: This broke JSBenchFacebook.js, see
https://code.google.com/p/v8/issues/detail?id=3456.

Powered by Google App Engine
This is Rietveld 408576698