14 ECMAScript Language: Statements and Declarations

Syntax

Statement[Yield, Await, Return] : BlockStatement[?Yield, ?Await, ?Return] VariableStatement[?Yield, ?Await] EmptyStatement ExpressionStatement[?Yield, ?Await] IfStatement[?Yield, ?Await, ?Return] BreakableStatement[?Yield, ?Await, ?Return] ContinueStatement[?Yield, ?Await] BreakStatement[?Yield, ?Await] [+Return] ReturnStatement[?Yield, ?Await] WithStatement[?Yield, ?Await, ?Return] LabelledStatement[?Yield, ?Await, ?Return] ThrowStatement[?Yield, ?Await] TryStatement[?Yield, ?Await, ?Return] DebuggerStatement Declaration[Yield, Await] : HoistableDeclaration[?Yield, ?Await, ~Default] ClassDeclaration[?Yield, ?Await, ~Default] LexicalDeclaration[+In, ?Yield, ?Await] HoistableDeclaration[Yield, Await, Default] : FunctionDeclaration[?Yield, ?Await, ?Default] GeneratorDeclaration[?Yield, ?Await, ?Default] AsyncFunctionDeclaration[?Yield, ?Await, ?Default] AsyncGeneratorDeclaration[?Yield, ?Await, ?Default] BreakableStatement[Yield, Await, Return] : IterationStatement[?Yield, ?Await, ?Return] SwitchStatement[?Yield, ?Await, ?Return]

14.1 Statement Semantics

14.1.1 Runtime Semantics: Evaluation

HoistableDeclaration : GeneratorDeclaration AsyncFunctionDeclaration AsyncGeneratorDeclaration
  1. emptyを返す。
HoistableDeclaration : FunctionDeclaration
  1. FunctionDeclarationの ? Evaluationを返す。
BreakableStatement : IterationStatement SwitchStatement
  1. newLabelSetを新しい空のListとする。
  2. 引数newLabelSetを伴うthis BreakableStatementの ? LabelledEvaluationを返す。

14.2 Block

Syntax

BlockStatement[Yield, Await, Return] : Block[?Yield, ?Await, ?Return] Block[Yield, Await, Return] : { StatementList[?Yield, ?Await, ?Return]opt } StatementList[Yield, Await, Return] : StatementListItem[?Yield, ?Await, ?Return] StatementList[?Yield, ?Await, ?Return] StatementListItem[?Yield, ?Await, ?Return] StatementListItem[Yield, Await, Return] : Statement[?Yield, ?Await, ?Return] Declaration[?Yield, ?Await]

14.2.1 Static Semantics: Early Errors

Block : { StatementList }

14.2.2 Runtime Semantics: Evaluation

Block : { }
  1. emptyを返す。
Block : { StatementList }
  1. oldEnv を、実行中の実行コンテキストの LexicalEnvironment とする。
  2. blockEnvNewDeclarativeEnvironment(oldEnv) とする。
  3. BlockDeclarationInstantiation(StatementList, blockEnv) を実行する。
  4. 実行中の実行コンテキストの LexicalEnvironment を blockEnv に設定する。
  5. blockValueStatementListEvaluationCompletion とする。
  6. blockValueCompletion(DisposeResources(blockEnv.[[DisposableResourceStack]], blockValue)) に設定する。
  7. 実行中の実行コンテキストの LexicalEnvironment を oldEnv に設定する。
  8. Return ? blockValue.
Note 1

controlがどのようにBlockから離れても、LexicalEnvironmentは常に以前のstateへ復元されます。

StatementList : StatementList StatementListItem
  1. slStatementListの ? Evaluationとする。
  2. sStatementListItemEvaluationCompletionとする。
  3. UpdateEmpty(s, sl)を返す。
Note 2

StatementListの値は、StatementList内で値を生成する最後のitemの値です。例えば、次のeval functionへのcallsはすべて値1を返します:

eval("1;;;;;")
eval("1;{}")
eval("1;var a;")

14.2.3 BlockDeclarationInstantiation ( code, envRecord )

The abstract operation BlockDeclarationInstantiation takes arguments code (a Parse Node) and envRecord (a Declarative Environment Record) and returns unused. codeはblockのbodyに対応するParse Nodeです。envRecordはbindingsが作成されるEnvironment Recordです。

Note

BlockまたはCaseBlockが評価されるとき、新しいDeclarative Environment Recordが作成され、block内でdeclaredされた各block scoped variable、constant、function、またはclassに対するbindingsがEnvironment Record内でinstantiatedされます。

これは呼び出されたとき、次のstepsを実行します:

  1. codeLexicallyScopedDeclarationsdeclsとする。
  2. 実行中の実行コンテキストのPrivateEnvironmentをprivateEnvとする。
  3. declsの各要素declについて、次を行う。
    1. declBoundNamesの各要素nameについて、次を行う。
      1. declIsConstantDeclarationtrueである場合、
        1. envRecord.CreateImmutableBinding(name, true)を実行する。
      2. そうでなければ、
        1. ホストがWebブラウザである、またはその他の形でBlock-Level Function Declarations Web Legacy Compatibility Semanticsをサポートする場合、
          1. envRecord.HasBinding(name)がfalseである場合、
            1. envRecord.CreateMutableBinding(name, false)を実行する。
        2. そうでなければ、
          1. envRecord.CreateMutableBinding(name, false)を実行する。
    2. declFunctionDeclarationGeneratorDeclarationAsyncFunctionDeclaration、またはAsyncGeneratorDeclarationのいずれかである場合、
      1. declBoundNamesの唯一の要素をfuncNameとする。
      2. envRecordおよびprivateEnvを引数として、declInstantiateFunctionObjectfuncObjとする。
      3. ホストがWebブラウザである、またはその他の形でBlock-Level Function Declarations Web Legacy Compatibility Semanticsをサポートする場合、
        1. envRecord内のfuncNameに対する束縛が未初期化束縛である場合、
          1. envRecord.InitializeBinding(funcName, funcObj)を実行する。
        2. そうでなければ、
          1. Assert: declFunctionDeclarationである。
          2. envRecord.SetMutableBinding(funcName, funcObj, false)を実行する。
      4. そうでなければ、
        1. envRecord.InitializeBinding(funcName, funcObj)を実行する。
  4. unusedを返す。

14.3 Declarations and the Variable Statement

14.3.1 Let、Const、Using、および Await Using 宣言

Note

letconstusing、および await using 宣言は、実行中の実行コンテキストの LexicalEnvironment にスコープされる変数を定義する。変数は、それを含む Environment Record がインスタンス化されるときに作成されるが、その変数の LexicalBinding が評価されるまで、いかなる方法でもアクセスできない。Initializer を持つ LexicalBinding によって定義される変数には、変数が作成されるときではなく、LexicalBinding が評価されるときに、その InitializerAssignmentExpression の値が代入される。let 宣言内の LexicalBindingInitializer を持たない場合、その LexicalBinding が評価されるときに、変数には値 undefined が代入される。

構文

LexicalDeclaration[In, Yield, Await] : LetOrConst BindingList[?In, ?Yield, ?Await, +Pattern] ; UsingDeclaration[?In, ?Yield, ?Await] [+Await] AwaitUsingDeclaration[?In, ?Yield] LetOrConst : let const UsingDeclaration[In, Yield, Await] : using [no LineTerminator here] BindingList[?In, ?Yield, ?Await, ~Pattern] ; AwaitUsingDeclaration[In, Yield] : CoverAwaitExpressionAndAwaitUsingDeclarationHead[?Yield] [no LineTerminator here] BindingList[?In, ?Yield, +Await, ~Pattern] ; BindingList[In, Yield, Await, Pattern] : LexicalBinding[?In, ?Yield, ?Await, ?Pattern] BindingList[?In, ?Yield, ?Await, ?Pattern] , LexicalBinding[?In, ?Yield, ?Await, ?Pattern] LexicalBinding[In, Yield, Await, Pattern] : BindingIdentifier[?Yield, ?Await] Initializer[?In, ?Yield, ?Await]opt [+Pattern] BindingPattern[?Yield, ?Await] Initializer[?In, ?Yield, ?Await]

補足構文

生成規則のインスタンスを処理する際
AwaitUsingDeclaration : CoverAwaitExpressionAndAwaitUsingDeclarationHead BindingList ;
CoverAwaitExpressionAndAwaitUsingDeclarationHead の解釈は、次の文法を使用して精緻化される:

AwaitUsingDeclarationHead : await [no LineTerminator here] using

14.3.1.1 Static Semantics: 早期エラー

LexicalDeclaration : LetOrConst BindingList ; UsingDeclaration : using BindingList ; AwaitUsingDeclaration : CoverAwaitExpressionAndAwaitUsingDeclarationHead BindingList ; LexicalBinding : BindingIdentifier Initializeropt

14.3.1.2 Runtime Semantics: Evaluation

LexicalDeclaration : LetOrConst BindingList ;
  1. 引数 normalBindingListBindingEvaluation を実行する。
  2. empty を返す。
UsingDeclaration : using BindingList ;
  1. 引数 sync-disposeBindingListBindingEvaluation を実行する。
  2. empty を返す。
AwaitUsingDeclaration : CoverAwaitExpressionAndAwaitUsingDeclarationHead BindingList ;
  1. 引数 async-disposeBindingListBindingEvaluation を実行する。
  2. empty を返す。

14.3.1.3 Runtime Semantics: BindingEvaluation

The syntax-directed operation BindingEvaluation takes argument kind (normalsync-dispose、または async-dispose) and returns unused を含む normal completion または abrupt completion. It is defined piecewise over the following productions:

BindingList : BindingList , LexicalBinding
  1. 引数 kind で、派生した BindingListBindingEvaluation を実行する。
  2. 引数 kindLexicalBindingBindingEvaluation を返す。
