Go to file
marja@chromium.org 70da8959bc 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

Review URL: https://codereview.chromium.org/383983002

Patch from Adrián Pérez de Castro <aperez@igalia.com>.

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22366 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2014-07-14 07:55:45 +00:00
benchmarks Add new benchmark suite runner. 2014-05-28 13:05:17 +00:00
build Add mips64 port. 2014-07-09 11:08:26 +00:00
include Refactor ScriptData class for cached compile data. 2014-07-10 10:28:05 +00:00
samples Buildfix for windows after r22180 2014-07-03 07:57:29 +00:00
src Implement handling of arrow functions in the parser 2014-07-14 07:55:45 +00:00
test Implement handling of arrow functions in the parser 2014-07-14 07:55:45 +00:00
tools Introduce a PrototypeIterator class and use it for prototype access 2014-07-14 07:19:49 +00:00
.clang-format Change clang-format config to allow for two empty lines between functions 2013-12-03 10:39:21 +00:00
.DEPS.git Roll buildtools to fb782d4369d5ae04f17a2fceef7de5a63e50f07b 2014-06-26 10:49:27 +00:00
.gitignore Roll buildtools to fb782d4369d5ae04f17a2fceef7de5a63e50f07b 2014-06-26 10:49:27 +00:00
AUTHORS Introduce x87 port 2014-05-23 16:37:27 +00:00
BUILD.gn Introduce a PrototypeIterator class and use it for prototype access 2014-07-14 07:19:49 +00:00
ChangeLog Sync change log file with trunk. 2014-05-19 15:29:29 +00:00
codereview.settings Add PROJECT to v8 2014-06-23 15:33:19 +00:00
DEPS Roll buildtools to fb782d4369d5ae04f17a2fceef7de5a63e50f07b 2014-06-26 10:49:27 +00:00
LICENSE Update LICENSE date. 2014-02-18 10:50:22 +00:00
LICENSE.strongtalk Add LICENSE.v8, LICENSE.strongtalk and LICENSE.valgrind to the v8 2011-02-03 07:10:06 +00:00
LICENSE.v8 Add LICENSE.v8, LICENSE.strongtalk and LICENSE.valgrind to the v8 2011-02-03 07:10:06 +00:00
LICENSE.valgrind Add LICENSE.v8, LICENSE.strongtalk and LICENSE.valgrind to the v8 2011-02-03 07:10:06 +00:00
Makefile Add mips64 port. 2014-07-09 11:08:26 +00:00
Makefile.android Android ARM64: update Makefile for new NDK. 2014-07-01 09:40:14 +00:00
Makefile.nacl Set host_arch to ia32 on machines with a 32bit userland but a 64bit kernel. 2014-06-24 07:12:48 +00:00
OWNERS Add vogelheim@ to v8 OWNERS 2014-07-08 13:26:48 +00:00
PRESUBMIT.py Add compile-only win64 trybot. 2014-07-10 19:24:33 +00:00
WATCHLISTS Add myself to a watchlist for the public API. 2013-10-10 11:37:48 +00:00