Ignore:
Timestamp:
Jan 26, 2015, 5:14:14 PM (10 years ago)
Author:
[email protected]
Message:

Parse a function expression as a primary expression
https://bugs.webkit.org/show_bug.cgi?id=140908

Reviewed by Mark Lam.

Moved the code to generate an AST node for a function expression from parseMemberExpression
to parsePrimaryExpression to match the ES6 specification terminology:
https://people.mozilla.org/~jorendorff/es6-draft.html#sec-primary-expression

There should be no behavior change from this change since parsePrimaryExpression is only
called in parseMemberExpression other than the fact failIfStackOverflow() is called.

  • parser/Parser.cpp:

(JSC::Parser<LexerType>::parsePrimaryExpression):
(JSC::Parser<LexerType>::parseMemberExpression):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/parser/Parser.cpp

    r178888 r179159  
    20282028    failIfStackOverflow();
    20292029    switch (m_token.m_type) {
     2030    case FUNCTION: {
     2031        JSTokenLocation location(tokenLocation());
     2032        unsigned functionKeywordStart = tokenStart();
     2033        next();
     2034        ParserFunctionInfo<TreeBuilder> info;
     2035        info.name = &m_vm->propertyNames->nullIdentifier;
     2036        failIfFalse((parseFunctionInfo(context, FunctionNoRequirements, FunctionMode, false, info)), "Cannot parse function expression");
     2037        return context.createFunctionExpr(location, info, functionKeywordStart);
     2038    }
    20302039    case OPENBRACE:
    20312040        if (strictMode())
     
    21642173    }
    21652174
    2166     if (match(FUNCTION)) {
    2167         unsigned functionKeywordStart = tokenStart();
    2168         location = tokenLocation();
    2169         next();
    2170         ParserFunctionInfo<TreeBuilder> info;
    2171         info.name = &m_vm->propertyNames->nullIdentifier;
    2172         failIfFalse((parseFunctionInfo(context, FunctionNoRequirements, FunctionMode, false, info)), "Cannot parse function expression");
    2173         base = context.createFunctionExpr(location, info, functionKeywordStart);
    2174     } else
    2175         base = parsePrimaryExpression(context);
     2175    base = parsePrimaryExpression(context);
    21762176   
    21772177    failIfFalse(base, "Cannot parse base expression");
Note: See TracChangeset for help on using the changeset viewer.