LexicalBinding : BindingIdentifier
  1. Assert: kindnormal である。
  2. lhs を ! ResolveBinding(BindingIdentifierStringValue) とする。
  3. InitializeReferencedBinding(lhs, undefined) を実行する。
  4. unused を返す。
Note

静的意味論の規則により、この形式の LexicalBindingconstusing、または await using 宣言では決して発生しないことが保証される。

LexicalBinding : BindingIdentifier Initializer
  1. bindingIdBindingIdentifierStringValue とする。
  2. lhs を ! ResolveBinding(bindingId) とする。
  3. IsAnonymousFunctionDefinition(Initializer) が true である場合、then
    1. value を、引数 bindingIdInitializerNamedEvaluation とする。
  4. Else,
    1. rhsInitializerEvaluation とする。
    2. value を ? GetValue(rhs) とする。
  5. kindnormal でない場合、then
    1. Assert: IsUnresolvableReference(lhs) は false である。
    2. baselhs.[[Base]] とする。
    3. Assert: baseDeclarative Environment Record である。
    4. AddDisposableResource(base.[[DisposableResourceStack]], value, kind) を実行する。
  6. InitializeReferencedBinding(lhs, value) を実行する。
  7. unused を返す。
LexicalBinding : BindingPattern Initializer
  1. Assert: kindnormal である。
  2. rhsInitializerEvaluation とする。
  3. value を ? GetValue(rhs) とする。
  4. envRecord を、実行中の実行コンテキストの LexicalEnvironment とする。
  5. 引数 value および envRecord で、BindingPatternBindingInitialization を返す。

14.3.2 Variable Statement

Note

var statementは、running execution contextのVariableEnvironmentにscopedされるvariablesを宣言します。Var variablesは、それらを含むEnvironment Recordがinstantiatedされるときに作成され、作成時にundefinedへinitializedされます。任意のVariableEnvironmentのscope内では、共通のBindingIdentifierが複数のVariableDeclarationに現れてよいですが、それらのdeclarationsはcollectivelyに1つのvariableのみを定義します。Initializerを持つVariableDeclarationによって定義されるvariableには、variableが作成されたときではなく、VariableDeclarationが実行されるときに、そのInitializerAssignmentExpressionの値が割り当てられます。

Syntax

VariableStatement[Yield, Await] : var VariableDeclarationList[+In, ?Yield, ?Await] ; VariableDeclarationList[In, Yield, Await] : VariableDeclaration[?In, ?Yield, ?Await] VariableDeclarationList[?In, ?Yield, ?Await] , VariableDeclaration[?In, ?Yield, ?Await] VariableDeclaration[In, Yield, Await] : BindingIdentifier[?Yield, ?Await] Initializer[?In, ?Yield, ?Await]opt BindingPattern[?Yield, ?Await] Initializer[?In, ?Yield, ?Await]

14.3.2.1 Runtime Semantics: Evaluation

VariableStatement : var VariableDeclarationList ;
  1. VariableDeclarationListの ? Evaluationを実行する。
  2. emptyを返す。
VariableDeclarationList : VariableDeclarationList , VariableDeclaration
  1. VariableDeclarationListの ? Evaluationを実行する。
  2. VariableDeclarationの ? Evaluationを返す。
VariableDeclaration : BindingIdentifier
  1. emptyを返す。
VariableDeclaration : BindingIdentifier Initializer
  1. bindingIdBindingIdentifierStringValueとする。
  2. lhsを ? ResolveBinding(bindingId) とする。
  3. IsAnonymousFunctionDefinition(Initializer)がtrueなら、
    1. valueを、引数bindingIdを伴うInitializerの ? NamedEvaluationとする。
  4. そうでなければ、
    1. rhsInitializerの ? Evaluationとする。
    2. valueを ? GetValue(rhs) とする。
  5. PutValue(lhs, value)を実行する。
  6. emptyを返す。
Note

VariableDeclarationがwith statement内にnestedされており、VariableDeclaration内のBindingIdentifierがwith statementのObject Environment Recordのbinding objectのproperty nameと同じである場合、step 5valueIdentifierのVariableEnvironment bindingへ割り当てる代わりに、そのpropertyへ割り当てます。

VariableDeclaration : BindingPattern Initializer
  1. rhsInitializerの ? Evaluationとする。
  2. rightValueを ? GetValue(rhs) とする。
  3. 引数rightValueおよびundefinedを伴うBindingPatternの ? BindingInitializationを返す。

14.3.3 Destructuring Binding Patterns

Syntax

BindingPattern[Yield, Await] : ObjectBindingPattern[?Yield, ?Await] ArrayBindingPattern[?Yield, ?Await] ObjectBindingPattern[Yield, Await] : { } { BindingRestProperty[?Yield, ?Await] } { BindingPropertyList[?Yield, ?Await] } { BindingPropertyList[?Yield, ?Await] , BindingRestProperty[?Yield, ?Await]opt } ArrayBindingPattern[Yield, Await] : [ Elisionopt BindingRestElement[?Yield, ?Await]opt ] [ BindingElementList[?Yield, ?Await] ] [ BindingElementList[?Yield, ?Await] , Elisionopt BindingRestElement[?Yield, ?Await]opt ] BindingRestProperty[Yield, Await] : ... BindingIdentifier[?Yield, ?Await] BindingPropertyList[Yield, Await] : BindingProperty[?Yield, ?Await] BindingPropertyList[?Yield, ?Await] , BindingProperty[?Yield, ?Await] BindingElementList[Yield, Await] : BindingElisionElement[?Yield, ?Await] BindingElementList[?Yield, ?Await] , BindingElisionElement[?Yield, ?Await] BindingElisionElement[Yield, Await] : Elisionopt BindingElement[?Yield, ?Await] BindingProperty[Yield, Await] : SingleNameBinding[?Yield, ?Await] PropertyName[?Yield, ?Await] : BindingElement[?Yield, ?Await] BindingElement[Yield, Await] : SingleNameBinding[?Yield, ?Await] BindingPattern[?Yield, ?Await] Initializer[+In, ?Yield, ?Await]opt SingleNameBinding[Yield, Await] : BindingIdentifier[?Yield, ?Await] Initializer[+In, ?Yield, ?Await]opt BindingRestElement[Yield, Await] : ... BindingIdentifier[?Yield, ?Await] ... BindingPattern[?Yield, ?Await]

14.3.3.1 Runtime Semantics: PropertyBindingInitialization

The syntax-directed operation PropertyBindingInitialization takes arguments value (an ECMAScript language value) and envRecord (an Environment Record or undefined) and returns either a normal completion containing a List of property keys or an abrupt completion. これは、bound property namesすべてのlistを収集します。 It is defined piecewise over the following productions:

BindingPropertyList : BindingPropertyList , BindingProperty
  1. boundNamesを、引数valueおよびenvRecordを伴うBindingPropertyListの ? PropertyBindingInitializationとする。
  2. nextNamesを、引数valueおよびenvRecordを伴うBindingPropertyの ? PropertyBindingInitializationとする。
  3. boundNamesnextNameslist-concatenationを返す。
BindingProperty : SingleNameBinding
  1. nameSingleNameBindingBoundNamesの唯一の要素とする。
  2. 引数valueenvRecord、およびnameを伴うSingleNameBindingの ? KeyedBindingInitializationを実行する。
  3. « name »を返す。
BindingProperty : PropertyName : BindingElement
  1. propertyKeyPropertyNameの ? Evaluationとする。
  2. 引数valueenvRecord、およびpropertyKeyを伴うBindingElementの ? KeyedBindingInitializationを実行する。
  3. « propertyKey »を返す。

14.3.3.2 Runtime Semantics: RestBindingInitialization

The syntax-directed operation RestBindingInitialization takes arguments value (an ECMAScript language value), envRecord (an Environment Record or undefined), and excludedNames (a List of property keys) and returns either a normal completion containing unused or an abrupt completion. It is defined piecewise over the following productions:

BindingRestProperty : ... BindingIdentifier
  1. lhsを ? ResolveBinding(BindingIdentifierStringValue, envRecord) とする。
  2. restObjOrdinaryObjectCreate(%Object.prototype%)とする。
  3. CopyDataProperties(restObj, value, excludedNames)を実行する。
  4. envRecordundefinedなら、? PutValue(lhs, restObj)を返す。
  5. InitializeReferencedBinding(lhs, restObj)を返す。

14.3.3.3 Runtime Semantics: KeyedBindingInitialization

The syntax-directed operation KeyedBindingInitialization takes arguments value (an ECMAScript language value), envRecord (an Environment Record or undefined), and propertyName (a property key) and returns either a normal completion containing unused or an abrupt completion.

Note

envRecordundefinedが渡された場合、それはinitialization valueを割り当てるためにPutValue operationが使用されるべきであることを示します。これはnon-strict functionsのformal parameter listsの場合です。その場合、同じ名前を持つ複数のparametersの可能性に対処するため、formal parameter bindingsはpreinitializedされます。

It is defined piecewise over the following productions:

BindingElement : BindingPattern Initializeropt
  1. valueを ? GetV(value, propertyName) に設定する。
  2. Initializerが存在し、かつvalueundefinedなら、
    1. defaultValueInitializerの ? Evaluationとする。
    2. valueを ? GetValue(defaultValue) に設定する。
  3. 引数valueおよびenvRecordを伴うBindingPatternの ? BindingInitializationを返す。
