Ignore:
Timestamp:
Aug 10, 2015, 1:24:35 PM (10 years ago)
Author:
[email protected]
Message:

Let's rename FunctionBodyNode
https://bugs.webkit.org/show_bug.cgi?id=147292

Reviewed by Mark Lam & Saam Barati.

FunctionBodyNode => FunctionMetadataNode

Make FunctionMetadataNode inherit from Node instead of StatementNode
because a FunctionMetadataNode can appear in expression context and does
not have a next statement.

(I decided to continue allocating FunctionMetadataNode in the AST arena,
and to retain "Node" in its name, because it really is a parsing
construct, and we transform its data before consuming it elsewhere.

There is still room for a future patch to distill and simplify the
metadata we track about functions between FunDeclNode/FuncExprNode,
FunctionMetadataNode, and UnlinkedFunctionExecutable. But this is a start.)

  • builtins/BuiltinExecutables.cpp:

(JSC::BuiltinExecutables::createExecutableInternal):

  • bytecode/UnlinkedCodeBlock.cpp:

(JSC::generateFunctionCodeBlock):
(JSC::UnlinkedFunctionExecutable::UnlinkedFunctionExecutable):

  • bytecode/UnlinkedCodeBlock.h:
  • bytecompiler/BytecodeGenerator.cpp:

(JSC::BytecodeGenerator::generate):
(JSC::BytecodeGenerator::BytecodeGenerator):
(JSC::BytecodeGenerator::emitNewArray):
(JSC::BytecodeGenerator::emitNewFunction):
(JSC::BytecodeGenerator::emitNewFunctionExpression):

  • bytecompiler/BytecodeGenerator.h:

(JSC::BytecodeGenerator::makeFunction):

  • bytecompiler/NodesCodegen.cpp:

(JSC::EvalNode::emitBytecode):
(JSC::FunctionNode::emitBytecode):
(JSC::FunctionBodyNode::emitBytecode): Deleted.

  • parser/ASTBuilder.h:

(JSC::ASTBuilder::createFunctionExpr):
(JSC::ASTBuilder::createFunctionBody):

  • parser/NodeConstructors.h:

(JSC::FunctionParameters::FunctionParameters):
(JSC::FuncExprNode::FuncExprNode):
(JSC::FuncDeclNode::FuncDeclNode):

  • parser/Nodes.cpp:

(JSC::EvalNode::EvalNode):
(JSC::FunctionMetadataNode::FunctionMetadataNode):
(JSC::FunctionMetadataNode::finishParsing):
(JSC::FunctionMetadataNode::setEndPosition):
(JSC::FunctionBodyNode::FunctionBodyNode): Deleted.
(JSC::FunctionBodyNode::finishParsing): Deleted.
(JSC::FunctionBodyNode::setEndPosition): Deleted.

  • parser/Nodes.h:

(JSC::FuncExprNode::body):
(JSC::FuncDeclNode::body):

  • parser/Parser.h:

(JSC::Parser::isFunctionMetadataNode):
(JSC::Parser::next):
(JSC::Parser<LexerType>::parse):
(JSC::Parser::isFunctionBodyNode): Deleted.

  • runtime/CodeCache.cpp:

(JSC::CodeCache::getFunctionExecutableFromGlobalCode):

  • runtime/CodeCache.h:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/parser/ASTBuilder.h

    r187890 r188219  
    110110#endif
    111111    typedef FunctionParameters* FormalParameterList;
    112     typedef FunctionBodyNode* FunctionBody;
     112    typedef FunctionMetadataNode* FunctionBody;
    113113#if ENABLE(ES6_CLASS_SYNTAX)
    114114    typedef ClassExprNode* ClassExpression;
     
    337337    {
    338338        if (rhs->isFuncExprNode())
    339             static_cast<FuncExprNode*>(rhs)->body()->setInferredName(ident);
     339            static_cast<FuncExprNode*>(rhs)->metadata()->setInferredName(ident);
    340340        AssignResolveNode* node = new (m_parserArena) AssignResolveNode(location, ident, rhs, assignmentContext);
    341341        setExceptionLocation(node, start, divot, end);
     
    359359    }
    360360
    361     FunctionBodyNode* createFunctionBody(
     361    FunctionMetadataNode* createFunctionMetadata(
    362362        const JSTokenLocation& startLocation, const JSTokenLocation& endLocation,
    363363        unsigned startColumn, unsigned endColumn, int functionKeywordStart,
     
    365365        ConstructorKind constructorKind, unsigned parameterCount, FunctionParseMode mode)
    366366    {
    367         return new (m_parserArena) FunctionBodyNode(
     367        return new (m_parserArena) FunctionMetadataNode(
    368368            m_parserArena, startLocation, endLocation, startColumn, endColumn,
    369369            functionKeywordStart, functionNameStart, parametersStart,
     
    409409    {
    410410        if (node->isFuncExprNode())
    411             static_cast<FuncExprNode*>(node)->body()->setInferredName(*propertyName);
     411            static_cast<FuncExprNode*>(node)->metadata()->setInferredName(*propertyName);
    412412        return new (m_parserArena) PropertyNode(*propertyName, node, type, putType, superBinding);
    413413    }
     
    439439        if (*functionInfo.name == m_vm->propertyNames->arguments)
    440440            usesArguments();
    441         m_scope.m_funcDeclarations.append(decl->body());
     441        m_scope.m_funcDeclarations.append(decl->metadata());
    442442        functionInfo.body->setLoc(functionInfo.startLine, functionInfo.endLine, location.startOffset, location.lineStartOffset);
    443443        return decl;
     
    12121212        if (op == OpEqual) {
    12131213            if (expr->isFuncExprNode())
    1214                 static_cast<FuncExprNode*>(expr)->body()->setInferredName(resolve->identifier());
     1214                static_cast<FuncExprNode*>(expr)->metadata()->setInferredName(resolve->identifier());
    12151215            AssignResolveNode* node = new (m_parserArena) AssignResolveNode(location, resolve->identifier(), expr, AssignmentContext::AssignmentExpression);
    12161216            setExceptionLocation(node, start, divot, end);
     
    12311231    if (op == OpEqual) {
    12321232        if (expr->isFuncExprNode())
    1233             static_cast<FuncExprNode*>(expr)->body()->setInferredName(dot->identifier());
     1233            static_cast<FuncExprNode*>(expr)->metadata()->setInferredName(dot->identifier());
    12341234        return new (m_parserArena) AssignDotNode(location, dot->base(), dot->identifier(), expr, exprHasAssignments, dot->divot(), start, end);
    12351235    }
Note: See TracChangeset for help on using the changeset viewer.