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

    r221080 r221358  
    603603    }
    604604   
    605     StatementNode* createForOfLoop(const JSTokenLocation& location, ExpressionNode* lhs, ExpressionNode* iter, StatementNode* statements, const JSTokenLocation&, const JSTextPosition& eStart, const JSTextPosition& eDivot, const JSTextPosition& eEnd, int start, int end, VariableEnvironment& lexicalVariables)
    606     {
    607         ForOfNode* result = new (m_parserArena) ForOfNode(location, lhs, iter, statements, lexicalVariables);
     605    StatementNode* createForOfLoop(bool isForAwait, const JSTokenLocation& location, ExpressionNode* lhs, ExpressionNode* iter, StatementNode* statements, const JSTokenLocation&, const JSTextPosition& eStart, const JSTextPosition& eDivot, const JSTextPosition& eEnd, int start, int end, VariableEnvironment& lexicalVariables)
     606    {
     607        ForOfNode* result = new (m_parserArena) ForOfNode(isForAwait, location, lhs, iter, statements, lexicalVariables);
    608608        result->setLoc(start, end, location.startOffset, location.lineStartOffset);
    609609        setExceptionLocation(result, eStart, eDivot, eEnd);
     
    611611    }
    612612   
    613     StatementNode* createForOfLoop(const JSTokenLocation& location, DestructuringPatternNode* pattern, ExpressionNode* iter, StatementNode* statements, const JSTokenLocation& declLocation, const JSTextPosition& eStart, const JSTextPosition& eDivot, const JSTextPosition& eEnd, int start, int end, VariableEnvironment& lexicalVariables)
     613    StatementNode* createForOfLoop(bool isForAwait, const JSTokenLocation& location, DestructuringPatternNode* pattern, ExpressionNode* iter, StatementNode* statements, const JSTokenLocation& declLocation, const JSTextPosition& eStart, const JSTextPosition& eDivot, const JSTextPosition& eEnd, int start, int end, VariableEnvironment& lexicalVariables)
    614614    {
    615615        auto lexpr = new (m_parserArena) DestructuringAssignmentNode(declLocation, pattern, nullptr);
    616         return createForOfLoop(location, lexpr, iter, statements, declLocation, eStart, eDivot, eEnd, start, end, lexicalVariables);
     616        return createForOfLoop(isForAwait, location, lexpr, iter, statements, declLocation, eStart, eDivot, eEnd, start, end, lexicalVariables);
    617617    }
    618618
Note: See TracChangeset for help on using the changeset viewer.