SingleNameBinding : BindingIdentifier Initializeropt
  1. bindingIdBindingIdentifierStringValueとする。
  2. lhsを ? ResolveBinding(bindingId, envRecord) とする。
  3. valueを ? GetV(value, propertyName) に設定する。
  4. Initializerが存在し、かつvalueundefinedなら、
    1. IsAnonymousFunctionDefinition(Initializer)がtrueなら、
      1. valueを、引数bindingIdを伴うInitializerの ? NamedEvaluationに設定する。
    2. そうでなければ、
      1. defaultValueInitializerの ? Evaluationとする。
      2. valueを ? GetValue(defaultValue) に設定する。
  5. envRecordundefinedなら、? PutValue(lhs, value)を返す。
  6. InitializeReferencedBinding(lhs, value)を返す。

14.4 Empty Statement

Syntax

EmptyStatement : ;

14.4.1 Runtime Semantics: Evaluation

EmptyStatement : ;
  1. emptyを返す。

14.5 Expression Statement

Syntax

ExpressionStatement[Yield, Await] : [lookahead ∉ { {, function, async [no LineTerminator here] function, class, let [ }] Expression[+In, ?Yield, ?Await] ; Note

ExpressionStatementはU+007B (LEFT CURLY BRACKET)で開始できません。これはBlockとのambiguityを生じさせる可能性があるためです。ExpressionStatementfunctionまたはclass keywordsで開始できません。これはFunctionDeclarationGeneratorDeclaration、またはClassDeclarationとのambiguityを生じさせるためです。ExpressionStatementasync functionで開始できません。これはAsyncFunctionDeclarationまたはAsyncGeneratorDeclarationとのambiguityを生じさせるためです。ExpressionStatementはtwo token sequence let [で開始できません。これは、最初のLexicalBindingArrayBindingPatternであるlet LexicalDeclarationとのambiguityを生じさせるためです。

14.5.1 Runtime Semantics: Evaluation

ExpressionStatement : Expression ;
  1. exprRefExpressionの ? Evaluationとする。
  2. GetValue(exprRef)を返す。

14.6 The if Statement

Syntax

IfStatement[Yield, Await, Return] : if ( Expression[+In, ?Yield, ?Await] ) Statement[?Yield, ?Await, ?Return] else Statement[?Yield, ?Await, ?Return] if ( Expression[+In, ?Yield, ?Await] ) Statement[?Yield, ?Await, ?Return] [lookahead ≠ else] Note
lookahead-restriction [lookahead ≠ else]は、古典的な“dangling else”問題を通常の方法で解決します。つまり、関連付けられるifの選択が他の点ではambiguousである場合、elseは候補となるifのうち最も近い(最も内側の)ものに関連付けられます

14.6.1 Static Semantics: Early Errors

IfStatement : if ( Expression ) Statement else Statement IfStatement : if ( Expression ) Statement Note

このruleを適用する必要があるのは、B.3.1で指定されるextensionが実装されている場合だけです。

14.6.2 Runtime Semantics: Evaluation

IfStatement : if ( Expression ) Statement else Statement
  1. exprRefExpressionの ? Evaluationとする。
  2. exprValueToBoolean(? GetValue(exprRef))とする。
  3. exprValuetrueなら、
    1. stmtCompletionを最初のStatementEvaluationCompletionとする。
  4. そうでなければ、
    1. stmtCompletionを2番目のStatementEvaluationCompletionとする。
  5. UpdateEmpty(stmtCompletion, undefined)を返す。
IfStatement : if ( Expression ) Statement
  1. exprRefExpressionの ? Evaluationとする。
  2. exprValueToBoolean(? GetValue(exprRef))とする。
  3. exprValuefalseなら、undefinedを返す。
  4. stmtCompletionStatementEvaluationCompletionとする。
  5. UpdateEmpty(stmtCompletion, undefined)を返す。

14.7 Iteration Statements

Syntax

IterationStatement[Yield, Await, Return] : DoWhileStatement[?Yield, ?Await, ?Return] WhileStatement[?Yield, ?Await, ?Return] ForStatement[?Yield, ?Await, ?Return] ForInOfStatement[?Yield, ?Await, ?Return]

14.7.1 Semantics

14.7.1.1 LoopContinues ( completion, labelSet )

The abstract operation LoopContinues takes arguments completion (a Completion Record) and labelSet (a List of Strings) and returns a Boolean. It performs the following steps when called:

  1. completionnormal completionなら、trueを返す。
  2. completioncontinue completionでないなら、falseを返す。
  3. completion.[[Target]]emptyなら、trueを返す。
  4. labelSetcompletion.[[Target]]を含むなら、trueを返す。
  5. falseを返す。
Note

IterationStatementStatement部分内では、ContinueStatementを使用して新しいiterationを開始できます。

14.7.1.2 Runtime Semantics: LoopEvaluation

The syntax-directed operation LoopEvaluation takes argument labelSet (a List of Strings) and returns either a normal completion containing an ECMAScript language value or an abrupt completion. It is defined piecewise over the following productions:

IterationStatement : DoWhileStatement
  1. 引数labelSetを伴うDoWhileStatementの ? DoWhileLoopEvaluationを返す。
IterationStatement : WhileStatement
  1. 引数labelSetを伴うWhileStatementの ? WhileLoopEvaluationを返す。
IterationStatement : ForStatement
  1. 引数labelSetを伴うForStatementの ? ForLoopEvaluationを返す。
IterationStatement : ForInOfStatement
  1. 引数labelSetを伴うForInOfStatementの ? ForIn/OfLoopEvaluationを返す。

14.7.2 The do-while Statement

Syntax

DoWhileStatement[Yield, Await, Return] : do Statement[?Yield, ?Await, ?Return] while ( Expression[+In, ?Yield, ?Await] ) ;

14.7.2.1 Static Semantics: Early Errors

DoWhileStatement : do Statement while ( Expression ) ; Note

このruleを適用する必要があるのは、B.3.1で指定されるextensionが実装されている場合だけです。

14.7.2.2 Runtime Semantics: DoWhileLoopEvaluation

The syntax-directed operation DoWhileLoopEvaluation takes argument labelSet (a List of Strings) and returns either a normal completion containing an ECMAScript language value or an abrupt completion. It is defined piecewise over the following productions:

DoWhileStatement : do Statement while ( Expression ) ;
  1. iterationResultundefinedとする。
  2. 繰り返す
    1. stmtResultStatementEvaluationCompletionとする。
    2. LoopContinues(stmtResult, labelSet)がfalseなら、? UpdateEmpty(stmtResult, iterationResult)を返す。
    3. stmtResult.[[Value]]emptyでないなら、iterationResultstmtResult.[[Value]]に設定する。
    4. exprRefExpressionの ? Evaluationとする。
    5. exprValueを ? GetValue(exprRef) とする。
    6. ToBoolean(exprValue)がfalseなら、iterationResultを返す。

14.7.3 The while Statement

Syntax

WhileStatement[Yield, Await, Return] : while ( Expression[+In, ?Yield, ?Await] ) Statement[?Yield, ?Await, ?Return]

14.7.3.1 Static Semantics: Early Errors

WhileStatement : while ( Expression ) Statement Note

このruleを適用する必要があるのは、B.3.1で指定されるextensionが実装されている場合だけです。

14.7.3.2 Runtime Semantics: WhileLoopEvaluation

The syntax-directed operation WhileLoopEvaluation takes argument labelSet (a List of Strings) and returns either a normal completion containing an ECMAScript language value or an abrupt completion. It is defined piecewise over the following productions:

WhileStatement : while ( Expression ) Statement
  1. iterationResultundefinedとする。
  2. 繰り返す
    1. exprRefExpressionの ? Evaluationとする。
    2. exprValueを ? GetValue(exprRef) とする。
    3. ToBoolean(exprValue)がfalseなら、iterationResultを返す。
    4. stmtResultStatementEvaluationCompletionとする。
    5. LoopContinues(stmtResult, labelSet)がfalseなら、? UpdateEmpty(stmtResult, iterationResult)を返す。
    6. stmtResult.[[Value]]emptyでないなら、iterationResultstmtResult.[[Value]]に設定する。

14.7.4 The for Statement

Syntax

ForStatement[Yield, Await, Return] : for ( [lookahead ≠ let [] Expression[~In, ?Yield, ?Await]opt ; Expression[+In, ?Yield, ?Await]opt ; Expression[+In, ?Yield, ?Await]opt ) Statement[?Yield, ?Await, ?Return] for ( var VariableDeclarationList[~In, ?Yield, ?Await] ; Expression[+In, ?Yield, ?Await]opt ; Expression[+In, ?Yield, ?Await]opt ) Statement[?Yield, ?Await, ?Return] for ( LexicalDeclaration[~In, ?Yield, ?Await] Expression[+In, ?Yield, ?Await]opt ; Expression[+In, ?Yield, ?Await]opt ) Statement[?Yield, ?Await, ?Return]

14.7.4.1 Static Semantics: Early Errors

ForStatement : for ( Expressionopt ; Expressionopt ; Expressionopt ) Statement for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement Note

このruleを適用する必要があるのは、B.3.1で指定されるextensionが実装されている場合だけです。

ForStatement : for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement

14.7.4.2 Runtime Semantics: ForLoopEvaluation

The syntax-directed operation ForLoopEvaluation takes argument labelSet (a List of Strings) and returns either a normal completion containing an ECMAScript language value or an abrupt completion. It is defined piecewise over the following productions:

ForStatement : for ( Expressionopt ; Expressionopt ; Expressionopt ) Statement
  1. 最初のExpressionが存在するなら、
    1. exprRefを最初のExpressionの ? Evaluationとする。
    2. GetValue(exprRef)を実行する。
  2. 2番目のExpressionが存在するなら、testを2番目のExpressionとする;そうでなければ、testemptyとする。
  3. 3番目のExpressionが存在するなら、incrementを3番目のExpressionとする;そうでなければ、incrementemptyとする。
  4. ForBodyEvaluation(test, increment, Statement, « », labelSet)を返す。
ForStatement : for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
  1. VariableDeclarationListの ? Evaluationを実行する。
  2. 最初のExpressionが存在するなら、testを最初のExpressionとする;そうでなければ、testemptyとする。
  3. 2番目のExpressionが存在するなら、incrementを2番目のExpressionとする;そうでなければ、incrementemptyとする。
  4. ForBodyEvaluation(test, increment, Statement, « », labelSet)を返す。
ForStatement : for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
  1. oldEnv を、実行中の実行コンテキストの LexicalEnvironment とする。
  2. loopEnvNewDeclarativeEnvironment(oldEnv) とする。
  3. isConstLexicalDeclarationIsConstantDeclaration とする。
  4. boundNamesLexicalDeclarationBoundNames とする。
  5. boundNames の各要素 name について、do
    1. isConsttrue である場合、then
      1. loopEnv.CreateImmutableBinding(name, true) を実行する。
    2. Else,
      1. loopEnv.CreateMutableBinding(name, false) を実行する。
  6. 実行中の実行コンテキストの LexicalEnvironment を loopEnv に設定する。
  7. forDeclLexicalDeclarationEvaluationCompletion とする。
  8. forDeclabrupt completion である場合、then
    1. forDeclCompletion(DisposeResources(loopEnv.[[DisposableResourceStack]], forDecl)) に設定する。
    2. Assert: forDeclabrupt completion である。
    3. 実行中の実行コンテキストの LexicalEnvironment を oldEnv に設定する。
    4. Return ? forDecl.
  9. isConstfalse である場合、perIterationLetsboundNames とする。そうでなければ、perIterationLets を新しい空の List とする。
  10. 最初の Expression が存在する場合、test を最初の Expression とする。そうでなければ、testempty とする。
  11. 2番目の Expression が存在する場合、increment を2番目の Expression とする。そうでなければ、incrementempty とする。
  12. bodyResultCompletion(ForBodyEvaluation(test, increment, Statement, perIterationLets, labelSet)) とする。
  13. bodyResultCompletion(DisposeResources(loopEnv.[[DisposableResourceStack]], bodyResult)) に設定する。
  14. Assert: bodyResultnormal completion である場合、bodyResult.[[Value]]empty でない。
  15. 実行中の実行コンテキストの LexicalEnvironment を oldEnv に設定する。
  16. Return ? bodyResult.

14.7.4.3 ForBodyEvaluation ( test, increment, stmt, perIterationBindings, labelSet )

The abstract operation ForBodyEvaluation takes arguments test (an Expression Parse Node or empty), increment (an Expression Parse Node or empty), stmt (a Statement Parse Node), perIterationBindings (a List of Strings), and labelSet (a List of Strings) and returns either a normal completion containing an ECMAScript language value or an abrupt completion. It performs the following steps when called:

  1. iterationResultundefinedとする。
  2. CreatePerIterationEnvironment(perIterationBindings)を実行する。
  3. 繰り返す
    1. testemptyでないなら、
      1. testReftestの ? Evaluationとする。
      2. testValueを ? GetValue(testRef) とする。
      3. ToBoolean(testValue)がfalseなら、iterationResultを返す。
    2. resultstmtEvaluationCompletionとする。
    3. LoopContinues(result, labelSet)がfalseなら、? UpdateEmpty(result, iterationResult)を返す。
    4. result.[[Value]]emptyでないなら、iterationResultresult.[[Value]]に設定する。
    5. CreatePerIterationEnvironment(perIterationBindings)を実行する。
    6. incrementemptyでないなら、
      1. incRefincrementの ? Evaluationとする。
      2. GetValue(incRef)を実行する。

14.7.4.4 CreatePerIterationEnvironment ( perIterationBindings )

The abstract operation CreatePerIterationEnvironment takes argument perIterationBindings (a List of Strings) and returns either a normal completion containing unused or a throw completion. It performs the following steps when called:

  1. perIterationBindingsに要素がある場合、
    1. 実行中の実行コンテキストのLexicalEnvironmentをlastIterationEnvとする。
    2. lastIterationEnv.[[OuterEnv]]outerとする。
    3. Assert: outernullではない。
    4. NewDeclarativeEnvironment(outer)をthisIterationEnvとする。
    5. perIterationBindingsの各要素nameについて、次を行う。
      1. thisIterationEnv.CreateMutableBinding(name, false)を実行する。
      2. lastIterationEnv.GetBindingValue(name, true)をlastValueとする。
      3. thisIterationEnv.InitializeBinding(name, lastValue)を実行する。
    6. 実行中の実行コンテキストのLexicalEnvironmentをthisIterationEnvに設定する。
  2. unusedを返す。

14.7.5 The for-in, for-of, and for-await-of Statements

Syntax

ForInOfStatement[Yield, Await, Return] : for ( [lookahead ≠ let [] LeftHandSideExpression[?Yield, ?Await] in Expression[+In, ?Yield, ?Await] ) Statement[?Yield, ?Await, ?Return] for ( var ForBinding[?Yield, ?Await, +Pattern] in Expression[+In, ?Yield, ?Await] ) Statement[?Yield, ?Await, ?Return] for ( ForDeclaration[?Yield, ?Await, ~Using] in Expression[+In, ?Yield, ?Await] ) Statement[?Yield, ?Await, ?Return] for ( [lookahead ∉ { let, async of }] LeftHandSideExpression[?Yield, ?Await] of AssignmentExpression[+In, ?Yield, ?Await] ) Statement[?Yield, ?Await, ?Return] for ( var ForBinding[?Yield, ?Await, +Pattern] of AssignmentExpression[+In, ?Yield, ?Await] ) Statement[?Yield, ?Await, ?Return] for ( [lookahead ≠ using of] ForDeclaration[?Yield, ?Await, +Using] of AssignmentExpression[+In, ?Yield, ?Await] ) Statement[?Yield, ?Await, ?Return] [+Await] for await ( [lookahead ≠ let] LeftHandSideExpression[?Yield, ?Await] of AssignmentExpression[+In, ?Yield, ?Await] ) Statement[?Yield, ?Await, ?Return] [+Await] for await ( var ForBinding[?Yield, ?Await, +Pattern] of AssignmentExpression[+In, ?Yield, ?Await] ) Statement[?Yield, ?Await, ?Return] [+Await] for await ( [lookahead ≠ using of] ForDeclaration[?Yield, ?Await, +Using] of AssignmentExpression[+In, ?Yield, ?Await] ) Statement[?Yield, ?Await, ?Return] ForDeclaration[Yield, Await, Using] : LetOrConst ForBinding[?Yield, ?Await, +Pattern] [+Using] using [no LineTerminator here] ForBinding[?Yield, ?Await, ~Pattern] [+Using, +Await] await [no LineTerminator here] using [no LineTerminator here] ForBinding[?Yield, +Await, ~Pattern] ForBinding[Yield, Await, Pattern] : BindingIdentifier[?Yield, ?Await] [+Pattern] BindingPattern[?Yield, ?Await] Note

このsectionはAnnex B.3.5によって拡張されます。

14.7.5.1 Static Semantics: Early Errors

ForInOfStatement : for ( LeftHandSideExpression in Expression ) Statement for ( var ForBinding in Expression ) Statement for ( ForDeclaration in Expression ) Statement for ( LeftHandSideExpression of AssignmentExpression ) Statement for ( var ForBinding of AssignmentExpression ) Statement for ( ForDeclaration of AssignmentExpression ) Statement for await ( LeftHandSideExpression of AssignmentExpression ) Statement for await ( var ForBinding of AssignmentExpression ) Statement for await ( ForDeclaration of AssignmentExpression ) Statement Note

このruleを適用する必要があるのは、B.3.1で指定されるextensionが実装されている場合だけです。

ForInOfStatement : for ( LeftHandSideExpression in Expression ) Statement for ( LeftHandSideExpression of AssignmentExpression ) Statement for await ( LeftHandSideExpression of AssignmentExpression ) Statement ForInOfStatement : for ( ForDeclaration in Expression ) Statement for ( ForDeclaration of AssignmentExpression ) Statement for await ( ForDeclaration of AssignmentExpression ) Statement

14.7.5.2 Static Semantics: IsDestructuring

The syntax-directed operation IsDestructuring takes no arguments and returns a Boolean. It is defined piecewise over the following productions:

MemberExpression : PrimaryExpression
  1. PrimaryExpressionObjectLiteralまたはArrayLiteralのいずれかなら、trueを返す。
  2. falseを返す。
MemberExpression : MemberExpression [ Expression ] MemberExpression . IdentifierName MemberExpression TemplateLiteral SuperProperty MetaProperty new MemberExpression Arguments MemberExpression . PrivateIdentifier NewExpression : new NewExpression LeftHandSideExpression : CallExpression OptionalExpression
  1. falseを返す。
ForDeclaration : LetOrConst ForBinding
  1. ForBindingIsDestructuringを返す。
ForBinding : BindingIdentifier
  1. falseを返す。
ForBinding : BindingPattern
  1. trueを返す。
Note

このsectionはAnnex B.3.5によって拡張されます。

14.7.5.3 Runtime Semantics: ForDeclarationBindingInitialization

The syntax-directed operation ForDeclarationBindingInitialization takes arguments value (an ECMAScript language value) and envRecord (an Environment Record) and returns either a normal completion containing unused or an abrupt completion. It is defined piecewise over the following productions:

ForDeclaration : LetOrConst ForBinding
  1. 引数valueおよびenvRecordを伴うForBindingの ? BindingInitializationを返す。
ForDeclaration : using ForBinding await using ForBinding
  1. SyntaxError 例外を投げる。

14.7.5.4 Runtime Semantics: ForDeclarationBindingInstantiation

The syntax-directed operation ForDeclarationBindingInstantiation takes argument envRecord (a Declarative Environment Record) and returns unused. It is defined piecewise over the following productions:

ForDeclaration : LetOrConst ForBinding
  1. ForBindingBoundNamesの各要素nameについて、以下を行う
    1. LetOrConstIsConstantDeclarationtrueなら、
      1. envRecord.CreateImmutableBinding(name, true)を実行する。
    2. そうでなければ、
      1. envRecord.CreateMutableBinding(name, false)を実行する。
  2. unusedを返す。
ForDeclaration : using ForBinding await using ForBinding
  1. ForBindingBoundNames の各要素 name について、do
    1. envRecord.CreateImmutableBinding(name, true) を実行する。
  2. unused を返す。

14.7.5.5 Runtime Semantics: ForIn/OfLoopEvaluation

The syntax-directed operation ForIn/OfLoopEvaluation takes argument labelSet (a List of Strings) and returns either a normal completion containing an ECMAScript language value or an abrupt completion. It is defined piecewise over the following productions:

ForInOfStatement : for ( LeftHandSideExpression in Expression ) Statement
  1. keyResultを ? ForIn/OfHeadEvaluation(« », Expression, enumerate) とする。
  2. ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, keyResult, enumerate, assignment, labelSet)を返す。
ForInOfStatement : for ( var ForBinding in Expression ) Statement
  1. keyResultを ? ForIn/OfHeadEvaluation(« », Expression, enumerate) とする。
  2. ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, enumerate, var-binding, labelSet)を返す。
ForInOfStatement : for ( ForDeclaration in Expression ) Statement
  1. keyResultを ? ForIn/OfHeadEvaluation(ForDeclarationBoundNames, Expression, enumerate) とする。
  2. ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, enumerate, lexical-binding, labelSet)を返す。
ForInOfStatement : for ( LeftHandSideExpression of AssignmentExpression ) Statement
  1. keyResultを ? ForIn/OfHeadEvaluation(« », AssignmentExpression, iterate) とする。
  2. ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, keyResult, iterate, assignment, labelSet)を返す。
ForInOfStatement : for ( var ForBinding of AssignmentExpression ) Statement
  1. keyResultを ? ForIn/OfHeadEvaluation(« », AssignmentExpression, iterate) とする。
  2. ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, iterate, var-binding, labelSet)を返す。
