Ignore:
Timestamp:
Aug 13, 2015, 4:55:35 PM (10 years ago)
Author:
Yusuke Suzuki
Message:

Unify JSParserCodeType, FunctionParseMode and ModuleParseMode into SourceParseMode
https://bugs.webkit.org/show_bug.cgi?id=147353

Reviewed by Saam Barati.

This is the follow-up patch after r188355.
It includes the following changes.

  • Unify JSParserCodeType, FunctionParseMode and ModuleParseMode into SourceParseMode
  • Make SourceParseMode to C++ strongly-typed enum.
  • Fix the comments.
  • Rename ModuleSpecifier to ModuleName.
  • Add the type name ImportEntry before the C++11 uniform initialization.
  • Fix the thrown message for duplicate 'default' names.
  • Assert the all statements in the top-level source elements are the module declarations under the module analyzer phase.
  • API/JSScriptRef.cpp:

(parseScript):

  • builtins/BuiltinExecutables.cpp:

(JSC::BuiltinExecutables::createExecutableInternal):

  • bytecode/UnlinkedFunctionExecutable.cpp:

(JSC::generateFunctionCodeBlock):

  • bytecode/UnlinkedFunctionExecutable.h:
  • bytecompiler/BytecodeGenerator.h:

(JSC::BytecodeGenerator::makeFunction):

  • parser/ASTBuilder.h:

(JSC::ASTBuilder::createFunctionMetadata):
(JSC::ASTBuilder::createModuleName):
(JSC::ASTBuilder::createImportDeclaration):
(JSC::ASTBuilder::createExportAllDeclaration):
(JSC::ASTBuilder::createExportNamedDeclaration):
(JSC::ASTBuilder::createModuleSpecifier): Deleted.

  • parser/ModuleAnalyzer.cpp:

(JSC::ModuleAnalyzer::analyze):

  • parser/NodeConstructors.h:

(JSC::ModuleNameNode::ModuleNameNode):
(JSC::ImportDeclarationNode::ImportDeclarationNode):
(JSC::ExportAllDeclarationNode::ExportAllDeclarationNode):
(JSC::ExportNamedDeclarationNode::ExportNamedDeclarationNode):
(JSC::ModuleSpecifierNode::ModuleSpecifierNode): Deleted.

  • parser/Nodes.cpp:

(JSC::FunctionMetadataNode::FunctionMetadataNode):

  • parser/Nodes.h:

(JSC::StatementNode::isModuleDeclarationNode):
(JSC::ModuleDeclarationNode::isModuleDeclarationNode):
(JSC::ImportDeclarationNode::moduleName):
(JSC::ExportAllDeclarationNode::moduleName):
(JSC::ExportNamedDeclarationNode::moduleName):
(JSC::ImportDeclarationNode::moduleSpecifier): Deleted.
(JSC::ExportAllDeclarationNode::moduleSpecifier): Deleted.
(JSC::ExportNamedDeclarationNode::moduleSpecifier): Deleted.

  • parser/NodesAnalyzeModule.cpp:

(JSC::SourceElements::analyzeModule):
(JSC::ImportDeclarationNode::analyzeModule):
(JSC::ExportAllDeclarationNode::analyzeModule):
(JSC::ExportNamedDeclarationNode::analyzeModule):

  • parser/Parser.cpp:

(JSC::Parser<LexerType>::Parser):
(JSC::Parser<LexerType>::parseInner):
(JSC::Parser<LexerType>::parseModuleSourceElements):
(JSC::Parser<LexerType>::parseFunctionBody):
(JSC::stringForFunctionMode):
(JSC::Parser<LexerType>::parseFunctionParameters):
(JSC::Parser<LexerType>::parseFunctionInfo):
(JSC::Parser<LexerType>::parseFunctionDeclaration):
(JSC::Parser<LexerType>::parseClass):
(JSC::Parser<LexerType>::parseModuleName):
(JSC::Parser<LexerType>::parseImportDeclaration):
(JSC::Parser<LexerType>::parseExportDeclaration):
(JSC::Parser<LexerType>::parsePropertyMethod):
(JSC::Parser<LexerType>::parseGetterSetter):
(JSC::Parser<LexerType>::parsePrimaryExpression):
(JSC::Parser<LexerType>::parseArrowFunctionExpression):
(JSC::Parser<LexerType>::parseModuleSpecifier): Deleted.

  • parser/Parser.h:

(JSC::Parser<LexerType>::parse):
(JSC::parse):

  • parser/ParserModes.h:

