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/SyntaxChecker.h

    r181807 r181818  
    169169    ClassExpression createClassExpr(const JSTokenLocation&, const Identifier&, ExpressionType, ExpressionType, PropertyList, PropertyList) { return ClassExpr; }
    170170#endif
    171     ExpressionType createFunctionExpr(const JSTokenLocation&, const ParserFunctionInfo<SyntaxChecker>&, int) { return FunctionExpr; }
    172     int createFunctionBody(const JSTokenLocation&, const JSTokenLocation&, int, int, bool, ConstructorKind) { return FunctionBodyResult; }
    173     void setFunctionNameStart(int, int) { }
     171    ExpressionType createFunctionExpr(const JSTokenLocation&, const ParserFunctionInfo<SyntaxChecker>&) { return FunctionExpr; }
     172    int createFunctionBody(const JSTokenLocation&, const JSTokenLocation&, int, int, bool, int, int, int, ConstructorKind) { return FunctionBodyResult; }
    174173    int createArguments() { return ArgumentsResult; }
    175174    int createArguments(int) { return ArgumentsResult; }
     
    203202    int createClauseList(int) { return ClauseListResult; }
    204203    int createClauseList(int, int) { return ClauseListResult; }
    205     int createFuncDeclStatement(const JSTokenLocation&, const ParserFunctionInfo<SyntaxChecker>&, int) { return StatementResult; }
     204    int createFuncDeclStatement(const JSTokenLocation&, const ParserFunctionInfo<SyntaxChecker>&) { return StatementResult; }
    206205#if ENABLE(ES6_CLASS_SYNTAX)
    207206    int createClassDeclStatement(const JSTokenLocation&, ClassExpression,
     
    232231    int createConstStatement(const JSTokenLocation&, int, int, int) { return StatementResult; }
    233232    int appendConstDecl(const JSTokenLocation&, int, const Identifier*, int) { return StatementResult; }
    234     Property createGetterOrSetterProperty(const JSTokenLocation&, PropertyNode::Type type, bool strict, const Identifier* name, const ParserFunctionInfo<SyntaxChecker>&, unsigned, SuperBinding)
     233    Property createGetterOrSetterProperty(const JSTokenLocation&, PropertyNode::Type type, bool strict, const Identifier* name, const ParserFunctionInfo<SyntaxChecker>&, SuperBinding)
    235234    {
    236235        ASSERT(name);
     
    239238        return Property(name, type);
    240239    }
    241     Property createGetterOrSetterProperty(VM* vm, ParserArena& parserArena, const JSTokenLocation&, PropertyNode::Type type, bool strict, double name, const ParserFunctionInfo<SyntaxChecker>&, unsigned, SuperBinding)
     240    Property createGetterOrSetterProperty(VM* vm, ParserArena& parserArena, const JSTokenLocation&, PropertyNode::Type type, bool strict, double name, const ParserFunctionInfo<SyntaxChecker>&, SuperBinding)
    242241    {
    243242        if (!strict)
Note: See TracChangeset for help on using the changeset viewer.