ForInOfStatement : for ( ForDeclaration of AssignmentExpression ) Statement
  1. keyResultを ? ForIn/OfHeadEvaluation(ForDeclarationBoundNames, AssignmentExpression, iterate) とする。
  2. ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, iterate, lexical-binding, labelSet)を返す。
ForInOfStatement : for await ( LeftHandSideExpression of AssignmentExpression ) Statement
  1. keyResultを ? ForIn/OfHeadEvaluation(« », AssignmentExpression, async-iterate) とする。
  2. ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement, keyResult, iterate, assignment, labelSet, async)を返す。
ForInOfStatement : for await ( var ForBinding of AssignmentExpression ) Statement
  1. keyResultを ? ForIn/OfHeadEvaluation(« », AssignmentExpression, async-iterate) とする。
  2. ForIn/OfBodyEvaluation(ForBinding, Statement, keyResult, iterate, var-binding, labelSet, async)を返す。
ForInOfStatement : for await ( ForDeclaration of AssignmentExpression ) Statement
  1. keyResultを ? ForIn/OfHeadEvaluation(ForDeclarationBoundNames, AssignmentExpression, async-iterate) とする。
  2. ForIn/OfBodyEvaluation(ForDeclaration, Statement, keyResult, iterate, lexical-binding, labelSet, async)を返す。
