15.6 Async Generator Function Definitions
Syntax
15.6.1 Static Semantics: Early Errors
- It is a Syntax Error if
HasDirectSuper ofAsyncGeneratorMethod istrue . - It is a Syntax Error if
UniqueFormalParameters Contains YieldExpression istrue . - It is a Syntax Error if
UniqueFormalParameters Contains AwaitExpression istrue . - It is a Syntax Error if
FunctionBodyContainsUseStrict ofAsyncGeneratorBody istrue andIsSimpleParameterList ofUniqueFormalParameters isfalse . - It is a Syntax Error if any element of the
BoundNames ofUniqueFormalParameters also occurs in theLexicallyDeclaredNames ofAsyncGeneratorBody .
- If the
source text matched by FormalParameters isstrict mode code , the Early Error rules for are applied.UniqueFormalParameters : FormalParameters - If
BindingIdentifier is present and thesource text matched by BindingIdentifier isstrict mode code , it is a Syntax Error if theStringValue ofBindingIdentifier is either"eval" or"arguments" . - It is a Syntax Error if
FunctionBodyContainsUseStrict ofAsyncGeneratorBody istrue andIsSimpleParameterList ofFormalParameters isfalse . - It is a Syntax Error if any element of the
BoundNames ofFormalParameters also occurs in theLexicallyDeclaredNames ofAsyncGeneratorBody . - It is a Syntax Error if
FormalParameters Contains YieldExpression istrue . - It is a Syntax Error if
FormalParameters Contains AwaitExpression istrue . - It is a Syntax Error if
FormalParameters Contains SuperProperty istrue . - It is a Syntax Error if
AsyncGeneratorBody Contains SuperProperty istrue . - It is a Syntax Error if
FormalParameters Contains SuperCall istrue . - It is a Syntax Error if
AsyncGeneratorBody Contains SuperCall istrue .
15.6.2 Runtime Semantics: EvaluateAsyncGeneratorBody
The
- Perform ?
FunctionDeclarationInstantiation (functionObject, argumentsList). - Let generator be ?
OrdinaryCreateFromConstructor (functionObject,"%AsyncGeneratorFunction.prototype.prototype%" , « [[AsyncGeneratorState]], [[AsyncGeneratorContext]], [[AsyncGeneratorQueue]], [[GeneratorBrand]] »). - Set generator.[[GeneratorBrand]] to
empty . - Perform
AsyncGeneratorStart (generator,FunctionBody ). - Return
Completion Record { [[Type]]:return , [[Value]]: generator, [[Target]]:empty }.
15.6.3 Runtime Semantics: InstantiateAsyncGeneratorFunctionObject
The
- Let name be
StringValue ofBindingIdentifier . - Let sourceText be the
source text matched by AsyncGeneratorDeclaration . - Let F be
OrdinaryFunctionCreate (%AsyncGeneratorFunction.prototype% , sourceText,FormalParameters ,AsyncGeneratorBody ,non-lexical-this , env, privateEnv). - Perform
SetFunctionName (F, name). - Let prototype be
OrdinaryObjectCreate (%AsyncGeneratorFunction.prototype.prototype% ). - Perform !
DefinePropertyOrThrow (F,"prototype" , PropertyDescriptor { [[Value]]: prototype, [[Writable]]:true , [[Enumerable]]:false , [[Configurable]]:false }). - Return F.
- Let sourceText be the
source text matched by AsyncGeneratorDeclaration . - Let F be
OrdinaryFunctionCreate (%AsyncGeneratorFunction.prototype% , sourceText,FormalParameters ,AsyncGeneratorBody ,non-lexical-this , env, privateEnv). - Perform
SetFunctionName (F,"default" ). - Let prototype be
OrdinaryObjectCreate (%AsyncGeneratorFunction.prototype.prototype% ). - Perform !
DefinePropertyOrThrow (F,"prototype" , PropertyDescriptor { [[Value]]: prototype, [[Writable]]:true , [[Enumerable]]:false , [[Configurable]]:false }). - Return F.
An anonymous export default
declaration.
15.6.4 Runtime Semantics: InstantiateAsyncGeneratorFunctionExpression
The
- If name is not present, set name to
"" . - Let env be the LexicalEnvironment of the
running execution context . - Let privateEnv be the
running execution context 's PrivateEnvironment. - Let sourceText be the
source text matched by AsyncGeneratorExpression . - Let closure be
OrdinaryFunctionCreate (%AsyncGeneratorFunction.prototype% , sourceText,FormalParameters ,AsyncGeneratorBody ,non-lexical-this , env, privateEnv). - Perform
SetFunctionName (closure, name). - Let prototype be
OrdinaryObjectCreate (%AsyncGeneratorFunction.prototype.prototype% ). - Perform !
DefinePropertyOrThrow (closure,"prototype" , PropertyDescriptor { [[Value]]: prototype, [[Writable]]:true , [[Enumerable]]:false , [[Configurable]]:false }). - Return closure.
Assert : name is not present.- Set name to
StringValue ofBindingIdentifier . - Let outerEnv be the
running execution context 's LexicalEnvironment. - Let funcEnv be
NewDeclarativeEnvironment (outerEnv). - Perform ! funcEnv.CreateImmutableBinding(name,
false ). - Let privateEnv be the
running execution context 's PrivateEnvironment. - Let sourceText be the
source text matched by AsyncGeneratorExpression . - Let closure be
OrdinaryFunctionCreate (%AsyncGeneratorFunction.prototype% , sourceText,FormalParameters ,AsyncGeneratorBody ,non-lexical-this , funcEnv, privateEnv). - Perform
SetFunctionName (closure, name). - Let prototype be
OrdinaryObjectCreate (%AsyncGeneratorFunction.prototype.prototype% ). - Perform !
DefinePropertyOrThrow (closure,"prototype" , PropertyDescriptor { [[Value]]: prototype, [[Writable]]:true , [[Enumerable]]:false , [[Configurable]]:false }). - Perform ! funcEnv.InitializeBinding(name, closure).
- Return closure.
The