14.1 関数定義(Function Definitions)
構文:
14.1.1 ディレクティブプロローグと Use Strictディレクティブ
ディレクティブプロローグ
ディレクティブ(命令)プロローグは、FunctionBody、ScriptBody、ModuleBodyの最初のStatementListItemまたはModuleItemとして発生するExpressionStatementの最長シーケンスです。シーケンス内の各ExpressionStatementは完全なStringLiteralトークンとそれに続くセミコロンで構成されます。 セミコロンは明示的に記述される場合と、自動セミコロン挿入で挿入されることがあります。 ディレクティブプロローグは空のシーケンスである可能性があります。
Use Strictディレクティブ
Use Strictディレクティブは、StringLiteralが "use strict" または 'use strict' に正確に一致するコードポイントシーケンスであるディレクティブプロローグのExpressionStatementです。 Use Strictディレクティブには、EscapeSequenceまたはLineContinuation
を含めることはできません。
ディレクティブプロローグには、複数のUse Strictディレクティブが含まれることがあります。 ただし、実装は警告を発行する場合があります。
14.1.2 静的セマンティクス:早期エラー(Static Semantics: Early Errors)
- FormalParameters に一致するソースコードが strictモードコード なら、 UniqueFormalParameters : FormalParameters の早期エラールールが適用されます
- BindingIdentifier が存在し、 BindingIdentifier に一致するソースコードが strictモードコード のとき、 BindingIdentifier の StringValue が "eval" または "arguments" なら、構文エラー
- FunctionBody の ContainsUseStrict が true で、 FormalParameters の IsSimpleParameterList が false なら、構文エラー
- FormalParameters の BoundNames のいずれかの要素が、 FunctionBody の LexicallyDeclaredNames にもあるなら、構文エラー
- FormalParameters Contains SuperProperty が true なら、構文エラー
- FunctionBody Contains SuperProperty が true なら、構文エラー
- FormalParameters Contains SuperCall が true なら、構文エラー
- FunctionBody Contains SuperCall が true なら、構文エラー
- FormalParameters の BoundNames に重複する要素が含まれているなら、構文エラー
- FormalParameterList の IsSimpleParameterList が false で、FormalParameterList の BoundNames に重複する要素が含まれているなら、構文エラー
- FunctionStatementList の LexicallyDeclaredNames に重複する要素が含まれているなら、構文エラー
- FunctionStatementList の LexicallyDeclaredNames のいずれかの要素が、 FunctionStatementList の VarDeclaredNames にもあるなら、構文エラー
- 引数 « » を使用して FunctionStatementList の ContainsDuplicateLabels が true なら、構文エラー
- 引数 « » を使用して FunctionStatementList の ContainsUndefinedBreakTarget が true なら、構文エラー
- 引数 « » と « » を使用して FunctionStatementList の ContainsUndefinedContinueTarget が true なら、構文エラー
14.1.3 静的セマンティクス(Static Semantics): BoundNames
- BindingIdentifier の BoundNames を返す
- 空の新規List を返す
- FormalParameterList の BoundNames を names とする
- FunctionRestParameter の BoundNames を names に追加する
- names を返す
- FormalParameterList の BoundNames を names とする
- FormalParameter の BoundNames を names に追加する
- names を返す
14.1.4 静的セマンティクス(Static Semantics): Contains
引数 symbol を使用。
- false を返す
14.1.5 静的セマンティクス(Static Semantics): ContainsDuplicateLabels
引数 labelSet を使用。
- false を返す
14.1.6 静的セマンティクス(Static Semantics): ContainsExpression
- false を返す
- FormalParameterList の ContainsExpression が true なら、 true を返す
- FunctionRestParameter の ContainsExpression を返す
- FormalParameterList の ContainsExpression が true なら、 true を返す
- FormalParameter の ContainsExpression を返す
14.1.7 静的セマンティクス(Static Semantics): ContainsUndefinedBreakTarget
引数 labelSet を使用。
- false を返す
14.1.8 静的セマンティクス(Static Semantics): ContainsUndefinedContinueTarget
引数 iterationSet と labelSet を使用。
- false を返す
14.1.9 静的セマンティクス(Static Semantics): ContainsUseStrict
- FunctionBody の ディレクティブプロローグ に Use Strictディレクティブ が含まれているなら true を、含まれていないなら false を返す
14.1.10 静的セマンティクス(Static Semantics): ExpectedArgumentCount
- 0 を返す
- FormalParameterList の ExpectedArgumentCount を返す
- FormalParameter の HasInitializer が true なら、 0 を返す
- 1 を返す
- FormalParameterList の ExpectedArgumentCount を count とする
- FormalParameterList の HasInitializer が true または、 FormalParameter の HasInitializer が true なら count を返す
- count + 1 を返す
14.1.11 静的セマンティクス(Static Semantics): HasInitializer
- FormalParameterList の HasInitializer が true なら、 true を返す
- FormalParameter の HasInitializer を返す
14.1.12 静的セマンティクス(Static Semantics): HasName
- false を返す
- true を返す
14.1.13 静的セマンティクス(Static Semantics): IsAnonymousFunctionDefinition ( expr )
抽象操作IsAnonymousFunctionDefinitionは、exprが名前をバインドしない関数定義であるかどうかを判別します。 引数exprは、AssignmentExpressionまたはInitializerを解析した結果です。 次の手順が実行されます。
- expr の IsFunctionDefinition が false なら、 false を返す
- expr の HasName を hasName とする
- hasName が true なら、 false を返す
- true を返す
14.1.14 静的セマンティクス(Static Semantics): IsConstantDeclaration
- false を返す
14.1.15 静的セマンティクス(Static Semantics): IsFunctionDefinition
- true を返す
14.1.16 静的セマンティクス(Static Semantics): IsSimpleParameterList
- true を返す
- false を返す
- false を返す
- FormalParameterList の IsSimpleParameterList が false なら、 false を返す
- FormalParameter の IsSimpleParameterList を返す
- BindingElement の IsSimpleParameterList を返す
14.1.17 静的セマンティクス(Static Semantics): LexicallyDeclaredNames
- 空の新規List を返す
- StatementList の TopLevelLexicallyDeclaredNames を返す
14.1.18 静的セマンティクス(Static Semantics): LexicallyScopedDeclarations
- 空の新規List を返す
- StatementList の TopLevelLexicallyScopedDeclarations を返す
14.1.19 静的セマンティクス(Static Semantics): VarDeclaredNames
- 空の新規List を返す
- StatementList の TopLevelVarDeclaredNames を返す
14.1.20 静的セマンティクス(Static Semantics): VarScopedDeclarations
- 空の新規List を返す
- StatementList の TopLevelVarScopedDeclarations を返す
14.1.21 ランタイムセマンティクス(Runtime Semantics): EvaluateBody
引数 functionObject と argumentsList を使用。
- ? FunctionDeclarationInstantiation(functionObject, argumentsList) を実行する
- FunctionStatementList の 評価結果を返す
14.1.22 ランタイムセマンティクス(Runtime Semantics): IteratorBindingInitialization
引数 iteratorRecord と environment を使用。
- NormalCompletion(empty) を返す
- 引数 iteratorRecord と environment を使用して ? FormalParameterList の IteratorBindingInitialization を実行する
- 引数 iteratorRecord と environment を使用して FunctionRestParameter の IteratorBindingInitialization の実行結果を返す
- 引数 iteratorRecord と environment を使用して ? FormalParameterList の IteratorBindingInitialization を実行する
- 引数 iteratorRecord と environment を使用して FormalParameter の IteratorBindingInitialization の実行結果を返す
- 引数 iteratorRecord と environment を使用して BindingElement の IteratorBindingInitialization の実行結果を返す
- 引数 iteratorRecord と environment を使用して BindingRestElement の IteratorBindingInitialization の実行結果を返す
14.1.23 ランタイムセマンティクス(Runtime Semantics): InstantiateFunctionObject
引数 scope を使用。
- BindingIdentifier の StringValue を name とする
- OrdinaryFunctionCreate(%Function.prototype%, FormalParameters , FunctionBody , non-lexical-this, scope) を F とする
- MakeConstructor(F) を実行する
- SetFunctionName(F, name) を実行する
- FunctionDeclaration に一致するソーステキスト を F.[[SourceText]] にセットする
- F を返す
- OrdinaryFunctionCreate(%Function.prototype%, FormalParameters , FunctionBody , non-lexical-this, scope) を F とする
- MakeConstructor(F) を実行する
- SetFunctionName(F, "default") を実行する
- FunctionDeclaration に一致するソーステキスト を F.[[SourceText]] にセットする
- F を返す
14.1.24 ランタイムセマンティクス(Runtime Semantics): NamedEvaluation
引数 name を使用。
- FunctionExpression の評価結果を closure とする
- SetFunctionName(closure, name) を実行する
- closure を返す
14.1.25 ランタイムセマンティクス:評価(Runtime Semantics: Evaluation)
- NormalCompletion(empty) を返す
- NormalCompletion(empty) を返す
- 実行中の実行コンテキスト の LexicalEnvironment を scope とする
- OrdinaryFunctionCreate(%Function.prototype%, FormalParameters , FunctionBody , non-lexical-this, scope) を closure とする
- MakeConstructor(closure) を実行する
- FunctionExpression に一致するソーステキスト を closure.[[SourceText]] にセットする
- closure を返す
- 実行中の実行コンテキスト の LexicalEnvironment を scope とする
- NewDeclarativeEnvironment(scope) を funcEnv とする
- funcEnv の EnvironmentRecord を envRec とする
- BindingIdentifier の StringValue を name とする
- envRec.CreateImmutableBinding(name, false) を実行する
- OrdinaryFunctionCreate(%Function.prototype%, FormalParameters , FunctionBody , non-lexical-this, funcEnv) を closure とする
- MakeConstructor(closure) を実行する
- SetFunctionName(closure, name) を実行する
- FunctionExpression に一致するソーステキスト を closure.[[SourceText]] にセットする
- envRec.InitializeBinding(name, closure) を実行する
- closure を返す
- NormalCompletion(undefined) を返す
14.2 アロー関数定義(Arrow Function Definitions)
構文:
補足構文:
次のプロダクションのとき、
次の文法を使用して、CoverParenthesizedExpressionAndArrowParameterListの解釈を改善します。
14.2.1 静的セマンティクス:早期エラー(Static Semantics: Early Errors)
- ArrowParameters Contains YieldExpression が true なら、構文エラー
- ArrowParameters Contains AwaitExpression が true なら、構文エラー
- ConciseBody の ContainsUseStrict が true で、 ArrowParameters の IsSimpleParameterList が false なら、構文エラー
- ArrowParameters の BoundNames のいずれかの要素が、 ConciseBody の LexicallyDeclaredNames にもあるなら、構文エラー
- CoverParenthesizedExpressionAndArrowParameterList が ArrowFormalParameters をカバーしていないなら、構文エラー
- ArrowFormalParameters とその派生プロダクションの早期エラールールは CoverParenthesizedExpressionAndArrowParameterList の CoveredFormalsList にも適用されます。
14.2.2 静的セマンティクス(Static Semantics): BoundNames
- CoverParenthesizedExpressionAndArrowParameterList の CoveredFormalsList を formals とする
- formals の BoundNames を返す
14.2.3 静的セマンティクス(Static Semantics): Contains
引数 symbol を使用。
- symbol が NewTarget 、 SuperProperty 、 SuperCall 、 super 、 this のどれでもないなら、 false を返す
- ArrowParameters Contains symbol が true なら、 true を返す
- ConciseBody Contains symbol を返す
- CoverParenthesizedExpressionAndArrowParameterList の CoveredFormalsList を formals とする
- formals Contains symbol を返す
14.2.4 静的セマンティクス(Static Semantics): ContainsExpression
- false を返す
- CoverParenthesizedExpressionAndArrowParameterList の CoveredFormalsList を formals とする
- formals の ContainsExpression を返す
14.2.5 静的セマンティクス(Static Semantics): ContainsUseStrict
- false を返す
14.2.6 静的セマンティクス(Static Semantics): ExpectedArgumentCount
- 1 を返す
- CoverParenthesizedExpressionAndArrowParameterList の CoveredFormalsList を formals とする
- formals の ExpectedArgumentCount を返す
14.2.7 静的セマンティクス(Static Semantics): HasName
- false を返す
14.2.8 静的セマンティクス(Static Semantics): IsSimpleParameterList
- true を返す
- CoverParenthesizedExpressionAndArrowParameterList の CoveredFormalsList を formals とする
- formals の IsSimpleParameterList を返す
14.2.9 静的セマンティクス(Static Semantics): CoveredFormalsList
- ArrowParameters を返す
14.2.10 静的セマンティクス(Static Semantics): LexicallyDeclaredNames
- 空の新規List を返す
14.2.11 静的セマンティクス(Static Semantics): LexicallyScopedDeclarations
- 空の新規List を返す
14.2.12 静的セマンティクス(Static Semantics): VarDeclaredNames
- 空の新規List を返す
14.2.13 静的セマンティクス(Static Semantics): VarScopedDeclarations
- 空の新規List を返す
14.2.14 ランタイムセマンティクス(Runtime Semantics): IteratorBindingInitialization
引数 iteratorRecord と environment を使用。
- Assert: iteratorRecord.[[Done]] は false
- IteratorStep(iteratorRecord) を next とする
- next が 突然の完了 なら、 true を iteratorRecord.[[Done]] にセットする
- ReturnIfAbrupt(next)
- next が false なら、 true を iteratorRecord.[[Done]] にセットする
- 5. と異なるなら、
- IteratorValue(next) を v とする
- v が 突然の完了 なら、 true を iteratorRecord.[[Done]] にセットする
- ReturnIfAbrupt(v)
- iteratorRecord.[[Done]] が true なら、 undefined を v とする
- 引数 v と environment を使用して BindingIdentifier の BindingInitialization の実行結果を返す
- CoverParenthesizedExpressionAndArrowParameterList の CoveredFormalsList を formals とする
- 引数 iteratorRecord と environment を使用して formals の IteratorBindingInitialization の実行結果を返す
14.2.15 ランタイムセマンティクス(Runtime Semantics): EvaluateBody
引数 functionObject と argumentsList を使用。
- ? FunctionDeclarationInstantiation(functionObject, argumentsList) を実行する
- ExpressionBody の 評価結果を返す
14.2.16 ランタイムセマンティクス(Runtime Semantics): NamedEvaluation
引数 name を使用。
- ArrowFunction の評価結果を closure とする
- SetFunctionName(closure, name) を実行する
- closure を返す
14.2.17 ランタイムセマンティクス:評価(Runtime Semantics: Evaluation)
- 実行中の実行コンテキスト の LexicalEnvironment を scope とする
- ArrowParameters の CoveredFormalsList を parameters とする
- OrdinaryFunctionCreate(%Function.prototype%, parameters, ConciseBody , lexical-this, scope) を closure とする
- ArrowFunction に一致するソーステキスト を closure.[[SourceText]] にセットする
- closure を返す
- AssignmentExpression の評価結果を exprRef とする
- ? GetValue(exprRef) を exprValue とする
- Completion { [[Type]]: return, [[Value]]: exprValue, [[Target]]: empty } を返す
14.3 メソッド定義(Method Definitions)
構文:
14.3.1 静的セマンティクス:早期エラー(Static Semantics: Early Errors)
- FunctionBody の ContainsUseStrict が true で、 UniqueFormalParameters の IsSimpleParameterList が false なら、構文エラー
- UniqueFormalParameters の BoundNames のいずれかの要素が、 FunctionBody の LexicallyDeclaredNames にもあるなら、構文エラー
- PropertySetParameterList の BoundNames に重複する要素が含まれているなら、構文エラー
- FunctionBody の ContainsUseStrict が true で、 PropertySetParameterList の IsSimpleParameterList が false なら、構文エラー
- PropertySetParameterList の BoundNames のいずれかの要素が、 FunctionBody の LexicallyDeclaredNames にもあるなら、構文エラー
14.3.2 静的セマンティクス(Static Semantics): ComputedPropertyContains
引数 symbol を使用。
- 引数 symbol を使用して PropertyName の ComputedPropertyContains の結果を返す
14.3.3 静的セマンティクス(Static Semantics): ExpectedArgumentCount
- FormalParameter の HasInitializer が true なら、 0 を返す
- 1 を返す
14.3.4 静的セマンティクス(Static Semantics): HasDirectSuper
- UniqueFormalParameters Contains SuperCall が true なら、 true を返す
- FunctionBody Contains SuperCall を返す
- FunctionBody Contains SuperCall を返す
- PropertySetParameterList Contains SuperCall が true なら、 true を返す
- FunctionBody Contains SuperCall を返す
14.3.5 静的セマンティクス(Static Semantics): PropName
- PropertyName の PropName を返す
14.3.6 静的セマンティクス(Static Semantics): SpecialMethod
- false を返す
- true を返す
14.3.7 ランタイムセマンティクス(Runtime Semantics): DefineMethod
引数 object と オプション引数 functionPrototype を使用。
- PropertyName の評価結果を propKey とする
- ReturnIfAbrupt(propKey)
- 実行中の実行コンテキスト の LexicalEnvironment を scope とする
- functionPrototype が存在するなら、
- functionPrototype を prototype とする
- 4. と異なるなら、
- %Function.prototype% を prototype とする
- OrdinaryFunctionCreate(prototype, UniqueFormalParameters , FunctionBody , non-lexical-this, scope) を closure とする
- MakeMethod(closure, object) を実行する
- MethodDefinition に一致するソーステキスト を closure.[[SourceText]] にセットする
- Record { [[Key]]: propKey, [[Closure]]: closure } を返す
14.3.8 ランタイムセマンティクス(Runtime Semantics): PropertyDefinitionEvaluation
引数 object と enumerable を使用。
- 引数 object を使用して MethodDefinition の ? DefineMethod を methodDef とする
- SetFunctionName(methodDef.[[Closure]], methodDef.[[Key]]) を実行する
- PropertyDescriptor型 { [[Value]]: methodDef.[[Closure]], [[Writable]]: true, [[Enumerable]]: enumerable, [[Configurable]]: true } を desc とする
- ? DefinePropertyOrThrow(object, methodDef.[[Key]], desc) を返す
- PropertyName の評価結果を propKey とする
- ReturnIfAbrupt(propKey)
- 実行中の実行コンテキスト の LexicalEnvironment を scope とする
- プロダクション FormalParameters : [empty] のインスタンスを formalParameterList とする
- OrdinaryFunctionCreate(%Function.prototype%, formalParameterList, FunctionBody , non-lexical-this, scope) を closure とする
- MakeMethod(closure, object) を実行する
- SetFunctionName(closure, propKey, "get") を実行する
- MethodDefinition に一致するソーステキスト を closure.[[SourceText]] にセットする
- PropertyDescriptor型 { [[Get]]: closure, [[Enumerable]]: enumerable, [[Configurable]]: true } を desc とする
- ? DefinePropertyOrThrow(object, propKey, desc) を返す
- PropertyName の評価結果を propKey とする
- ReturnIfAbrupt(propKey)
- 実行中の実行コンテキスト の LexicalEnvironment を scope とする
- OrdinaryFunctionCreate(%Function.prototype%, PropertySetParameterList , FunctionBody , non-lexical-this, scope) を closure とする
- MakeMethod(closure, object) を実行する
- SetFunctionName(closure, propKey, "set") を実行する
- MethodDefinition に一致するソーステキスト を closure.[[SourceText]] にセットする
- PropertyDescriptor型 { [[Set]]: closure, [[Enumerable]]: enumerable, [[Configurable]]: true } を desc とする
- ? DefinePropertyOrThrow(object, propKey, desc) を返す
14.4 ジェネレーター関数定義(Generator Function Definitions)
構文:
14.4.1 静的セマンティクス:早期エラー(Static Semantics: Early Errors)
- GeneratorMethod の HasDirectSuper が true なら、構文エラー
- UniqueFormalParameters Contains YieldExpression が true なら、構文エラー
- GeneratorBody の ContainsUseStrict が true で、 UniqueFormalParameters の IsSimpleParameterList が false なら、構文エラー
- UniqueFormalParameters の BoundNames のいずれかの要素が、 GeneratorBody の LexicallyDeclaredNames にもあるなら、構文エラー
- FormalParameters に一致するソースコード が strictモードコード なら、 UniqueFormalParameters : FormalParameters の早期エラールールが適用されます
- If BindingIdentifier が存在し、 BindingIdentifier に一致するソースコードが strictモードコード で、 BindingIdentifier の StringValue が "eval" または "arguments" なら、構文エラー
- GeneratorBody の ContainsUseStrict が true で、 FormalParameters の IsSimpleParameterList が false なら、構文エラー
- FormalParameters の BoundNames のいずれかの要素が、 GeneratorBody の LexicallyDeclaredNames にもあるなら、構文エラー
- FormalParameters Contains YieldExpression が true なら、構文エラー
- FormalParameters Contains SuperProperty が true なら、構文エラー
- GeneratorBody Contains SuperProperty が true なら、構文エラー
- FormalParameters Contains SuperCall が true なら、構文エラー
- GeneratorBody Contains SuperCall が true なら、構文エラー
14.4.2 静的セマンティクス(Static Semantics): BoundNames
- BindingIdentifier の BoundNames を返す
14.4.3 静的セマンティクス(Static Semantics): ComputedPropertyContains
引数 symbol を使用。
- 引数 symbol を使用して PropertyName の ComputedPropertyContains の結果を返す
14.4.4 静的セマンティクス(Static Semantics): Contains
引数 symbol を使用。
- false を返す
14.4.5 静的セマンティクス(Static Semantics): HasDirectSuper
- UniqueFormalParameters Contains SuperCall が true なら、 true を返す
- GeneratorBody Contains SuperCall を返す
14.4.6 静的セマンティクス(Static Semantics): HasName
- false を返す
- true を返す
14.4.7 静的セマンティクス(Static Semantics): IsConstantDeclaration
- false を返す
14.4.8 静的セマンティクス(Static Semantics): IsFunctionDefinition
- true を返す
14.4.9 静的セマンティクス(Static Semantics): PropName
- PropertyName の PropName を返す
14.4.10 ランタイムセマンティクス(Runtime Semantics): EvaluateBody
引数 functionObject と argumentsList を使用。
- ? FunctionDeclarationInstantiation(functionObject, argumentsList) を実行する
- ? OrdinaryCreateFromConstructor(functionObject, "%Generator.prototype%", « [[GeneratorState]], [[GeneratorContext]] ») を G とする
- GeneratorStart(G, FunctionBody ) を実行する
- Completion { [[Type]]: return, [[Value]]: G, [[Target]]: empty } を返す
14.4.11 ランタイムセマンティクス(Runtime Semantics): InstantiateFunctionObject
引数 scope を使用。
- BindingIdentifier の StringValue を name とする
- OrdinaryFunctionCreate(%Generator%, FormalParameters , GeneratorBody , non-lexical-this, scope) を F とする
- OrdinaryObjectCreate(%Generator.prototype%) を prototype とする
- DefinePropertyOrThrow(F, "prototype",プロパティ記述子 { [[Value]]: prototype, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: false }) を実行する
- SetFunctionName(F, name) を実行する
- GeneratorDeclaration に一致するソーステキスト を F.[[SourceText]] にセットする
- F を返す
- OrdinaryFunctionCreate(%Generator% , FormalParameters , GeneratorBody , non-lexical-this, scope) を F とする
- OrdinaryObjectCreate(%Generator.prototype%) を prototype とする
- DefinePropertyOrThrow(F, "prototype",プロパティ記述子 { [[Value]]: prototype, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: false }) を実行する
- SetFunctionName(F, "default") を実行する
- GeneratorDeclaration に一致するソーステキスト を F.[[SourceText]] にセットする
- F を返す
14.4.12 ランタイムセマンティクス(Runtime Semantics): PropertyDefinitionEvaluation
引数 object と enumerable を使用。
- PropertyName の評価結果を propKey とする
- ReturnIfAbrupt(propKey)
- 実行中の実行コンテキスト の LexicalEnvironment を scope とする
- OrdinaryFunctionCreate( %Generator% , UniqueFormalParameters , GeneratorBody , non-lexical-this, scope) を closure とする
- MakeMethod(closure, object) を実行する
- OrdinaryObjectCreate(%Generator.prototype%) を prototype とする
- DefinePropertyOrThrow(closure, "prototype",プロパティ記述子 { [[Value]]: prototype, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: false }) を実行する
- SetFunctionName(closure, propKey) を実行する
- GeneratorMethod に一致するソーステキスト を closure.[[SourceText]] にセットする
- PropertyDescriptor型 { [[Value]]: closure, [[Writable]]: true, [[Enumerable]]: enumerable, [[Configurable]]: true } を desc とする
- ? DefinePropertyOrThrow(object, propKey, desc) を返す
14.4.13 ランタイムセマンティクス(Runtime Semantics): NamedEvaluation
引数 name を使用。
- GeneratorExpression の評価結果を closure とする
- SetFunctionName(closure, name) を実行する
- closure を返す
14.4.14 ランタイムセマンティクス:評価(Runtime Semantics: Evaluation)
- 実行中の実行コンテキスト の LexicalEnvironment を scope とする
- OrdinaryFunctionCreate( %Generator% , FormalParameters , GeneratorBody , non-lexical-this, scope) を closure とする
- OrdinaryObjectCreate(%Generator.prototype%) を prototype とする
- DefinePropertyOrThrow(closure, "prototype",プロパティ記述子 { [[Value]]: prototype, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: false }) を実行する
- GeneratorExpression に一致するソーステキスト を closure.[[SourceText]] にセットする
- closure を返す
- 実行中の実行コンテキスト の LexicalEnvironment を scope とする
- NewDeclarativeEnvironment(scope) を funcEnv とする
- funcEnv の EnvironmentRecord を envRec とする
- BindingIdentifier の StringValue を name とする
- envRec.CreateImmutableBinding(name, false) を実行する
- OrdinaryFunctionCreate( %Generator% , FormalParameters , GeneratorBody , non-lexical-this, funcEnv) を closure とする
- OrdinaryObjectCreate(%Generator.prototype%) を prototype とする
- DefinePropertyOrThrow(closure, "prototype",プロパティ記述子 { [[Value]]: prototype, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: false }) を実行する
- SetFunctionName(closure, name) を実行する
- envRec.InitializeBinding(name, closure) を実行する
- GeneratorExpression に一致するソーステキスト を closure.[[SourceText]] にセットする
- closure を返す
- ! GetGeneratorKind() を generatorKind とする
- generatorKind が async なら、 ? AsyncGeneratorYield(undefined) を返す
- ? GeneratorYield( CreateIterResultObject(undefined, false)) を返す
- ! GetGeneratorKind() を generatorKind とする
- AssignmentExpression の評価結果を exprRef とする
- ? GetValue(exprRef) を value とする
- generatorKind が async なら、 ? AsyncGeneratorYield(value) を返す
- ? GeneratorYield( CreateIterResultObject(value, false)) を返す
- ! GetGeneratorKind() を generatorKind とする
- AssignmentExpression の評価結果を exprRef とする
- ? GetValue(exprRef) を value とする
- ? GetIterator(value, generatorKind) を iteratorRecord とする
- iteratorRecord.[[Iterator]] を iterator とする
- NormalCompletion(undefined) を received とする
- 繰り返す、
- received.[[Type]] が normal なら、
- ? Call(iteratorRecord.[[NextMethod]], iteratorRecord.[[Iterator]], « received.[[Value]] ») を innerResult とする
- generatorKind が async なら、 ? Await(innerResult) を innerResult にセットする
- Type(innerResult) が Object型 でないなら、 TypeError例外をスローする
- ? IteratorComplete(innerResult) を done とする
- done が true なら、
- ? IteratorValue(innerResult) を返す
- generatorKind が async なら、 AsyncGeneratorYield(? IteratorValue(innerResult)) を received にセットする
- vi. と異なるなら、GeneratorYield(innerResult) を received にセットする
- a. と異なり、received.[[Type]] が throw なら、
- ? GetMethod(iterator, "throw") を throw とする
- throw が undefined でないなら、
- ? Call(throw, iterator, « received.[[Value]] ») を innerResult とする
- generatorKind が async なら、 ? Await(innerResult) を innerResult にセットする
- NOTE: 内部のイテレータのthrowメソッドからの例外が伝播される。 throwメソッドからの通常の完了は、内部のnextと同様に処理する
- Type(innerResult) が Object型 でないなら、 TypeError例外をスローする
- ? IteratorComplete(innerResult) を done とする
- done が true なら、
- ? IteratorValue(innerResult) を返す
- generatorKind が async なら、 AsyncGeneratorYield(? IteratorValue(innerResult)) を received にセットする
- 7. と異なるなら、 GeneratorYield(innerResult) を received にセットする
- ii. と異なるなら、
- NOTE: iterator にthrowメソッドがないなら、このthrowはyield *ループを終了する。 ただし、最初にiteratorをクリーンアップする必要がある。
- Completion { [[Type]]: normal, [[Value]]: empty, [[Target]]: empty } を closeCompletion とする
- generatorKind が async なら、 ? AsyncIteratorClose(iteratorRecord, closeCompletion) を実行する
- 3. と異なるなら、 ? IteratorClose(iteratorRecord, closeCompletion) を実行する
- NOTE: yield *プロトコル違反のため、TypeErrorをスローする。イテレーターにはthrowメソッドがない。
- TypeError例外をスローする
- b. と異なるなら、
- Assert: received.[[Type]] は return
- ? GetMethod(iterator, "return") を return とする
- return が undefined なら、
- generatorKind が async なら、 ? Await(received.[[Value]]) を received.[[Value]] にセットする
- Completion(received) を返す
- ? Call(return, iterator, « received.[[Value]] ») を innerReturnResult とする
- generatorKind が async なら、 ? Await(innerReturnResult) を innerReturnResult にセットする
- Type(innerReturnResult) が Object型 でないなら、 TypeError例外をスローする
- ? IteratorComplete(innerReturnResult) を done とする
- done が true なら、
- ? IteratorValue(innerReturnResult) を value とする
- Completion { [[Type]]: return, [[Value]]: value, [[Target]]: empty } を返す
- generatorKind が async なら、 AsyncGeneratorYield(? IteratorValue(innerReturnResult)) を received にセットする
- ix. と異なるなら、 GeneratorYield(innerReturnResult) を received にセットする
- received.[[Type]] が normal なら、
14.5 非同期ジェネレーター関数定義(Async Generator Function Definitions)
構文:
14.5.1 静的セマンティクス:早期エラー(Static Semantics: Early Errors)
- AsyncGeneratorMethod の HasDirectSuper が true なら、構文エラー
- UniqueFormalParameters Contains YieldExpression が true なら、構文エラー
- UniqueFormalParameters Contains AwaitExpression が true なら、構文エラー
- AsyncGeneratorBody の ContainsUseStrict が true で、 UniqueFormalParameters の IsSimpleParameterList が false なら、構文エラー
- UniqueFormalParameters の BoundNames のいずれかの要素が、 AsyncGeneratorBody の LexicallyDeclaredNames にもあるなら、構文エラー
- FormalParameters に一致する ソースコード が strictモードコード なら、 UniqueFormalParameters : FormalParameters の早期エラールールが適用されます
- BindingIdentifier が存在し、 BindingIdentifier に一致するソースコードが strictモードコード で、 BindingIdentifier の StringValue が "eval" か "arguments" なら、構文エラー
- AsyncGeneratorBody の ContainsUseStrict が true で、 FormalParameters の IsSimpleParameterList が false なら、構文エラー
- FormalParameters の BoundNames のいずれかの要素が、 AsyncGeneratorBody の LexicallyDeclaredNames にもあるなら、構文エラー
- FormalParameters Contains YieldExpression が true なら、構文エラー
- FormalParameters Contains AwaitExpression が true なら、構文エラー
- FormalParameters Contains SuperProperty が true なら、構文エラー
- AsyncGeneratorBody Contains SuperProperty が true なら、構文エラー
- FormalParameters Contains SuperCall が true なら、構文エラー
- AsyncGeneratorBody Contains SuperCall が true なら、構文エラー
14.5.2 静的セマンティクス(Static Semantics): BoundNames
- BindingIdentifier の the BoundNames を返す
14.5.3 静的セマンティクス(Static Semantics): ComputedPropertyContains
引数 symbol を使用。
- 引数 symbol を使用して PropertyName の ComputedPropertyContains の結果を返す
14.5.4 静的セマンティクス(Static Semantics): Contains
引数 symbol を使用。
- false を返す
14.5.5 静的セマンティクス(Static Semantics): HasDirectSuper
- UniqueFormalParameters Contains SuperCall が true なら、 true を返す
- AsyncGeneratorBody Contains SuperCall を返す
14.5.6 静的セマンティクス(Static Semantics): HasName
- false を返す
- true を返す
14.5.7 静的セマンティクス(Static Semantics): IsConstantDeclaration
- false を返す
14.5.8 静的セマンティクス(Static Semantics): IsFunctionDefinition
- true を返す
14.5.9 静的セマンティクス(Static Semantics): PropName
- PropertyName の PropName を返す
14.5.10 ランタイムセマンティクス(Runtime Semantics): EvaluateBody
引数 functionObject と argumentsList を使用。
- ? FunctionDeclarationInstantiation(functionObject, argumentsList) を実行する
- ? OrdinaryCreateFromConstructor(functionObject, "%AsyncGenerator.prototype%", « [[AsyncGeneratorState]], [[AsyncGeneratorContext]], [[AsyncGeneratorQueue]] ») を generator とする
- ! AsyncGeneratorStart(generator, FunctionBody ) を実行する
- Completion { [[Type]]: return, [[Value]]: generator, [[Target]]: empty } を返す
14.5.11 ランタイムセマンティクス(Runtime Semantics): InstantiateFunctionObject
引数 scope を使用。
- BindingIdentifier の StringValue を name とする
- ! OrdinaryFunctionCreate(%AsyncGenerator%, FormalParameters , AsyncGeneratorBody , non-lexical-this, scope) を F とする
- ! OrdinaryObjectCreate(%AsyncGenerator.prototype%) を prototype とする
- ! DefinePropertyOrThrow(F, "prototype",プロパティ記述子 { [[Value]]: prototype, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: false }) を実行する
- ! SetFunctionName(F, name) を実行する
- AsyncGeneratorDeclaration に一致するソーステキスト を F.[[SourceText]] にセットする
- F を返す
- OrdinaryFunctionCreate(%AsyncGenerator%, FormalParameters , AsyncGeneratorBody , non-lexical-this, scope) を F とする
- OrdinaryObjectCreate(%AsyncGenerator.prototype%) を prototype とする
- DefinePropertyOrThrow(F, "prototype",プロパティ記述子 { [[Value]]: prototype, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: false }) を実行する
- SetFunctionName(F, "default") を実行する
- AsyncGeneratorDeclaration に一致するソーステキスト を F.[[SourceText]] にセットする
- F を返す
14.5.12 ランタイムセマンティクス(Runtime Semantics): PropertyDefinitionEvaluation
引数 object と enumerable を使用。
- PropertyName の評価結果を propKey とする
- ReturnIfAbrupt(propKey)
- 実行中の実行コンテキスト の LexicalEnvironment を scope とする
- ! OrdinaryFunctionCreate( %AsyncGenerator% , UniqueFormalParameters , AsyncGeneratorBody , non-lexical-this, scope) を closure とする
- ! MakeMethod(closure, object) を実行する
- ! OrdinaryObjectCreate(%AsyncGenerator.prototype%) を prototype とする
- ! DefinePropertyOrThrow(closure, "prototype",プロパティ記述子 { [[Value]]: prototype, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: false }) を実行する
- ! SetFunctionName(closure, propKey) を実行する
- AsyncGeneratorMethod に一致するソーステキスト を closure.[[SourceText]] にセットする
- プロパティ記述子 { [[Value]]: closure, [[Writable]]: true, [[Enumerable]]: enumerable, [[Configurable]]: true } を desc とする
- ? DefinePropertyOrThrow(object, propKey, desc) を返す
14.5.13 ランタイムセマンティクス(Runtime Semantics): NamedEvaluation
引数 name を使用。
- AsyncGeneratorExpression の評価結果を closure とする
- SetFunctionName(closure, name) を実行する
- closure を返す
14.5.14 ランタイムセマンティクス:評価(Runtime Semantics: Evaluation)
- 実行中の実行コンテキスト の LexicalEnvironment を scope とする
- ! OrdinaryFunctionCreate( %AsyncGenerator% , FormalParameters , AsyncGeneratorBody , non-lexical-this, scope) を closure とする
- ! OrdinaryObjectCreate(%AsyncGenerator.prototype%) を prototype とする
- ! DefinePropertyOrThrow(closure, "prototype",プロパティ記述子 { [[Value]]: prototype, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: false }) を実行する
- AsyncGeneratorExpression に一致するソーステキスト を closure.[[SourceText]] にセットする
- closure を返す
- 実行中の実行コンテキスト の LexicalEnvironment を scope とする
- ! NewDeclarativeEnvironment(scope) を funcEnv とする
- funcEnv の EnvironmentRecord を envRec とする
- BindingIdentifier の StringValue を name とする
- ! envRec.CreateImmutableBinding(name, false) を実行する
- ! OrdinaryFunctionCreate( %AsyncGenerator% , FormalParameters , AsyncGeneratorBody , non-lexical-this, funcEnv) を closure とする
- ! OrdinaryObjectCreate(%AsyncGenerator.prototype%) を prototype とする
- ! DefinePropertyOrThrow(closure, "prototype",プロパティ記述子 { [[Value]]: prototype, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: false }) を実行する
- ! SetFunctionName(closure, name) を実行する
- ! envRec.InitializeBinding(name, closure) を実行する
- AsyncGeneratorExpression に一致するソーステキスト を closure.[[SourceText]] にセットする
- closure を返す
14.6 クラス定義(Class Definitions)
構文:
14.6.1 静的セマンティクス:早期エラー(Static Semantics: Early Errors)
- ClassHeritageが存在せず、次のアルゴリズムがtrueと評価された場合、構文エラーになります。
- ClassBody の ConstructorMethod を constructor とする
- constructor が empty なら、 false を返す
- constructor の HasDirectSuper を返す
- ClassElementList の PrototypePropertyNameList に複数の "constructor" が含まれている場合は構文エラ。
- MethodDefinition の PropName が "constructor" でなく、 MethodDefinition の HasDirectSuper が true なら、構文エラー
- MethodDefinition の PropName が "constructor" で、 MethodDefinition の SpecialMethod が true なら、構文エラー
- MethodDefinition の HasDirectSuper が true なら、構文エラー
- MethodDefinition の PropName が "prototype" なら、構文エラー
14.6.2 静的セマンティクス(Static Semantics): BoundNames
- BindingIdentifier の BoundNames を返す
14.6.3 静的セマンティクス(Static Semantics): ConstructorMethod
- ClassElement が ClassElement : ; なら、 empty を返す
- ClassElement の IsStatic が true なら、 empty を返す
- ClassElement の PropName が "constructor" でないなら、 empty を返す
- ClassElement を返す
- ClassElementList の ConstructorMethod を head とする
- head が empty でないなら、 head を返す
- ClassElement が ClassElement : ; なら、 empty を返す
- ClassElement の IsStatic が true なら、 empty を返す
- ClassElement の PropName が "constructor" でないなら、 empty を返す
- ClassElement を返す
14.6.4 静的セマンティクス(Static Semantics): Contains
引数 symbol を使用。
- symbol が ClassBody なら、 true を返す
- symbol が ClassHeritage なら、
- ClassHeritage が存在するなら true を、異なるなら false を返す
- ClassHeritage Contains symbol を inHeritage とする
- inHeritage が true なら、 true を返す
- 引数 symbol を使用して ClassBody の ComputedPropertyContains の結果を返す
14.6.5 静的セマンティクス(Static Semantics): ComputedPropertyContains
引数 symbol を使用。
- 引数 symbol を使用して ClassElementList の ComputedPropertyContains を inList とする
- inList が true なら、 true を返す
- 引数 symbol を使用して ClassElement の ComputedPropertyContains の結果を返す
- false を返す
14.6.6 静的セマンティクス(Static Semantics): HasName
- false を返す
- true を返す
14.6.7 静的セマンティクス(Static Semantics): IsConstantDeclaration
- false を返す
14.6.8 静的セマンティクス(Static Semantics): IsFunctionDefinition
- true を返す
14.6.9 静的セマンティクス(Static Semantics): IsStatic
- false を返す
- true を返す
- false を返す
14.6.10 静的セマンティクス(Static Semantics): NonConstructorMethodDefinitions
- ClassElement がClassElement : ; なら、 空の新規List を返す
- ClassElement の IsStatic が false で ClassElement の PropName が "constructor" なら、 空の新規List を返す
- ClassElement を含む List を返す
- ClassElementList の NonConstructorMethodDefinitions を list とする
- ClassElement が ClassElement : ; なら、 list を返す
- ClassElement の IsStatic が false で ClassElement の PropName が "constructor" なら、 list を返す
- list の最後に ClassElement を追加する
- list を返す
14.6.11 静的セマンティクス(Static Semantics): PrototypePropertyNameList
- ClassElement の PropName が empty なら、 空の新規List を返す
- ClassElement の IsStatic が true なら、 空の新規List を返す
- ClassElement の PropName を含む Listを返す
- ClassElementList の PrototypePropertyNameList を list とする
- ClassElement の PropName が empty なら、 list を返す
- ClassElement の IsStatic が true なら、 list を返す
- list の最後に ClassElement の PropName を追加する
- list を返す
14.6.12 静的セマンティクス(Static Semantics): PropName
- empty を返す
14.6.13 ランタイムセマンティクス(Runtime Semantics): ClassDefinitionEvaluation
引数 classBinding と className を使用。
- 実行中の実行コンテキスト の LexicalEnvironment を lex とする
- NewDeclarativeEnvironment(lex) を classScope とする
- classScope の EnvironmentRecord を classScopeEnvRec とする
- classBinding が undefined でないなら、
- classScopeEnvRec.CreateImmutableBinding(classBinding, true) を実行する
- ClassHeritageopt が 存在しないなら、
- %Object.prototype% を protoParent とする
- %Function.prototype% を constructorParent とする
- 5. と異なるなら、
- classScope を 実行中の実行コンテキスト の LexicalEnvironment にセットする
- ClassHeritage の評価結果を superclassRef とする
- lex を 実行中の実行コンテキスト の LexicalEnvironment にセットする
- ? GetValue(superclassRef) を superclass とする
- superclass が null なら、
- null を protoParent とする
- %Function.prototype% を constructorParent とする
- e. と異なるなり、 IsConstructor(superclass) が false なら、 TypeError例外をスローする
- f. と異なるなら、
- OrdinaryObjectCreate(protoParent) を proto とする
- ClassBodyopt が 存在しないなら、 empty を constructor とする
- 8. と異なるなら、 ClassBody の ConstructorMethod を constructor とする
- constructor が empty なら、
- ClassHeritageopt が 存在するなら、
- 次のソーステキストを解析した結果を constructor にセットする
constructor(...args) { super(...args); }
※ゴールシンボル MethodDefinition[~Yield, ~Await] を使用
- 次のソーステキストを解析した結果を constructor にセットする
- a. と異なるなら、
- 次のソーステキストを解析した結果を constructor にセットする
constructor() {}
※ゴールシンボル MethodDefinition[~Yield, ~Await] を使用
- 次のソーステキストを解析した結果を constructor にセットする
- ClassHeritageopt が 存在するなら、
- classScope を 実行中の実行コンテキスト の LexicalEnvironment にセットする
- 引数 proto と constructorParent を使用して constructor の ! DefineMethod を constructorInfo とする
- constructorInfo.[[Closure]] を F とする
- MakeConstructor(F, false, proto) を実行する
- ClassHeritageopt が 存在するなら、 derived を F.[[ConstructorKind]] にセットする
- MakeClassConstructor(F) を実行する
- className が undefined でないなら、
- SetFunctionName(F, className) を実行する
- CreateMethodProperty(proto, "constructor", F) を実行する
- ClassBodyopt が 存在しないなら、 空の新規List を methods とする
- 19. と異なるなら、 ClassBody の NonConstructorMethodDefinitions を methods とする
- methods から順番に 各 ClassElement を m とし、 m ごとに次を実行する
- m の IsStatic が false なら、
- 引数 proto と false を使用して m の PropertyDefinitionEvaluation を status とする
- a. と異なるなら、
- 引数 F と false を使用して m の PropertyDefinitionEvaluation を status とする
- status が 突然の完了 なら、
- lex を 実行中の実行コンテキスト の LexicalEnvironment にセットする
- Completion(status) を返す
- m の IsStatic が false なら、
- lex を 実行中の実行コンテキスト の LexicalEnvironment にセットする
- classBinding が undefined でないなら、
- classScopeEnvRec.InitializeBinding(classBinding, F) を実行する
- F を返す
14.6.14 ランタイムセマンティクス(Runtime Semantics): BindingClassDeclarationEvaluation
- BindingIdentifier の StringValue を className とする
- 引数 className と className を使用して ClassTail の ? ClassDefinitionEvaluation を value とする
- ClassDeclaration に一致するソーステキスト を value.[[SourceText]] にセットする
- 実行中の実行コンテキスト の LexicalEnvironment を env とする
- ? InitializeBoundName(className, value, env) を実行する
- value を返す
- 引数 undefined と "default" を使用して ClassTail の ? ClassDefinitionEvaluation を value とする
- ClassDeclaration に一致するソーステキスト を value.[[SourceText]] にセットする
- value を返す
14.6.15 ランタイムセマンティクス(Runtime Semantics): NamedEvaluation
引数 name を使用。
- 引数 undefined と name を使用して ClassTail の ClassDefinitionEvaluation の結果 を value とする
- ReturnIfAbrupt(value)
- ClassExpression に一致するソーステキスト を value.[[SourceText]] にセットする
- value を返す
14.6.16 ランタイムセマンティクス:評価(Runtime Semantics: Evaluation)
- ? ClassDeclaration の BindingClassDeclarationEvaluation を実行する
- NormalCompletion(empty) を返す
- BindingIdentifieropt が 存在しないなら、 undefined を className とする
- 3. と異なるなら、 BindingIdentifier の StringValue を className とする
- 引数 className と className を使用して ClassTail の ? ClassDefinitionEvaluation を value とする
- ClassExpression に一致するソーステキスト を value.[[SourceText]] にセットする
- value を返す
14.7 非同期関数定義(Async Function Definitions)
構文:
- AsyncFunctionBody 内
- AsyncFunctionDeclaration、AsyncFunctionExpression、AsyncGeneratorDeclaration、またはAsyncGeneratorExpressionのFormalParameters内。 この位置のAwaitExpressionは、静的セマンティクスによる構文エラーです。
Moduleが構文上のゴールシンボルで、[Await]パラメーターが存在しない場合、awaitはキーワードとして解析され、その結果構文エラーになります。ゴールシンボルがScriptで、[Await]パラメーターがない場合、awaitは識別子として解析される可能性があります。 これには、次のコンテキストが含まれます。
14.7.1 静的セマンティクス:早期エラー(Static Semantics: Early Errors)
- AsyncFunctionBody の ContainsUseStrict が true で、 UniqueFormalParameters の IsSimpleParameterList が false なら、構文エラー
- AsyncMethod の HasDirectSuper が true なら、構文エラー
- UniqueFormalParameters Contains AwaitExpression が true なら、構文エラー
- UniqueFormalParameters の BoundNames のいずれかの要素が、 AsyncFunctionBody の LexicallyDeclaredNames にもあるなら、構文エラー
- AsyncFunctionBody の ContainsUseStrict が true で、 FormalParameters の IsSimpleParameterList が false なら、構文エラー
- FormalParameters Contains AwaitExpression が true なら、構文エラー
- FormalParameters に一致する ソースコード が strictモードコード なら、 UniqueFormalParameters : FormalParameters の早期エラールールが適用されます
- BindingIdentifier が存在し、 BindingIdentifier に一致するソースコードが strictモードコード で、 BindingIdentifier の StringValue が "eval" か "arguments" なら、構文エラー
- FormalParameters の BoundNames のいずれかの要素が、 AsyncFunctionBody の LexicallyDeclaredNames にもあるなら、構文エラー
- FormalParameters Contains SuperProperty が true なら、構文エラー
- AsyncFunctionBody Contains SuperProperty が true なら、構文エラー
- FormalParameters Contains SuperCall が true なら、構文エラー
- AsyncFunctionBody Contains SuperCall が true なら、構文エラー
14.7.2 静的セマンティクス(Static Semantics): BoundNames
- BindingIdentifier の the BoundNames を返す
14.7.3 静的セマンティクス(Static Semantics): ComputedPropertyContains
引数 symbol を使用。
- 引数 symbol を使用して PropertyName の ComputedPropertyContains の結果を返す
14.7.4 静的セマンティクス(Static Semantics): Contains
引数 symbol を使用。
- false を返す
14.7.5 静的セマンティクス(Static Semantics): HasDirectSuper
- UniqueFormalParameters Contains SuperCall が true なら、 true を返す
- AsyncFunctionBody Contains SuperCall を返す
14.7.6 静的セマンティクス(Static Semantics): HasName
- false を返す
- true を返す
14.7.7 静的セマンティクス(Static Semantics): IsConstantDeclaration
- false を返す
14.7.8 静的セマンティクス(Static Semantics): IsFunctionDefinition
- true を返す
14.7.9 静的セマンティクス(Static Semantics): PropName
- PropertyName の PropName を返す
14.7.10 ランタイムセマンティクス(Runtime Semantics): InstantiateFunctionObject
引数 scope を使用。
- BindingIdentifier の StringValue を name とする
- ! OrdinaryFunctionCreate(%AsyncFunction.prototype%, FormalParameters , AsyncFunctionBody , non-lexical-this, scope) を F とする
- ! SetFunctionName(F, name) を実行する
- AsyncFunctionDeclaration に一致するソーステキスト を F.[[SourceText]] にセットする
- F を返す
- ! OrdinaryFunctionCreate(%AsyncFunction.prototype%, FormalParameters , AsyncFunctionBody , non-lexical-this, scope) を F とする
- ! SetFunctionName(F, "default") を実行する
- AsyncFunctionDeclaration に一致するソーステキスト を F.[[SourceText]] にセットする
- F を返す
14.7.11 ランタイムセマンティクス(Runtime Semantics): EvaluateBody
引数 functionObject と argumentsList を使用。
- ! NewPromiseCapability(%Promise%) を promiseCapability とする
- FunctionDeclarationInstantiation(functionObject, argumentsList) を declResult とする
- declResult が 突然の完了 でないなら、
- ! AsyncFunctionStart(promiseCapability, FunctionBody ) を実行する
- 3. と異なるなら、
- Completion { [[Type]]: return, [[Value]]: promiseCapability.[[Promise]], [[Target]]: empty } を返す
14.7.12 ランタイムセマンティクス(Runtime Semantics): PropertyDefinitionEvaluation
引数 object と enumerable を使用。
- PropertyName の評価結果を propKey とする
- ReturnIfAbrupt(propKey)
- 実行中の実行コンテキスト の LexicalEnvironment を scope とする
- ! OrdinaryFunctionCreate(%AsyncFunction.prototype%, UniqueFormalParameters , AsyncFunctionBody , non-lexical-this, scope) を closure とする
- ! MakeMethod(closure, object) を実行する
- ! SetFunctionName(closure, propKey) を実行する
- AsyncMethod に一致するソーステキスト を closure.[[SourceText]] にセットする
- PropertyDescriptor型 { [[Value]]: closure, [[Writable]]: true, [[Enumerable]]: enumerable, [[Configurable]]: true } を desc とする
- ? DefinePropertyOrThrow(object, propKey, desc) を返す
14.7.13 ランタイムセマンティクス(Runtime Semantics): NamedEvaluation
引数 name を使用。
- AsyncFunctionExpression の評価結果を closure とする
- SetFunctionName(closure, name) を実行する
- closure を返す
14.7.14 ランタイムセマンティクス:評価(Runtime Semantics: Evaluation)
- NormalCompletion(empty) を返す
- NormalCompletion(empty) を返す
- 実行中の実行コンテキスト の LexicalEnvironment を scope とする
- ! OrdinaryFunctionCreate(%AsyncFunction.prototype%, FormalParameters , AsyncFunctionBody , non-lexical-this, scope) を closure とする
- AsyncFunctionExpression に一致するソーステキスト を closure.[[SourceText]] にセットする
- closure を返す
- 実行中の実行コンテキスト の LexicalEnvironment を scope とする
- ! NewDeclarativeEnvironment(scope) を funcEnv とする
- funcEnv の EnvironmentRecord を envRec とする
- BindingIdentifier の StringValue を name とする
- ! envRec.CreateImmutableBinding(name, false) を実行する
- ! OrdinaryFunctionCreate(%AsyncFunction.prototype%, FormalParameters , AsyncFunctionBody , non-lexical-this, funcEnv) を closure とする
- ! SetFunctionName(closure, name) を実行する
- ! envRec.InitializeBinding(name, closure) を実行する
- AsyncFunctionExpression に一致するソーステキスト を closure.[[SourceText]] にセットする
- closure を返す
- UnaryExpression の評価結果を exprRef とする
- ? GetValue(exprRef) を value とする
- ? Await(value) を返す
14.8 非同期アロー関数の定義(Async Arrow Function Definitions)
構文:
補足構文:
次のプロダクションのインスタンスを処理するとき
CoverCallExpressionAndAsyncArrowHeadの解釈は、次の文法で改善されます。
14.8.1 静的セマンティクス:早期エラー(Static Semantics: Early Errors)
- AsyncArrowBindingIdentifier の BoundNames のいずれかの要素が、 AsyncConciseBody の LexicallyDeclaredNames にもあるなら、構文エラー
- CoverCallExpressionAndAsyncArrowHead Contains YieldExpression が true なら、構文エラー
- CoverCallExpressionAndAsyncArrowHead Contains AwaitExpression が true なら、構文エラー
- CoverCallExpressionAndAsyncArrowHead が AsyncArrowHead をカバーしていないなら、構文エラー
- CoverCallExpressionAndAsyncArrowHead の BoundNames のいずれかの要素が、 AsyncConciseBody の LexicallyDeclaredNames にもあるなら、構文エラー
- AsyncConciseBody の ContainsUseStrict が true で、 CoverCallExpressionAndAsyncArrowHead の IsSimpleParameterList が false なら、構文エラー
- AsyncArrowHeadとその派生プロダクションのすべての早期エラールールは、CoverCallExpressionAndAsyncArrowHeadのCoveredAsyncArrowHeadに適用されます。
14.8.2 静的セマンティクス(Static Semantics): CoveredAsyncArrowHead
- CoverCallExpressionAndAsyncArrowHead によってカバーされている AsyncArrowHead を返す
14.8.3 静的セマンティクス(Static Semantics): BoundNames
- CoverCallExpressionAndAsyncArrowHead の CoveredAsyncArrowHead を head とする
- head の BoundNames を返す
14.8.4 静的セマンティクス(Static Semantics): Contains
引数 symbol を使用。
- symbol が NewTarget 、SuperProperty 、 SuperCall、 super、 this のどれかでないなら、 false を返す
- AsyncConciseBody Contains symbol を返す
- symbol が NewTarget 、 SuperProperty 、 SuperCall 、 super 、 this のどれかでないなら、 false を返す
- CoverCallExpressionAndAsyncArrowHead の CoveredAsyncArrowHead を head とする
- head Contains symbol が true なら、 true を返す
- AsyncConciseBody Contains symbol を返す
14.8.5 静的セマンティクス(Static Semantics): ContainsExpression
- false を返す
14.8.6 静的セマンティクス(Static Semantics): ContainsUseStrict
- false を返す
14.8.7 静的セマンティクス(Static Semantics): ExpectedArgumentCount
- 1 を返す
14.8.8 静的セマンティクス(Static Semantics): HasName
- false を返す
14.8.9 静的セマンティクス(Static Semantics): IsSimpleParameterList
- true を返す
- CoverCallExpressionAndAsyncArrowHead の CoveredAsyncArrowHead を head とする
- head の IsSimpleParameterList を返す
14.8.10 静的セマンティクス(Static Semantics): LexicallyDeclaredNames
- 空の新規List を返す
14.8.11 静的セマンティクス(Static Semantics): LexicallyScopedDeclarations
- 空の新規List を返す
14.8.12 静的セマンティクス(Static Semantics): VarDeclaredNames
- 空の新規List を返す
14.8.13 静的セマンティクス(Static Semantics): VarScopedDeclarations
- 空の新規List を返す
14.8.14 ランタイムセマンティクス(Runtime Semantics): IteratorBindingInitialization
引数 iteratorRecord と environment を使用。
- Assert: iteratorRecord.[[Done]] は false
- IteratorStep(iteratorRecord) を next とする
- next が 突然の完了 なら、 true を iteratorRecord.[[Done]] にセットする
- ReturnIfAbrupt(next)
- next が false なら、 true を iteratorRecord.[[Done]] にセットする
- 5. と異なるなら、
- IteratorValue(next) を v とする
- v が 突然の完了 なら、 true を iteratorRecord.[[Done]] にセットする
- ReturnIfAbrupt(v)
- iteratorRecord.[[Done]] が true なら、 undefined を v とする
- 引数 v と environment を使用して BindingIdentifier の BindingInitialization の実行結果を返す
14.8.15 ランタイムセマンティクス(Runtime Semantics): EvaluateBody
引数 functionObject と argumentsList を使用。
- ! NewPromiseCapability(%Promise%) を promiseCapability とする
- FunctionDeclarationInstantiation(functionObject, argumentsList) を declResult とする
- declResult が 突然の完了 でないなら、
- ! AsyncFunctionStart(promiseCapability, ExpressionBody ) を実行する
- 3. と異なるなら、
- Completion { [[Type]]: return, [[Value]]: promiseCapability.[[Promise]], [[Target]]: empty } を返す
14.8.16 ランタイムセマンティクス(Runtime Semantics): NamedEvaluation
引数 name を使用。
- AsyncArrowFunction の評価結果を closure とする
- SetFunctionName(closure, name) を実行する
- closure を返す
14.8.17 ランタイムセマンティクス:評価(Runtime Semantics: Evaluation)
- 実行中の実行コンテキスト の the LexicalEnvironment を scope とする
- AsyncArrowBindingIdentifier を parameters とする
- ! OrdinaryFunctionCreate(%AsyncFunction.prototype%, parameters, AsyncConciseBody , lexical-this, scope) を closure とする
- AsyncArrowFunction に一致するソーステキスト を closure.[[SourceText]] にセットする
- closure を返す
- 実行中の実行コンテキスト の LexicalEnvironment を scope とする
- CoverCallExpressionAndAsyncArrowHead の CoveredAsyncArrowHead を head とする
- head の ArrowFormalParameters を parameters とする
- ! OrdinaryFunctionCreate(%AsyncFunction.prototype%, parameters, AsyncConciseBody , lexical-this, scope) を closure とする
- AsyncArrowFunction に一致するソーステキスト を closure.[[SourceText]] にセットする
- closure を返す
14.9 末尾呼び出し(Tail Position Calls)
14.9.1 静的セマンティクス(Static Semantics): IsInTailPosition ( call )
引数callを伴う抽象操作IsInTailPositionは、次の手順を実行します。
- Assert: call は パースノード
- call に一致するソースコードが 非strictコード なら、 false を返す
- call が FunctionBody 、 ConciseBody 、 AsyncConciseBody に含まれていないなら、 false を返す
- FunctionBody、ConciseBody、 AsyncConciseBody のうち、call が一番密接に含まれているものを body とする
- body が GeneratorBody の FunctionBody なら、 false を返す
- body が AsyncFunctionBody の FunctionBody なら、 false を返す
- body が AsyncGeneratorBody の FunctionBody なら、 false を返す
- body が AsyncConciseBody なら、 false を返す
- 引数 call を使用して body の HasCallInTailPosition の結果を返す
14.9.2 静的セマンティクス(Static Semantics): HasCallInTailPosition
引数 call を使用。
14.9.2.1 ステートメントルール(Statement Rules)
- 引数 call を使用して StatementList の HasCallInTailPosition を has とする
- has が true なら、 true を返す
- 引数 call を使用して StatementListItem の HasCallInTailPosition の実行結果を返す
- false を返す
- 引数 call を使用して Statement の HasCallInTailPosition の実行結果を返す
- 引数 call を使用して LabelledItem の HasCallInTailPosition の実行結果を返す
- 引数 call を使用して Expression の HasCallInTailPosition の実行結果を返す
- 引数 call を使用して CaseBlock の HasCallInTailPosition の実行結果を返す
- false を has とする
- 最初の CaseClauses が存在するなら、 引数 call を使用して、最初の CaseClauses の HasCallInTailPosition を has とする
- has が true なら、 true を返す
- 引数 call を使用して DefaultClause の HasCallInTailPosition を has とする
- has が true なら、 true を返す
- 2番目の CaseClauses が 存在するなら、 引数 call を使用して、2番目の CaseClauses の HasCallInTailPosition を has とする
- has を返す
- 引数 call を使用して CaseClauses の HasCallInTailPosition を has とする
- has が true なら、 true を返す
- 引数 call を使用して CaseClause の HasCallInTailPosition の実行結果を返す
- StatementList が存在するなら、 引数 call を使用して StatementList の HasCallInTailPosition の実行結果を返す
- false を返す
- 引数 call を使用して Catch の HasCallInTailPosition の実行結果を返す
- 引数 call を使用して Finally の HasCallInTailPosition の実行結果を返す
- 引数 call を使用して Block の HasCallInTailPosition の実行結果を返す
14.9.2.2 表示規則(Expression Rules)
- false を返す
- 引数 call を使用して AssignmentExpression の HasCallInTailPosition の実行結果を返す
- 引数 call を使用して 最初の AssignmentExpression の HasCallInTailPosition を has とする
- has が true なら、 true を返す
- 引数 call を使用して 2番目の AssignmentExpression の HasCallInTailPosition の実行結果を返す
- 引数 call を使用して BitwiseORExpression の HasCallInTailPosition の実行結果を返す
- 引数 call を使用して LogicalANDExpression の HasCallInTailPosition の実行結果を返す
- 引数 call を使用して BitwiseORExpression の HasCallInTailPosition の実行結果を返す
- CallExpression が call なら、 true を返す
- false を返す
- 引数 call を使用して OptionalChain の HasCallInTailPosition の実行結果を返す
- false を返す
- OptionalChain が call なら、 true を返す
- false を返す
- MemberExpression が call なら、 true を返す
- false を返す
- CoverParenthesizedExpressionAndArrowParameterList の CoveredParenthesizedExpression を expr とする
- 引数 call を使用して expr の HasCallInTailPosition の実行結果を返す
- 引数 call を使用して Expression の HasCallInTailPosition の実行結果を返す
14.9.3 ランタイムセマンティクス(Runtime Semantics): PrepareForTailCall ( )
抽象操作PrepareForTailCallは、次の手順を実行します。
- 実行中の実行コンテキスト を leafContext とする
- Suspend leafContext
- 実行コンテキストスタック から leafContext をポップする。 スタックの最上位にある 実行コンテキスト が 実行中の実行コンテキスト になる
- Assert: leafContext はこれ以上使用されない。実行中の実行コンテキストとしてアクティブ化されることはない
末尾呼び出しは、ターゲット関数を呼び出す前に、現在実行中の関数実行コンテキスト に関連付けられている一時的な内部リソースを解放するか、ターゲット関数をサポートするためにそれらのリソースを再利用する必要があります。leafContextはそれ以上使用できません。 実行中の実行コンテキストとしてアクティブ化されることはありません。