Note

このsectionはAnnex B.3.5によって拡張されます。

14.7.5.6 ForIn/OfHeadEvaluation ( uninitializedBoundNames, expr, iterationKind )

The abstract operation ForIn/OfHeadEvaluation takes arguments uninitializedBoundNames (a List of Strings), expr (an Expression Parse Node or an AssignmentExpression Parse Node), and iterationKind (enumerate, iterate, or async-iterate) and returns either a normal completion containing an Iterator Record or an abrupt completion. It performs the following steps when called:

  1. oldEnvrunning execution contextのLexicalEnvironmentとする。
  2. uninitializedBoundNamesが空でないなら、
    1. Assert: uninitializedBoundNamesは重複entriesを持たない。
    2. newEnvNewDeclarativeEnvironment(oldEnv)とする。
    3. uninitializedBoundNamesの各String nameについて、以下を行う
      1. newEnv.CreateMutableBinding(name, false)を実行する。
    4. running execution contextのLexicalEnvironmentをnewEnvに設定する。
  3. exprRefexprEvaluationCompletionとする。
  4. running execution contextのLexicalEnvironmentをoldEnvに設定する。
  5. exprValueを ? GetValue(? exprRef) とする。
  6. iterationKindenumerateなら、
    1. exprValueundefinedまたはnullのいずれかなら、
      1. Completion Record { [[Type]]: break, [[Value]]: empty, [[Target]]: empty }を返す。
    2. objを ! ToObject(exprValue) とする。
    3. iteratorEnumerateObjectProperties(obj)とする。
    4. nextMethodを ! GetV(iterator, "next") とする。
    5. Iterator Record { [[Iterator]]: iterator, [[NextMethod]]: nextMethod, [[Done]]: false }を返す。
  7. Assert: iterationKinditerateまたはasync-iterateのいずれかである。
  8. iterationKindasync-iterateなら、iteratorKindasyncとする。
  9. そうでなければ、iteratorKindsyncとする。
  10. GetIterator(exprValue, iteratorKind)を返す。

14.7.5.7 ForIn/OfBodyEvaluation ( lhs, stmt, iteratorRecord, iterationKind, lhsKind, labelSet [ , iteratorKind ] )

The abstract operation ForIn/OfBodyEvaluation takes arguments lhs (a Parse Node), stmt (a Statement Parse Node), iteratorRecord (an Iterator Record), iterationKind (enumerate or iterate), lhsKind (assignment, var-binding, or lexical-binding), and labelSet (a List of Strings) and optional argument iteratorKind (sync or async) and returns either a normal completion containing an ECMAScript language value or an abrupt completion. It performs the following steps when called:

  1. iteratorKind が存在しない場合、iteratorKindsync に設定する。
  2. oldEnv を、実行中の実行コンテキストの LexicalEnvironment とする。
  3. iterationResultundefined とする。
  4. lhsKindlexical-binding である場合、then
    1. Assert: lhsForDeclaration である。
    2. lhsIsAwaitUsingDeclarationtrue である場合、then
      1. declarationKindasync-dispose とする。
    3. Else if lhsIsUsingDeclarationtrue である場合、then
      1. declarationKindsync-dispose とする。
    4. Else,
      1. declarationKindnormal とする。
  5. Else,
    1. declarationKindnormal とする。
  6. destructuringlhsIsDestructuring とする。
  7. destructuringtrue であり、かつ lhsKindassignment である場合、then
    1. Assert: lhsLeftHandSideExpression である。
    2. assignmentPattern を、lhs によってカバーされる AssignmentPattern とする。
  8. Repeat,
    1. nextResult を ? Call(iteratorRecord.[[NextMethod]], iteratorRecord.[[Iterator]]) とする。
    2. iteratorKindasync である場合、nextResult を ? Await(nextResult) に設定する。
    3. nextResult が Object でない場合、TypeError 例外を投げる。
    4. done を ? IteratorComplete(nextResult) とする。
    5. donetrue である場合、iterationResult を返す。
    6. nextValue を ? IteratorValue(nextResult) とする。
    7. lhsKindassignment または var-binding のいずれかである場合、then
      1. destructuringtrue である場合、then
        1. lhsKindassignment である場合、then
          1. status を、引数 nextValueassignmentPatternDestructuringAssignmentEvaluationCompletion とする。
        2. Else,
          1. Assert: lhsKindvar-binding である。
          2. Assert: lhsForBinding である。
          3. status を、引数 nextValue および undefinedlhsBindingInitializationCompletion とする。
      2. Else,
        1. lhsReflhsEvaluationCompletion とする。(これは繰り返し評価されることがある。)
        2. lhsKindassignment であり、かつ lhsAssignmentTargetTypeweb-compat である場合、ReferenceError 例外を投げる。
        3. lhsRefabrupt completion である場合、then
          1. statuslhsRef とする。
        4. Else,
          1. statusCompletion(PutValue(lhsRef.[[Value]], nextValue)) とする。
      3. iterationEnvundefined とする。
    8. Else,
      1. Assert: lhsKindlexical-binding である。
      2. Assert: lhsForDeclaration である。
      3. iterationEnvNewDeclarativeEnvironment(oldEnv) とする。
      4. 引数 iterationEnvlhsForDeclarationBindingInstantiation を実行する。
      5. 実行中の実行コンテキストの LexicalEnvironment を iterationEnv に設定する。
      6. destructuringtrue である場合、then
        1. status を、引数 nextValue および iterationEnvlhsForDeclarationBindingInitializationCompletion とする。
      7. Else,
        1. Assert: lhs は単一の名前を束縛する。
        2. lhsNamelhsBoundNames の唯一の要素とする。
        3. lhsRef を ! ResolveBinding(lhsName) とする。
        4. declarationKindnormal でない場合、then
          1. Assert: IsUnresolvableReference(lhsRef) は false である。
          2. baselhsRef.[[Base]] とする。
          3. Assert: baseDeclarative Environment Record である。
          4. statusCompletion(AddDisposableResource(base.[[DisposableResourceStack]], nextValue, declarationKind)) とする。
        5. Else,
          1. statusNormalCompletion(unused) とする。
        6. statusnormal completion である場合、then
          1. statusCompletion(InitializeReferencedBinding(lhsRef, nextValue)) に設定する。
    9. statusabrupt completion である場合、then
      1. iterationEnvundefined でない場合、then
        1. statusCompletion(DisposeResources(iterationEnv.[[DisposableResourceStack]], status)) に設定する。
        2. Assert: statusabrupt completion である。
      2. 実行中の実行コンテキストの LexicalEnvironment を oldEnv に設定する。
      3. iterationKindenumerate である場合、return ? status.
      4. Assert: iterationKinditerate である。
      5. iteratorKindasync である場合、return ? AsyncIteratorClose(iteratorRecord, status).
      6. Return ? IteratorClose(iteratorRecord, status).
    10. resultstmtEvaluationCompletion とする。
    11. iterationEnvundefined でない場合、then
      1. resultCompletion(DisposeResources(iterationEnv.[[DisposableResourceStack]], result)) に設定する。
    12. 実行中の実行コンテキストの LexicalEnvironment を oldEnv に設定する。
    13. LoopContinues(result, labelSet) が false である場合、then
      1. statusCompletion(UpdateEmpty(result, iterationResult)) に設定する。
      2. iterationKindenumerate である場合、return ? status.
      3. Assert: iterationKinditerate である。
      4. iteratorKindasync である場合、return ? AsyncIteratorClose(iteratorRecord, status).
      5. Return ? IteratorClose(iteratorRecord, status).
    14. result.[[Value]]empty でない場合、iterationResultresult.[[Value]] に設定する。

