Ignore:
Timestamp:
Aug 30, 2017, 2:51:45 AM (8 years ago)
Author:
[email protected]
Message:

[ESNext] Async iteration - Implement async iteration statement: for-await-of
https://bugs.webkit.org/show_bug.cgi?id=166698

Reviewed by Yusuke Suzuki.

JSTests:

  • stress/async-iteration-for-await-of-syntax.js: Added.

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

  • stress/async-iteration-for-await-of.js: Added.

(assert):
(async.foo):
(async.boo):
(const.boo.async):

Source/JavaScriptCore:

Implementation of the for-await-of statement.

  • bytecompiler/BytecodeGenerator.cpp:

(JSC::BytecodeGenerator::emitEnumeration):
(JSC::BytecodeGenerator::emitIteratorNext):

  • bytecompiler/BytecodeGenerator.h:
  • parser/ASTBuilder.h:

(JSC::ASTBuilder::createForOfLoop):

  • parser/NodeConstructors.h:

(JSC::ForOfNode::ForOfNode):

  • parser/Nodes.h:

(JSC::ForOfNode::isForAwait const):

  • parser/Parser.cpp:

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

  • parser/Parser.h:

(JSC::Scope::setSourceParseMode):
(JSC::Scope::setIsFunction):
(JSC::Scope::setIsAsyncGeneratorFunction):
(JSC::Scope::setIsAsyncGeneratorFunctionBody):

  • parser/SyntaxChecker.h:

(JSC::SyntaxChecker::createForOfLoop):

File:
1 edited

Legend:

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

    r220323 r221358  
    227227        switch (mode) {
    228228        case SourceParseMode::AsyncGeneratorBodyMode:
    229             setIsAsyncFunctionBody();
    230             setIsGenerator();
     229            setIsAsyncGeneratorFunctionBody();
    231230            break;
    232231        case SourceParseMode::AsyncArrowFunctionBodyMode:
     
    249248        case SourceParseMode::AsyncGeneratorWrapperMethodMode:
    250249        case SourceParseMode::AsyncGeneratorWrapperFunctionMode:
    251             setIsAsyncFunction();
    252             setIsGeneratorFunction();
     250            setIsAsyncGeneratorFunction();
    253251            break;
    254252   
     
    712710        m_isArrowFunctionBoundary = false;
    713711        m_isArrowFunction = false;
     712        m_isAsyncFunction = false;
     713        m_isAsyncFunctionBoundary = false;
    714714    }
    715715
     
    745745        setIsFunction();
    746746        m_isAsyncFunction = true;
     747    }
     748
     749    void setIsAsyncGeneratorFunction()
     750    {
     751        setIsFunction();
     752        m_isAsyncFunction = true;
     753        m_isGenerator = true;
     754    }
     755
     756    void setIsAsyncGeneratorFunctionBody()
     757    {
     758        setIsFunction();
     759        m_hasArguments = false;
     760        m_isGenerator = true;
     761        m_isGeneratorBoundary = true;
     762        m_isAsyncFunction = true;
     763        m_isAsyncFunctionBoundary = true;
    747764    }
    748765
Note: See TracChangeset for help on using the changeset viewer.