(JSC::isFunctionParseMode):
(JSC::isModuleParseMode):
(JSC::isProgramParseMode):

  • parser/SyntaxChecker.h:

(JSC::SyntaxChecker::createFunctionMetadata):
(JSC::SyntaxChecker::createModuleName):
(JSC::SyntaxChecker::createImportDeclaration):
(JSC::SyntaxChecker::createExportAllDeclaration):
(JSC::SyntaxChecker::createExportNamedDeclaration):
(JSC::SyntaxChecker::createModuleSpecifier): Deleted.

  • runtime/CodeCache.cpp:

(JSC::CodeCache::getGlobalCodeBlock):
(JSC::CodeCache::getFunctionExecutableFromGlobalCode):

  • runtime/Completion.cpp:

(JSC::checkSyntax):
(JSC::checkModuleSyntax):

  • runtime/Executable.cpp:

(JSC::ProgramExecutable::checkSyntax):

  • tests/stress/modules-syntax-error-with-names.js:
File:
1 edited

Legend:

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

    r188355 r188417  
    8585        TemplateExpressionListResult, TemplateExpr,
    8686        TaggedTemplateExpr,
    87         ModuleSpecifierResult,
     87        ModuleNameResult,
    8888        ImportSpecifierResult, ImportSpecifierListResult,
    8989        ExportSpecifierResult, ExportSpecifierListResult
     
    128128    typedef int ClassExpression;
    129129#endif
    130     typedef int ModuleSpecifier;
     130    typedef int ModuleName;
    131131    typedef int ImportSpecifier;
    132132    typedef int ImportSpecifierList;
     
    187187#endif
    188188    ExpressionType createFunctionExpr(const JSTokenLocation&, const ParserFunctionInfo<SyntaxChecker>&) { return FunctionExpr; }
    189     int createFunctionMetadata(const JSTokenLocation&, const JSTokenLocation&, int, int, bool, int, int, int, ConstructorKind, unsigned, int) { return FunctionBodyResult; }
     189    int createFunctionMetadata(const JSTokenLocation&, const JSTokenLocation&, int, int, bool, int, int, int, ConstructorKind, unsigned, SourceParseMode) { return FunctionBodyResult; }
    190190    ExpressionType createArrowFunctionExpr(const JSTokenLocation&, const ParserFunctionInfo<SyntaxChecker>&) { return FunctionExpr; }
    191191    void setFunctionNameStart(int, int) { }
     
    260260    int createDebugger(const JSTokenLocation&, int, int) { return StatementResult; }
    261261    int createConstStatement(const JSTokenLocation&, int, int, int) { return StatementResult; }
    262     int createModuleSpecifier(const JSTokenLocation&, const Identifier&) { return ModuleSpecifierResult; }
     262    int createModuleName(const JSTokenLocation&, const Identifier&) { return ModuleNameResult; }
    263263    ImportSpecifier createImportSpecifier(const JSTokenLocation&, const Identifier&, const Identifier&) { return ImportSpecifierResult; }
    264264    ImportSpecifierList createImportSpecifierList() { return ImportSpecifierListResult; }
    265265    void appendImportSpecifier(ImportSpecifierList, ImportSpecifier) { }
    266     int createImportDeclaration(const JSTokenLocation&, ImportSpecifierList, ModuleSpecifier) { return StatementResult; }
    267     int createExportAllDeclaration(const JSTokenLocation&, ModuleSpecifier) { return StatementResult; }
     266    int createImportDeclaration(const JSTokenLocation&, ImportSpecifierList, ModuleName) { return StatementResult; }
     267    int createExportAllDeclaration(const JSTokenLocation&, ModuleName) { return StatementResult; }
    268268    int createExportDefaultDeclaration(const JSTokenLocation&, int, const Identifier&) { return StatementResult; }
    269269    int createExportLocalDeclaration(const JSTokenLocation&, int) { return StatementResult; }
    270     int createExportNamedDeclaration(const JSTokenLocation&, ExportSpecifierList, ModuleSpecifier) { return StatementResult; }
     270    int createExportNamedDeclaration(const JSTokenLocation&, ExportSpecifierList, ModuleName) { return StatementResult; }
    271271    ExportSpecifier createExportSpecifier(const JSTokenLocation&, const Identifier&, const Identifier&) { return ExportSpecifierResult; }
    272272    ExportSpecifierList createExportSpecifierList() { return ExportSpecifierListResult; }
Note: See TracChangeset for help on using the changeset viewer.