14.7.5.8 Runtime Semantics: Evaluation

BindingIdentifier : Identifier yield await
  1. bindingIdBindingIdentifierStringValueとする。
  2. ResolveBinding(bindingId)を返す。

14.7.5.9 EnumerateObjectProperties ( obj )

The abstract operation EnumerateObjectProperties takes argument obj (an Object) and returns an iterator object. It performs the following steps when called:

  1. objのenumerable propertiesのString値keysすべてを反復するnext methodを持つiterator objectを返す。iterator objectはECMAScript codeから直接accessできることは決してありません。propertiesをenumeratingするmechanicsおよびorderは指定されませんが、以下で指定されるrulesにconformしなければなりません。

iteratorthrowおよびreturn methodsはnullであり、決して呼び出されません。iteratornext methodは、property keyiterator valueとして返すべきかどうかを判定するためにobject propertiesを処理します。返されるproperty keysにはSymbolsであるkeysは含まれません。target objectのpropertiesはenumeration中に削除される場合があります。iteratornext methodによって処理される前に削除されたpropertyは無視されます。enumeration中にtarget objectへ新しいpropertiesが追加された場合、新しく追加されたpropertiesはactive enumerationで処理されることが保証されません。property nameは、どのenumerationでもiteratornext methodによって最大1回だけ返されます。

target objectのpropertiesをenumeratingすることには、そのprototype、そのprototypeのprototype、以下同様にrecursiveにpropertiesをenumeratingすることが含まれます;ただし、prototypeのpropertyは、iteratornext methodによってすでに処理されたpropertyと同じ名前を持つ場合、処理されません。prototype objectのpropertyがすでに処理されたかどうかを判定するとき、[[Enumerable]] attributesの値は考慮されません。prototype objectsのenumerable property namesは、そのprototype objectをargumentとして渡してEnumerateObjectPropertiesを呼び出すことで取得されなければなりません。EnumerateObjectPropertiesは、target objectの[[OwnPropertyKeys]] internal methodを呼び出すことで、そのown property keysを取得しなければなりません。target objectのProperty attributesは、その[[GetOwnProperty]] internal methodを呼び出すことで取得されなければなりません。

さらに、objも、そのprototype chain内のどのobjectもProxy exotic objectTypedArraymodule namespace exotic object、またはimplementation provided exotic objectでない場合、iteratorは、次のいずれかが発生するまで、CreateForInIterator(obj)によって与えられるiteratorのように振る舞わなければなりません:

  • objまたはそのprototype chain内のobjectの[[Prototype]] internal slotの値が変更される、
  • objまたはそのprototype chain内のobjectからpropertyが削除される、
  • objのprototype chain内のobjectへpropertyが追加される、または
  • objまたはそのprototype chain内のobjectのpropertyの[[Enumerable]] attributeの値が変更される。
Note 1

ECMAScript implementationsは、14.7.5.10.2.1内のalgorithmを直接実装する必要はありません。前段落のconstraintsの1つがviolatedされない限り、そのalgorithmからbehaviourが逸脱しない任意のimplementationを選択してよいです。

以下は、これらのrulesにconformするECMAScript generator functionのinformative definitionです:

function* EnumerateObjectProperties(obj) {
  const visited = new Set();
  for (const key of Reflect.ownKeys(obj)) {
    if (typeof key === "symbol") continue;
    const desc = Reflect.getOwnPropertyDescriptor(obj, key);
    if (desc) {
      visited.add(key);
      if (desc.enumerable) yield key;
    }
  }
  const proto = Reflect.getPrototypeOf(obj);
  if (proto === null) return;
  for (const protoKey of EnumerateObjectProperties(proto)) {
    if (!visited.has(protoKey)) yield protoKey;
  }
}
Note 2
implementationsがCreateForInIteratorとmatchする必要がないexotic objectsのlistは、implementationsがhistoricallyにこれらの場合でbehaviourに違いがあり、その他すべてでは一致していたため、選択されました。

14.7.5.10 For-In Iterator Objects

For-In Iteratorは、特定のobjectに対する特定のiterationを表すobjectです。For-In Iterator objectsはECMAScript codeから直接accessできることは決してありません;それらはEnumerateObjectPropertiesのbehaviourをillustrateするためだけに存在します。

14.7.5.10.1 CreateForInIterator ( obj )

The abstract operation CreateForInIterator takes argument obj (an Object) and returns a For-In Iterator. これは、objのownおよびinherited enumerable string propertiesを特定のorderで反復するFor-In Iterator objectを作成するために使用されます。 It performs the following steps when called:

  1. iteratorOrdinaryObjectCreate(%ForInIteratorPrototype%, « [[Object]], [[ObjectWasVisited]], [[VisitedKeys]], [[RemainingKeys]] »)とする。
  2. iterator.[[Object]]objに設定する。
  3. iterator.[[ObjectWasVisited]]falseに設定する。
  4. iterator.[[VisitedKeys]]を新しい空のListに設定する。
  5. iterator.[[RemainingKeys]]を新しい空のListに設定する。
  6. iteratorを返す。

14.7.5.10.2 The %ForInIteratorPrototype% Object

%ForInIteratorPrototype% object:

  • すべてのFor-In Iterator objectsによってinheritedされるpropertiesを持ちます。
  • ordinary objectです。
  • その値が%Iterator.prototype%である[[Prototype]] internal slotを持ちます。
  • ECMAScript codeから直接accessできることは決してありません。
  • 次のpropertiesを持ちます:

14.7.5.10.2.1 %ForInIteratorPrototype%.next ( )

  1. iteratorthis valueとする。
  2. Assert: iteratorはObjectである。
  3. Assert: iteratorFor-In Iterator instanceのinternal slotsすべてを持つ(14.7.5.10.3)。
  4. objiterator.[[Object]]とする。
  5. 繰り返す
    1. iterator.[[ObjectWasVisited]]falseなら、
      1. keysを ? obj.[[OwnPropertyKeys]]() とする。
      2. keysの各要素keyについて、以下を行う
        1. keyがStringなら、
          1. keyiterator.[[RemainingKeys]]へappendする。
      3. iterator.[[ObjectWasVisited]]trueに設定する。
    2. iterator.[[RemainingKeys]]が空でない間、繰り返す
      1. keyiterator.[[RemainingKeys]]の最初の要素とする。
      2. iterator.[[RemainingKeys]]から最初の要素をremoveする。
      3. iterator.[[VisitedKeys]]keyを含まないなら、
        1. propertyDescを ? obj.[[GetOwnProperty]](key) とする。
        2. propertyDescundefinedでないなら、
          1. keyiterator.[[VisitedKeys]]へappendする。
          2. propertyDesc.[[Enumerable]]trueなら、CreateIteratorResultObject(key, false)を返す。
    3. objを ? obj.[[GetPrototypeOf]]() に設定する。
    4. iterator.[[Object]]objに設定する。
    5. iterator.[[ObjectWasVisited]]falseに設定する。
    6. objnullなら、CreateIteratorResultObject(undefined, true)を返す。

14.7.5.10.3 Properties of For-In Iterator Instances

For-In Iterator instancesは、%ForInIteratorPrototype% intrinsic objectからpropertiesをinheritするordinary objectsです。For-In Iterator instancesは、Table 34に列挙されたinternal slotsを持つものとしてinitiallyに作成されます。

Table 34: Internal Slots of For-In Iterator Instances
Internal Slot Type Description
[[Object]] an Object propertiesがiteratedされているObject値。
[[ObjectWasVisited]] a Boolean iterator[[Object]]に対して[[OwnPropertyKeys]]をinvokedしているならtrue、そうでなければfalse
[[VisitedKeys]] a List of Strings このiteratorによってこれまでにemittedされた値。
[[RemainingKeys]] a List of Strings そのprototypeがnullでない場合に、そのprototypeのpropertiesをiteratingする前に、current objectについてemitされるためにremainingしている値。

14.8 The continue Statement

Syntax

ContinueStatement[Yield, Await] : continue ; continue [no LineTerminator here] LabelIdentifier[?Yield, ?Await] ;

14.8.1 Static Semantics: Early Errors

ContinueStatement : continue ; continue LabelIdentifier ;
  • このContinueStatementが、直接的または間接的に(ただしfunctionまたはstatic initialization blockのboundariesを越えずに)IterationStatement内にnestedされていない場合、それはSyntax Errorです。

