• marja@chromium.org's avatar
    Implement handling of arrow functions in the parser · 7367720d
    marja@chromium.org authored
    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 ParseFunctionLiteral(),
    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 ParseExpression() expects parenthesized expressions
    to not be empty, so checking for a closing parenthesis is added in
    handling the empty parameter list "()" will accept a right-paren and
    return an empty expression, which means that the parameter list is
    empty.
    
    Additionally, this adds the following machinery:
    
     - A runtime flag "harmony_arrow_functions" (disabled by default).
       Enabling "harmony" will enable it as well.
     - An IsArrow bit in SharedFunctionInfo, and accessors for it.
     - An IsArrow bit in FunctionLiteral, accessorts for it, and
       a constructor parameter to set its value.
     - In ParserBase: allow_arrow_functions() and set_allow_arrow_functions()
     - A V8 native %FunctionIsArrow(), which is used to skip adding the
       "function " prefix when getting the source code for an arrow
       function.
    
    R=marja@chromium.org
    
    Review URL: https://codereview.chromium.org/160073006
    
    Patch from Adrián Pérez de Castro <aperez@igalia.com>.
    
    git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22265 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
    7367720d
Name
Last commit
Last update
benchmarks Loading commit data...
build Loading commit data...
include Loading commit data...
samples Loading commit data...
src Loading commit data...
test Loading commit data...
tools Loading commit data...
.DEPS.git Loading commit data...
.clang-format Loading commit data...
.gitignore Loading commit data...
AUTHORS Loading commit data...
BUILD.gn Loading commit data...
ChangeLog Loading commit data...
DEPS Loading commit data...
LICENSE Loading commit data...
LICENSE.strongtalk Loading commit data...
LICENSE.v8 Loading commit data...
LICENSE.valgrind Loading commit data...
Makefile Loading commit data...
Makefile.android Loading commit data...
Makefile.nacl Loading commit data...
OWNERS Loading commit data...
PRESUBMIT.py Loading commit data...
WATCHLISTS Loading commit data...
codereview.settings Loading commit data...