Ignore:
Timestamp:
Aug 6, 2017, 6:04:32 AM (8 years ago)
Author:
[email protected]
Message:

[Next] Async iteration - Implement Async Generator - parser
https://bugs.webkit.org/show_bug.cgi?id=175210

Reviewed by Yusuke Suzuki.

JSTests:

  • stress/async-await-syntax.js:

(testTopLevelAsyncAwaitSyntaxSloppyMode.testSyntax):

  • stress/async-iteration-syntax.js: Added.

(assert):
(checkSyntax):
(checkSyntaxError):
(checkSimpleAsyncGeneratorSloppyMode):
(checkSimpleAsyncGeneratorStrictMode):
(checkNestedAsyncGenerators):
(checkSimpleAsyncGeneratorSyntaxErrorInStrictMode):

  • stress/generator-class-methods-syntax.js:

Source/JavaScriptCore:

Current implementation is draft version of Async Iteration.
Link to spec https://tc39.github.io/proposal-async-iteration/

Current patch implement only parser part of the Async generator
Runtime part will be in next ptches

  • parser/ASTBuilder.h:

(JSC::ASTBuilder::createFunctionMetadata):

  • parser/Parser.cpp:

(JSC::getAsynFunctionBodyParseMode):
(JSC::Parser<LexerType>::parseInner):
(JSC::Parser<LexerType>::parseAsyncFunctionSourceElements):
(JSC::Parser<LexerType>::parseAsyncGeneratorFunctionSourceElements):
(JSC::stringArticleForFunctionMode):
(JSC::stringForFunctionMode):
(JSC::Parser<LexerType>::parseFunctionInfo):
(JSC::Parser<LexerType>::parseAsyncFunctionDeclaration):
(JSC::Parser<LexerType>::parseClass):
(JSC::Parser<LexerType>::parseProperty):
(JSC::Parser<LexerType>::parsePropertyMethod):
(JSC::Parser<LexerType>::parseAsyncFunctionExpression):

  • parser/Parser.h:

(JSC::Scope::setSourceParseMode):

  • parser/ParserModes.h:

(JSC::isFunctionParseMode):
(JSC::isAsyncFunctionParseMode):
(JSC::isAsyncArrowFunctionParseMode):
(JSC::isAsyncGeneratorFunctionParseMode):
(JSC::isAsyncFunctionOrAsyncGeneratorWrapperParseMode):
(JSC::isAsyncFunctionWrapperParseMode):
(JSC::isAsyncFunctionBodyParseMode):
(JSC::isGeneratorMethodParseMode):
(JSC::isAsyncMethodParseMode):
(JSC::isAsyncGeneratorMethodParseMode):
(JSC::isMethodParseMode):
(JSC::isGeneratorOrAsyncFunctionBodyParseMode):
(JSC::isGeneratorOrAsyncFunctionWrapperParseMode):

File:
1 edited

Legend:

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

    r218861 r220323  
    226226    {
    227227        switch (mode) {
     228        case SourceParseMode::AsyncGeneratorBodyMode:
     229            setIsAsyncFunctionBody();
     230            setIsGenerator();
     231            break;
    228232        case SourceParseMode::AsyncArrowFunctionBodyMode:
    229233            setIsAsyncArrowFunctionBody();
     
    243247            break;
    244248
     249        case SourceParseMode::AsyncGeneratorWrapperMethodMode:
     250        case SourceParseMode::AsyncGeneratorWrapperFunctionMode:
     251            setIsAsyncFunction();
     252            setIsGeneratorFunction();
     253            break;
     254   
    245255        case SourceParseMode::NormalFunctionMode:
    246256        case SourceParseMode::GetterMode:
     
    14961506    template <class TreeBuilder> TreeSourceElements parseGeneratorFunctionSourceElements(TreeBuilder&, const Identifier& name, SourceElementsMode);
    14971507    template <class TreeBuilder> TreeSourceElements parseAsyncFunctionSourceElements(TreeBuilder&, SourceParseMode, bool isArrowFunctionBodyExpression, SourceElementsMode);
     1508    template <class TreeBuilder> TreeSourceElements parseAsyncGeneratorFunctionSourceElements(TreeBuilder&, SourceParseMode, bool isArrowFunctionBodyExpression, SourceElementsMode);
    14981509    template <class TreeBuilder> TreeStatement parseStatementListItem(TreeBuilder&, const Identifier*& directive, unsigned* directiveLiteralLength);
    14991510    template <class TreeBuilder> TreeStatement parseStatement(TreeBuilder&, const Identifier*& directive, unsigned* directiveLiteralLength = 0);
     
    15421553    template <class TreeBuilder> ALWAYS_INLINE TreeExpression parseArgument(TreeBuilder&, ArgumentType&);
    15431554    template <class TreeBuilder> TreeProperty parseProperty(TreeBuilder&, bool strict);
    1544     template <class TreeBuilder> TreeExpression parsePropertyMethod(TreeBuilder& context, const Identifier* methodName, bool isGenerator, bool isAsyncMethod);
     1555    template <class TreeBuilder> TreeExpression parsePropertyMethod(TreeBuilder& context, const Identifier* methodName, SourceParseMode);
    15451556    template <class TreeBuilder> TreeProperty parseGetterSetter(TreeBuilder&, bool strict, PropertyNode::Type, unsigned getterOrSetterStartOffset, ConstructorKind, bool isClassProperty, bool isStaticMethod);
    15461557    template <class TreeBuilder> ALWAYS_INLINE TreeFunctionBody parseFunctionBody(TreeBuilder&, SyntaxChecker&, const JSTokenLocation&, int, int functionKeywordStart, int functionNameStart, int parametersStart, ConstructorKind, SuperBinding, FunctionBodyType, unsigned, SourceParseMode);
Note: See TracChangeset for help on using the changeset viewer.