14.8.2 Runtime Semantics: Evaluation

ContinueStatement : continue ;
  1. Completion Record { [[Type]]: continue, [[Value]]: empty, [[Target]]: empty }を返す。
ContinueStatement : continue LabelIdentifier ;
  1. labelLabelIdentifierStringValueとする。
  2. Completion Record { [[Type]]: continue, [[Value]]: empty, [[Target]]: label }を返す。

14.9 The break Statement

Syntax

BreakStatement[Yield, Await] : break ; break [no LineTerminator here] LabelIdentifier[?Yield, ?Await] ;

14.9.1 Static Semantics: Early Errors

BreakStatement : break ;
  • このBreakStatementが、直接的または間接的に(ただしfunctionまたはstatic initialization blockのboundariesを越えずに)IterationStatementまたはSwitchStatement内にnestedされていない場合、それはSyntax Errorです。

14.9.2 Runtime Semantics: Evaluation

BreakStatement : break ;
  1. Completion Record { [[Type]]: break, [[Value]]: empty, [[Target]]: empty }を返す。
BreakStatement : break LabelIdentifier ;
  1. labelLabelIdentifierStringValueとする。
  2. Completion Record { [[Type]]: break, [[Value]]: empty, [[Target]]: label }を返す。

14.10 The return Statement

Syntax

ReturnStatement[Yield, Await] : return ; return [no LineTerminator here] Expression[+In, ?Yield, ?Await] ; Note

return statementはfunctionのexecutionを停止させ、ほとんどの場合、callerへ値を返します。Expressionが省略された場合、return valueはundefinedです。そうでなければ、return valueはExpressionの値です。return statementは、surrounding contextによっては、実際にはcallerへ値を返さない場合があります。例えば、try blockでは、return statementのCompletion Recordfinally blockのevaluation中に別のCompletion Recordへ置き換えられる場合があります。

14.10.1 Runtime Semantics: Evaluation

ReturnStatement : return ;
  1. ReturnCompletion(undefined)を返す。
ReturnStatement : return Expression ;
  1. exprRefExpressionの ? Evaluationとする。
  2. exprValueを ? GetValue(exprRef) とする。
  3. GetGeneratorKind()がasyncなら、exprValueを ? Await(exprValue) に設定する。
  4. ReturnCompletion(exprValue)を返す。

14.11 The with Statement

Note 1

新しいECMAScript codeではLegacy with statementの使用はdiscouragedされます。strict mode codeおよびnon-strict codeの両方で許可される代替手段、例えばdestructuring assignmentを検討してください。

Syntax

WithStatement[Yield, Await, Return] : with ( Expression[+In, ?Yield, ?Await] ) Statement[?Yield, ?Await, ?Return] Note 2

with statementは、computed objectに対するObject Environment Recordrunning execution contextのlexical environmentへ追加します。その後、このaugmented lexical environmentを使用してstatementを実行します。最後に、original lexical environmentを復元します。

14.11.1 Static Semantics: Early Errors

WithStatement : with ( Expression ) Statement Note

second ruleを適用する必要があるのは、B.3.1で指定されるextensionが実装されている場合だけです。

14.11.2 Runtime Semantics: Evaluation

WithStatement : with ( Expression ) Statement
  1. valueExpressionの ? Evaluationとする。
  2. objを ? ToObject(? GetValue(value)) とする。
  3. oldEnvrunning execution contextのLexicalEnvironmentとする。
  4. newEnvNewObjectEnvironment(obj, true, oldEnv)とする。
  5. running execution contextのLexicalEnvironmentをnewEnvに設定する。
  6. stmtCompletionStatementEvaluationCompletionとする。
  7. running execution contextのLexicalEnvironmentをoldEnvに設定する。
  8. UpdateEmpty(stmtCompletion, undefined)を返す。
Note

controlがembedded Statementからどのように離れても、通常であれ何らかのabrupt completionまたはexceptionによるものであれ、LexicalEnvironmentは常に以前のstateへ復元されます。

14.12 The switch Statement

Syntax

SwitchStatement[Yield, Await, Return] : switch ( Expression[+In, ?Yield, ?Await] ) CaseBlock[?Yield, ?Await, ?Return] CaseBlock[Yield, Await, Return] : { CaseClauses[?Yield, ?Await, ?Return]opt } { CaseClauses[?Yield, ?Await, ?Return]opt DefaultClause[?Yield, ?Await, ?Return] CaseClauses[?Yield, ?Await, ?Return]opt } CaseClauses[Yield, Await, Return] : CaseClause[?Yield, ?Await, ?Return] CaseClauses[?Yield, ?Await, ?Return] CaseClause[?Yield, ?Await, ?Return] CaseClause[Yield, Await, Return] : case Expression[+In, ?Yield, ?Await] : StatementList[?Yield, ?Await, ?Return]opt DefaultClause[Yield, Await, Return] : default : StatementList[?Yield, ?Await, ?Return]opt

14.12.1 Static Semantics: Early Errors

SwitchStatement : switch ( Expression ) CaseBlock CaseClause : case Expression : StatementList DefaultClause : default : StatementList

14.12.2 Runtime Semantics: CaseBlockEvaluation

The syntax-directed operation CaseBlockEvaluation takes argument input (an ECMAScript language value) and returns either a normal completion containing an ECMAScript language value or an abrupt completion. It is defined piecewise over the following productions:

CaseBlock : { }
  1. undefinedを返す。
CaseBlock : { CaseClauses }
  1. resultValueundefinedとする。
  2. caseClausesを、source text orderにおけるCaseClauses内のCaseClause itemsのListとする。
  3. foundfalseとする。
  4. caseClausesの各CaseClause clauseについて、以下を行う
    1. foundfalseなら、
      1. foundを ? CaseClauseIsSelected(clause, input) に設定する。
    2. foundtrueなら、
      1. completionclauseEvaluationCompletionとする。
      2. completion.[[Value]]emptyでないなら、resultValuecompletion.[[Value]]に設定する。
      3. completionabrupt completionなら、? UpdateEmpty(completion, resultValue)を返す。
  5. resultValueを返す。
CaseBlock : { CaseClausesopt DefaultClause CaseClausesopt }
  1. resultValueundefinedとする。
  2. 最初のCaseClausesが存在するなら、
    1. caseClausesを、source text orderにおける最初のCaseClauses内のCaseClause itemsのListとする。
  3. そうでなければ、
    1. caseClausesを新しい空のListとする。
  4. foundfalseとする。
  5. caseClausesの各CaseClause clauseについて、以下を行う
    1. foundfalseなら、
      1. foundを ? CaseClauseIsSelected(clause, input) に設定する。
    2. foundtrueなら、
      1. completionclauseEvaluationCompletionとする。
      2. completion.[[Value]]emptyでないなら、resultValuecompletion.[[Value]]に設定する。
      3. completionabrupt completionなら、? UpdateEmpty(completion, resultValue)を返す。
  6. foundInBfalseとする。
  7. 2番目のCaseClausesが存在するなら、
    1. secondCaseClausesを、source text orderにおける2番目のCaseClauses内のCaseClause itemsのListとする。
  8. そうでなければ、
    1. secondCaseClausesを新しい空のListとする。
  9. foundfalseなら、
    1. secondCaseClausesの各CaseClause clauseについて、以下を行う
      1. foundInBfalseなら、
        1. foundInBを ? CaseClauseIsSelected(clause, input) に設定する。
      2. foundInBtrueなら、
        1. completionCaseClause clauseEvaluationCompletionとする。
        2. completion.[[Value]]emptyでないなら、resultValuecompletion.[[Value]]に設定する。
        3. completionabrupt completionなら、? UpdateEmpty(completion, resultValue)を返す。
  10. foundInBtrueなら、resultValueを返す。
  11. defaultRDefaultClauseEvaluationCompletionとする。
  12. defaultR.[[Value]]emptyでないなら、resultValuedefaultR.[[Value]]に設定する。
  13. defaultRabrupt completionなら、? UpdateEmpty(defaultR, resultValue)を返す。
  14. NOTE: 以下は2番目のCaseClausesのもう1つの完全なiterationです。
  15. secondCaseClausesの各CaseClause clauseについて、以下を行う
    1. completionCaseClause clauseEvaluationCompletionとする。
    2. completion.[[Value]]emptyでないなら、resultValuecompletion.[[Value]]に設定する。
    3. completionabrupt completionなら、? UpdateEmpty(completion, resultValue)を返す。
  16. resultValueを返す。

14.12.3 CaseClauseIsSelected ( caseClauseNode, input )

The abstract operation CaseClauseIsSelected takes arguments caseClauseNode (a CaseClause Parse Node) and input (an ECMAScript language value) and returns either a normal completion containing a Boolean or an abrupt completion. これはcaseClauseNodeinputにmatchするかどうかを判定します。 It performs the following steps when called:

  1. Assert: caseClauseNodeはproduction CaseClause : case Expression : StatementListopt のinstanceである。
  2. exprRefcaseClauseNodeExpressionの ? Evaluationとする。
  3. clauseSelectorを ? GetValue(exprRef) とする。
  4. IsStrictlyEqual(input, clauseSelector)を返す。
Note

このoperationはcaseClauseNodeStatementList(存在する場合)を実行しません。CaseBlock algorithmは、どのStatementListの実行を開始するかを判定するためにそのreturn valueを使用します。

14.12.4 Runtime Semantics: Evaluation

