Ignore:
Timestamp:
Mar 20, 2015, 4:37:51 PM (10 years ago)
Author:
[email protected]
Message:

FunctionBodyNode should known where its parameters started
https://bugs.webkit.org/show_bug.cgi?id=142926

Reviewed by Ryosuke Niwa.

This will allow us to re-parse parameters instead of keeping the
parameters piece of the AST around forever.

I also took the opportunity to initialize most FunctionBodyNode data
members at construction time, to help clarify that they are set right.

  • parser/ASTBuilder.h:

(JSC::ASTBuilder::createFunctionExpr): No need to pass
functionKeywordStart here; we now provide it at FunctionBodyNode
creation time.

(JSC::ASTBuilder::createFunctionBody): Require everything we need at
construction time, including the start of our parameters.

(JSC::ASTBuilder::createGetterOrSetterProperty):
(JSC::ASTBuilder::createFuncDeclStatement): No need to pass
functionKeywordStart here; we now provide it at FunctionBodyNode
creation time.

(JSC::ASTBuilder::setFunctionNameStart): Deleted.

  • parser/Nodes.cpp:

(JSC::FunctionBodyNode::FunctionBodyNode): Initialize everything at
construction time.

  • parser/Nodes.h: Added a field for the location of our parameters.
  • parser/Parser.cpp:

(JSC::Parser<LexerType>::parseFunctionBody):
(JSC::Parser<LexerType>::parseFunctionInfo):
(JSC::Parser<LexerType>::parseFunctionDeclaration):
(JSC::Parser<LexerType>::parseClass):
(JSC::Parser<LexerType>::parsePropertyMethod):
(JSC::Parser<LexerType>::parseGetterSetter):
(JSC::Parser<LexerType>::parsePrimaryExpression):

  • parser/Parser.h: Refactored to match above interface changes.
  • parser/SyntaxChecker.h:

(JSC::SyntaxChecker::createFunctionExpr):
(JSC::SyntaxChecker::createFunctionBody):
(JSC::SyntaxChecker::createFuncDeclStatement):
(JSC::SyntaxChecker::createGetterOrSetterProperty): Refactored to match
above interface changes.

(JSC::SyntaxChecker::setFunctionNameStart): Deleted.

File:
1 edited

Legend:

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

    r181490 r181818  
    168168}
    169169
    170 FunctionBodyNode::FunctionBodyNode(ParserArena&, const JSTokenLocation& startLocation, const JSTokenLocation& endLocation, unsigned startColumn, unsigned endColumn, bool isInStrictContext, ConstructorKind constructorKind)
    171     : StatementNode(endLocation)
    172     , m_startColumn(startColumn)
    173     , m_endColumn(endColumn)
    174     , m_startStartOffset(startLocation.startOffset)
    175     , m_isInStrictContext(isInStrictContext)
    176     , m_constructorKind(static_cast<unsigned>(constructorKind))
     170FunctionBodyNode::FunctionBodyNode(
     171    ParserArena&, const JSTokenLocation& startLocation,
     172    const JSTokenLocation& endLocation, unsigned startColumn, unsigned endColumn,
     173    int functionKeywordStart, int functionNameStart, int parametersStart,
     174    bool isInStrictContext, ConstructorKind constructorKind)
     175        : StatementNode(endLocation)
     176        , m_startColumn(startColumn)
     177        , m_endColumn(endColumn)
     178        , m_functionKeywordStart(functionKeywordStart)
     179        , m_functionNameStart(functionNameStart)
     180        , m_parametersStart(parametersStart)
     181        , m_startStartOffset(startLocation.startOffset)
     182        , m_isInStrictContext(isInStrictContext)
     183        , m_constructorKind(static_cast<unsigned>(constructorKind))
    177184{
    178185    ASSERT(m_constructorKind == static_cast<unsigned>(constructorKind));
Note: See TracChangeset for help on using the changeset viewer.