SwitchStatement : switch ( Expression ) CaseBlock
  1. exprRefExpressionEvaluation とする。
  2. switchValue を ? GetValue(exprRef) とする。
  3. oldEnv を、実行中の実行コンテキストの LexicalEnvironment とする。
  4. blockEnvNewDeclarativeEnvironment(oldEnv) とする。
  5. BlockDeclarationInstantiation(CaseBlock, blockEnv) を実行する。
  6. 実行中の実行コンテキストの LexicalEnvironment を blockEnv に設定する。
  7. blockResult を、引数 switchValueCaseBlockCaseBlockEvaluationCompletion とする。
  8. Assert: blockEnv.[[DisposableResourceStack]] は空の List である。
  9. 実行中の実行コンテキストの LexicalEnvironment を oldEnv に設定する。
  10. Return blockResult.
Note

controlがどのようにSwitchStatementから離れても、LexicalEnvironmentは常に以前のstateへ復元されます。

CaseClause : case Expression :
  1. emptyを返す。
CaseClause : case Expression : StatementList
  1. StatementListの ? Evaluationを返す。
DefaultClause : default :
  1. emptyを返す。
DefaultClause : default : StatementList
  1. StatementListの ? Evaluationを返す。

14.13 Labelled Statements

Syntax

LabelledStatement[Yield, Await, Return] : LabelIdentifier[?Yield, ?Await] : LabelledItem[?Yield, ?Await, ?Return] LabelledItem[Yield, Await, Return] : Statement[?Yield, ?Await, ?Return] FunctionDeclaration[?Yield, ?Await, ~Default] Note

Statementにはlabelをprefixできます。Labelled statementsはlabelled breakおよびcontinue statementsと組み合わせてのみ使用されます。ECMAScriptにはgoto statementはありません。StatementLabelledStatementの一部であり得、それ自体がLabelledStatementの一部であり得、以下同様です。この方法でintroducedされるlabelsは、個々のstatementsのsemanticsを記述するとき、collectivelyに“current label set”と呼ばれます。

14.13.1 Static Semantics: Early Errors

LabelledItem : FunctionDeclaration
  • 任意のsource textがこのproductionによってmatchされる場合、それはSyntax Errorです。ただし、そのsource textがnon-strict codeであり、かつhostがweb browserである、またはその他の形でLabelled Function Declarationsをサポートする場合を除きます

14.13.2 Static Semantics: IsLabelledFunction ( stmt )

The abstract operation IsLabelledFunction takes argument stmt (a Statement Parse Node) and returns a Boolean. It performs the following steps when called:

  1. stmtLabelledStatementでないなら、falseを返す。
  2. itemstmtLabelledItemとする。
  3. item LabelledItem : FunctionDeclaration なら、trueを返す。
  4. subStmtitemStatementとする。
  5. IsLabelledFunction(subStmt)を返す。

14.13.3 Runtime Semantics: Evaluation

LabelledStatement : LabelIdentifier : LabelledItem
  1. 引数« »を伴うthis LabelledStatementの ? LabelledEvaluationを返す。

14.13.4 Runtime Semantics: LabelledEvaluation

The syntax-directed operation LabelledEvaluation takes argument labelSet (a List of Strings) and returns either a normal completion containing either an ECMAScript language value or empty, or an abrupt completion. It is defined piecewise over the following productions:

BreakableStatement : IterationStatement
  1. stmtResultを、引数labelSetを伴うIterationStatementLoopEvaluationCompletionとする。
  2. stmtResultbreak completionなら、
    1. stmtResult.[[Target]]emptyなら、
      1. stmtResult.[[Value]]emptyなら、stmtResultNormalCompletion(undefined)に設定する。
      2. そうでなければ、stmtResultNormalCompletion(stmtResult.[[Value]])に設定する。
  3. stmtResultを返す。
BreakableStatement : SwitchStatement
  1. stmtResultSwitchStatementEvaluationCompletionとする。
  2. stmtResultbreak completionなら、
    1. stmtResult.[[Target]]emptyなら、
      1. stmtResult.[[Value]]emptyなら、stmtResultNormalCompletion(undefined)に設定する。
      2. そうでなければ、stmtResultNormalCompletion(stmtResult.[[Value]])に設定する。
  3. stmtResultを返す。
Note 1

BreakableStatementは、unlabelled BreakStatementを介してexitできるものです。

LabelledStatement : LabelIdentifier : LabelledItem
  1. labelLabelIdentifierStringValueとする。
  2. newLabelSetlabelSetと« label »のlist-concatenationとする。
  3. stmtResultを、引数newLabelSetを伴うLabelledItemLabelledEvaluationCompletionとする。
  4. stmtResultbreak completionであり、かつstmtResult.[[Target]]labelであるなら、
    1. stmtResultNormalCompletion(stmtResult.[[Value]])に設定する。
  5. stmtResultを返す。
LabelledItem : FunctionDeclaration
  1. FunctionDeclarationの ? Evaluationを返す。
Statement : BlockStatement VariableStatement EmptyStatement ExpressionStatement IfStatement ContinueStatement BreakStatement ReturnStatement WithStatement ThrowStatement TryStatement DebuggerStatement
  1. Statementの ? Evaluationを返す。
Note 2

LabelledEvaluationに対してspecial semanticsを持つStatementのproductionsは、BreakableStatementおよびLabelledStatementの2つだけです。

14.14 The throw Statement

Syntax

ThrowStatement[Yield, Await] : throw [no LineTerminator here] Expression[+In, ?Yield, ?Await] ;

14.14.1 Runtime Semantics: Evaluation

ThrowStatement : throw Expression ;
  1. exprRefExpressionの ? Evaluationとする。
  2. exprValueを ? GetValue(exprRef) とする。
  3. exprValueをThrowする。

14.15 The try Statement

Syntax

TryStatement[Yield, Await, Return] : try Block[?Yield, ?Await, ?Return] Catch[?Yield, ?Await, ?Return] try Block[?Yield, ?Await, ?Return] Finally[?Yield, ?Await, ?Return] try Block[?Yield, ?Await, ?Return] Catch[?Yield, ?Await, ?Return] Finally[?Yield, ?Await, ?Return] Catch[Yield, Await, Return] : catch ( CatchParameter[?Yield, ?Await] ) Block[?Yield, ?Await, ?Return] catch Block[?Yield, ?Await, ?Return] Finally[Yield, Await, Return] : finally Block[?Yield, ?Await, ?Return] CatchParameter[Yield, Await] : BindingIdentifier[?Yield, ?Await] BindingPattern[?Yield, ?Await] Note

try statementは、runtime errorやthrow statementなど、exceptional conditionが発生し得るcodeのblockを囲みます。catch clauseはexception-handling codeを提供します。catch clauseがexceptionをcatchすると、そのCatchParameterはそのexceptionにboundされます。

14.15.1 Static Semantics: Early Errors

Catch : catch ( CatchParameter ) Block

14.15.2 Runtime Semantics: CatchClauseEvaluation

The syntax-directed operation CatchClauseEvaluation takes argument thrownValue (an ECMAScript language value) and returns either a normal completion containing either an ECMAScript language value or empty, or an abrupt completion. It is defined piecewise over the following productions:

Catch : catch ( CatchParameter ) Block
  1. oldEnvrunning execution contextのLexicalEnvironmentとする。
  2. catchEnvNewDeclarativeEnvironment(oldEnv)とする。
  3. CatchParameterBoundNamesの各要素argNameについて、以下を行う
    1. catchEnv.CreateMutableBinding(argName, false)を実行する。
  4. running execution contextのLexicalEnvironmentをcatchEnvに設定する。
  5. statusを、引数thrownValueおよびcatchEnvを伴うCatchParameterBindingInitializationCompletionとする。
  6. statusabrupt completionなら、
    1. running execution contextのLexicalEnvironmentをoldEnvに設定する。
    2. statusを返す。
  7. blockCompletionBlockEvaluationCompletionとする。
  8. running execution contextのLexicalEnvironmentをoldEnvに設定する。
  9. blockCompletionを返す。
Catch : catch Block
  1. Blockの ? Evaluationを返す。
Note

controlがどのようにBlockから離れても、LexicalEnvironmentは常に以前のstateへ復元されます。

14.15.3 Runtime Semantics: Evaluation

TryStatement : try Block Catch
  1. blockResultBlockEvaluationCompletionとする。
  2. blockResultthrow completionなら、catchResultを、引数blockResult.[[Value]]を伴うCatchCatchClauseEvaluationCompletionとする。
  3. そうでなければ、catchResultblockResultとする。
  4. UpdateEmpty(catchResult, undefined)を返す。
TryStatement : try Block Finally
  1. blockResultBlockEvaluationCompletionとする。
  2. finallyResultFinallyEvaluationCompletionとする。
  3. finallyResultnormal completionなら、finallyResultblockResultに設定する。
  4. UpdateEmpty(finallyResult, undefined)を返す。
TryStatement : try Block Catch Finally
  1. blockResultBlockEvaluationCompletionとする。
  2. blockResultthrow completionなら、catchResultを、引数blockResult.[[Value]]を伴うCatchCatchClauseEvaluationCompletionとする。
  3. そうでなければ、catchResultblockResultとする。
  4. finallyResultFinallyEvaluationCompletionとする。
  5. finallyResultnormal completionなら、finallyResultcatchResultに設定する。
  6. UpdateEmpty(finallyResult, undefined)を返す。

14.16 The debugger Statement

Syntax

DebuggerStatement : debugger ;

14.16.1 Runtime Semantics: Evaluation

Note

DebuggerStatementを評価すると、debuggerの下で実行されている場合、implementationがbreakpointを発生させることを可能にする場合があります。debuggerが存在しない、またはactiveでない場合、このstatementにはobservable effectはありません。

DebuggerStatement : debugger ;
  1. implementation-defined debugging facilityがavailableかつenabledであるなら、
    1. implementation-defined debugging actionを実行する。
    2. 新しいimplementation-defined Completion Recordを返す。
  2. emptyを返す。