14 ECMAScript 언어: 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. FunctionDeclarationEvaluation을 ? 반환한다.
BreakableStatement : IterationStatement SwitchStatement
  1. newLabelSet을 새 empty List로 둔다.
  2. argument newLabelSet를 가진 this BreakableStatementLabelledEvaluation을 ? 반환한다.

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. blockValue를 반환한다.
Note 1

control이 Block을 어떻게 leave하든 LexicalEnvironment는 항상 former state로 restored됩니다.

StatementList : StatementList StatementListItem
  1. slStatementListEvaluation으로 ? 둔다.
  2. sStatementListItemEvaluationCompletion으로 둔다.
  3. UpdateEmpty(s, sl)를 반환한다.
Note 2

StatementList의 value는 StatementList 안의 마지막 value-producing item의 value입니다. 예를 들어, 다음 eval function call은 모두 value 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에 corresponding하는 Parse Node입니다. envRecord는 binding이 created될 Environment Record입니다.

Note

Block 또는 CaseBlock이 evaluated될 때 새 Declarative Environment Record가 created되고, block 안에 declared된 각 block scoped variable, constant, function 또는 class에 대한 binding이 Environment Record 안에서 instantiated됩니다.

called될 때 다음 step을 수행합니다:

  1. declscodeLexicallyScopedDeclarations라고 하자.
  2. privateEnv를 실행 중인 실행 컨텍스트의 PrivateEnvironment라고 하자.
  3. decls의 각 요소 decl에 대해 다음을 수행한다.
    1. declBoundNames의 각 요소 name에 대해 다음을 수행한다.
      1. declIsConstantDeclarationtrue이면,
        1. envRecord.CreateImmutableBinding(name, true)를 수행한다.
      2. 그렇지 않으면,
        1. host가 웹 브라우저이거나 그 밖에 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. declFunctionDeclaration, GeneratorDeclaration, AsyncFunctionDeclaration 또는 AsyncGeneratorDeclaration 중 하나이면,
      1. funcNamedeclBoundNames의 유일한 요소라고 하자.
      2. funcObjdeclInstantiateFunctionObject에 인수 envRecordprivateEnv를 전달한 결과라고 하자.
      3. host가 웹 브라우저이거나 그 밖에 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

let, const, usingawait 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 (normal, sync-dispose, or async-dispose) and returns either a normal completion containing unused or an abrupt completion. It is defined piecewise over the following productions:

BindingList : BindingList , LexicalBinding
  1. 인수 kind로 파생된 BindingListBindingEvaluation을 ? 수행한다.
  2. 인수 kindLexicalBindingBindingEvaluation을 ? 반환한다.
LexicalBinding : BindingIdentifier
  1. 단언: kindnormal이다.
  2. lhs를 ! ResolveBinding(BindingIdentifierStringValue)으로 둔다.
  3. InitializeReferencedBinding(lhs, undefined)를 수행한다.
  4. unused를 반환한다.
Note

정적 의미론 규칙은 이러한 형태의 LexicalBindingconst, using 또는 await using 선언에서 절대 발생하지 않도록 보장한다.

LexicalBinding : BindingIdentifier Initializer
  1. bindingIdBindingIdentifierStringValue로 둔다.
  2. lhs를 ! ResolveBinding(bindingId)로 둔다.
  3. IsAnonymousFunctionDefinition(Initializer)이 true이면,
    1. value를 인수 bindingIdInitializerNamedEvaluation을 ? 수행한 결과로 둔다.
  4. 그렇지 않으면,
    1. rhsInitializerEvaluation을 ? 수행한 결과로 둔다.
    2. value를 ? GetValue(rhs)로 둔다.
  5. kindnormal이 아니면,
    1. 단언: IsUnresolvableReference(lhs)는 false이다.
    2. baselhs.[[Base]]로 둔다.
    3. 단언: baseDeclarative Environment Record이다.
    4. AddDisposableResource(base.[[DisposableResourceStack]], value, kind)를 ? 수행한다.
  6. InitializeReferencedBinding(lhs, value)를 ? 수행한다.
  7. unused를 반환한다.
LexicalBinding : BindingPattern Initializer
  1. 단언: kindnormal이다.
  2. rhsInitializerEvaluation을 ? 수행한 결과로 둔다.
  3. value를 ? GetValue(rhs)로 둔다.
  4. envRecord를 실행 중인 실행 컨텍스트의 LexicalEnvironment로 둔다.
  5. 인수 valueenvRecordBindingPatternBindingInitialization을 ? 반환한다.

14.3.2 Variable Statement

Note

var statement는 running execution context의 VariableEnvironment로 scoped되는 variable을 declare합니다. Var variable은 containing Environment Record가 instantiated될 때 created되고, created될 때 undefined로 initialized됩니다. 어떤 VariableEnvironment의 scope 안에서도 common BindingIdentifier는 둘 이상의 VariableDeclaration에 appear할 수 있지만, 그러한 declaration은 collectively 하나의 variable만 define합니다. Initializer를 가진 VariableDeclaration에 의해 defined된 variable은 variable이 created될 때가 아니라 VariableDeclaration이 executed될 때 그 InitializerAssignmentExpression value가 assigned됩니다.

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. VariableDeclarationListEvaluation을 ? 수행한다.
  2. empty를 반환한다.
VariableDeclarationList : VariableDeclarationList , VariableDeclaration
  1. VariableDeclarationListEvaluation을 ? 수행한다.
  2. VariableDeclarationEvaluation을 ? 반환한다.
VariableDeclaration : BindingIdentifier
  1. empty를 반환한다.
VariableDeclaration : BindingIdentifier Initializer
  1. bindingIdBindingIdentifierStringValue로 둔다.
  2. lhs를 ? ResolveBinding(bindingId)로 둔다.
  3. IsAnonymousFunctionDefinition(Initializer)이 true이면, 다음을 수행한다.
    1. value를 argument bindingId를 가진 InitializerNamedEvaluation으로 ? 둔다.
  4. 그렇지 않으면,
    1. rhsInitializerEvaluation으로 ? 둔다.
    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과 same하면, step 5valueIdentifier의 VariableEnvironment binding에 assigning하는 대신 property에 assign합니다.

VariableDeclaration : BindingPattern Initializer
  1. rhsInitializerEvaluation으로 ? 둔다.
  2. rightValue를 ? GetValue(rhs)로 둔다.
  3. arguments rightValueundefined를 가진 BindingPatternBindingInitialization을 ? 반환한다.

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 name 전체의 list를 collect합니다. It is defined piecewise over the following productions:

BindingPropertyList : BindingPropertyList , BindingProperty
  1. boundNames를 arguments valueenvRecord를 가진 BindingPropertyListPropertyBindingInitialization으로 ? 둔다.
  2. nextNames를 arguments valueenvRecord를 가진 BindingPropertyPropertyBindingInitialization으로 ? 둔다.
  3. boundNamesnextNameslist-concatenation을 반환한다.
BindingProperty : SingleNameBinding
  1. nameSingleNameBindingBoundNames의 sole element로 둔다.
  2. arguments value, envRecord, name을 가진 SingleNameBindingKeyedBindingInitialization을 ? 수행한다.
  3. « name »를 반환한다.
BindingProperty : PropertyName : BindingElement
  1. propertyKeyPropertyNameEvaluation으로 ? 둔다.
  2. arguments value, envRecord, propertyKey를 가진 BindingElementKeyedBindingInitialization을 ? 수행한다.
  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

undefinedenvRecord로 passed되면 initialization value를 assign하기 위해 PutValue operation이 사용되어야 함을 indicate합니다. 이는 non-strict function의 formal parameter list의 경우입니다. 그 경우 formal parameter binding은 같은 name을 가진 multiple parameter의 possibility를 deal하기 위해 preinitialized됩니다.

It is defined piecewise over the following productions:

BindingElement : BindingPattern Initializeropt
  1. value를 ? GetV(value, propertyName)로 설정한다.
  2. Initializer가 present이고 valueundefined이면, 다음을 수행한다.
    1. defaultValueInitializerEvaluation으로 ? 둔다.
    2. value를 ? GetValue(defaultValue)로 설정한다.
  3. arguments valueenvRecord를 가진 BindingPatternBindingInitialization을 ? 반환한다.
SingleNameBinding : BindingIdentifier Initializeropt
  1. bindingIdBindingIdentifierStringValue로 둔다.
  2. lhs를 ? ResolveBinding(bindingId, envRecord)로 둔다.
  3. value를 ? GetV(value, propertyName)로 설정한다.
  4. Initializer가 present이고 valueundefined이면, 다음을 수행한다.
    1. IsAnonymousFunctionDefinition(Initializer)이 true이면, 다음을 수행한다.
      1. value를 argument bindingId를 가진 InitializerNamedEvaluation으로 ? 설정한다.
    2. 그렇지 않으면,
      1. defaultValueInitializerEvaluation으로 ? 둔다.
      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)로 start할 수 없습니다. 그렇게 하면 Block과 ambiguous할 수 있기 때문입니다. ExpressionStatementfunction 또는 class keyword로 start할 수 없습니다. 그렇게 하면 FunctionDeclaration, GeneratorDeclaration 또는 ClassDeclaration과 ambiguous할 수 있기 때문입니다. ExpressionStatementasync function으로 start할 수 없습니다. 그렇게 하면 AsyncFunctionDeclaration 또는 AsyncGeneratorDeclaration과 ambiguous할 수 있기 때문입니다. ExpressionStatement는 two token sequence let [로 start할 수 없습니다. 그렇게 하면 first LexicalBindingArrayBindingPatternlet LexicalDeclaration과 ambiguous할 수 있기 때문입니다.

14.5.1 Runtime Semantics: Evaluation

ExpressionStatement : Expression ;
  1. exprRefExpressionEvaluation으로 ? 둔다.
  2. GetValue(exprRef)를 반환한다.

14.6 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]는 classic “dangling else” problem을 usual way로 resolve합니다. 즉, associated if의 choice가 otherwise ambiguous할 때, else는 candidate if 중 nearest (innermost)에 associated됩니다

14.6.1 Static Semantics: Early Errors

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

이 rule은 B.3.1에 specified된 extension이 implemented된 경우에만 apply할 필요가 있습니다.

14.6.2 Runtime Semantics: Evaluation

IfStatement : if ( Expression ) Statement else Statement
  1. exprRefExpressionEvaluation으로 ? 둔다.
  2. exprValueToBoolean(? GetValue(exprRef))로 둔다.
  3. exprValuetrue이면, 다음을 수행한다.
    1. stmtCompletion을 first StatementEvaluationCompletion으로 둔다.
  4. 그렇지 않으면,
    1. stmtCompletion을 second StatementEvaluationCompletion으로 둔다.
  5. UpdateEmpty(stmtCompletion, undefined)를 반환한다.
IfStatement : if ( Expression ) Statement
  1. exprRefExpressionEvaluation으로 ? 둔다.
  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]]을 contain하면, true를 반환한다.
  5. false를 반환한다.
Note

IterationStatementStatement part 안에서는 ContinueStatement가 new iteration을 begin하는 데 사용될 수 있습니다.

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. argument labelSet를 가진 DoWhileStatementDoWhileLoopEvaluation을 ? 반환한다.
IterationStatement : WhileStatement
  1. argument labelSet를 가진 WhileStatementWhileLoopEvaluation을 ? 반환한다.
IterationStatement : ForStatement
  1. argument labelSet를 가진 ForStatementForLoopEvaluation을 ? 반환한다.
IterationStatement : ForInOfStatement
  1. argument labelSet를 가진 ForInOfStatementForInOfLoopEvaluation을 ? 반환한다.

14.7.2 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에 specified된 extension이 implemented된 경우에만 apply할 필요가 있습니다.

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. Repeat,
    1. stmtResultStatementEvaluationCompletion으로 둔다.
    2. LoopContinues(stmtResult, labelSet)가 false이면, ? UpdateEmpty(stmtResult, iterationResult)를 반환한다.
    3. stmtResult.[[Value]]empty가 아니면, iterationResultstmtResult.[[Value]]로 설정한다.
    4. exprRefExpressionEvaluation으로 ? 둔다.
    5. exprValue를 ? GetValue(exprRef)로 둔다.
    6. ToBoolean(exprValue)가 false이면, iterationResult를 반환한다.

14.7.3 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에 specified된 extension이 implemented된 경우에만 apply할 필요가 있습니다.

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. Repeat,
    1. exprRefExpressionEvaluation으로 ? 둔다.
    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 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에 specified된 extension이 implemented된 경우에만 apply할 필요가 있습니다.

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. first Expression이 present이면, 다음을 수행한다.
    1. exprRef를 first ExpressionEvaluation으로 ? 둔다.
    2. GetValue(exprRef)를 수행한다.
  2. second Expression이 present이면 test를 second Expression으로 둔다; 그렇지 않으면 testempty로 둔다.
  3. third Expression이 present이면 increment를 third Expression으로 둔다; 그렇지 않으면 incrementempty로 둔다.
  4. ForBodyEvaluation(test, increment, Statement, « », labelSet)를 반환한다.
ForStatement : for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
  1. VariableDeclarationListEvaluation을 ? 수행한다.
  2. first Expression이 present이면 test를 first Expression으로 둔다; 그렇지 않으면 testempty로 둔다.
  3. second Expression이 present이면 increment를 second 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에 대해, 다음을 수행한다.
    1. isConsttrue이면,
      1. loopEnv.CreateImmutableBinding(name, true)를 수행한다.
    2. 그렇지 않으면,
      1. loopEnv.CreateMutableBinding(name, false)를 수행한다.
  6. 실행 중인 실행 컨텍스트의 LexicalEnvironment를 loopEnv로 설정한다.
  7. forDeclLexicalDeclarationEvaluationCompletion으로 둔다.
  8. forDecl이 abrupt 완료이면,
    1. forDeclCompletion(DisposeResources(loopEnv.[[DisposableResourceStack]], forDecl))로 설정한다.
    2. 단언: forDecl은 abrupt 완료이다.
    3. 실행 중인 실행 컨텍스트의 LexicalEnvironment를 oldEnv로 설정한다.
    4. forDecl을 반환한다.
  9. isConstfalse이면, perIterationLetsboundNames로 둔다. 그렇지 않으면 perIterationLets를 새 빈 List로 둔다.
  10. 첫 번째 Expression이 존재하면, test를 첫 번째 Expression으로 둔다. 그렇지 않으면 testempty로 둔다.
  11. 두 번째 Expression이 존재하면, increment를 두 번째 Expression으로 둔다. 그렇지 않으면 incrementempty로 둔다.
  12. bodyResultCompletion(ForBodyEvaluation(test, increment, Statement, perIterationLets, labelSet))으로 둔다.
  13. bodyResultCompletion(DisposeResources(loopEnv.[[DisposableResourceStack]], bodyResult))로 설정한다.
  14. 단언: bodyResult가 정상 완료이면, bodyResult.[[Value]]empty가 아니다.
  15. 실행 중인 실행 컨텍스트의 LexicalEnvironment를 oldEnv로 설정한다.
  16. 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. Repeat,
    1. testempty가 아니면, 다음을 수행한다.
      1. testReftestEvaluation으로 ? 둔다.
      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. incRefincrementEvaluation으로 ? 둔다.
      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. lastIterationEnv를 실행 중인 실행 컨텍스트의 LexicalEnvironment라고 하자.
    2. outerlastIterationEnv.[[OuterEnv]]라고 하자.
    3. Assert: outernull이 아니다.
    4. thisIterationEnvNewDeclarativeEnvironment(outer)라고 하자.
    5. perIterationBindings의 각 요소 name에 대해 다음을 수행한다.
      1. thisIterationEnv.CreateMutableBinding(name, false)를 수행한다.
      2. lastValue를 ? lastIterationEnv.GetBindingValue(name, true)라고 하자.
      3. thisIterationEnv.InitializeBinding(name, lastValue)를 수행한다.
    6. 실행 중인 실행 컨텍스트의 LexicalEnvironment를 thisIterationEnv로 설정한다.
  2. unused를 반환한다.

14.7.5 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에 의해 extended됩니다.

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에 specified된 extension이 implemented된 경우에만 apply할 필요가 있습니다.

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에 의해 extended됩니다.

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. arguments valueenvRecord를 가진 ForBindingBindingInitialization을 ? 반환한다.
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의 각 element 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에 대해, 다음을 수행한다.
    1. envRecord.CreateImmutableBinding(name, true)를 수행한다.
  2. unused를 반환한다.

14.7.5.5 Runtime Semantics: ForInOfLoopEvaluation

The syntax-directed operation ForInOfLoopEvaluation 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에 의해 extended됩니다.

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가 empty가 아니면, 다음을 수행한다.
    1. Assert: uninitializedBoundNames는 duplicate entry를 가지지 않는다.
    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이면,
    1. 단언: lhsForDeclaration이다.
    2. lhsIsAwaitUsingDeclarationtrue이면,
      1. declarationKindasync-dispose로 둔다.
    3. 그렇지 않고 lhsIsUsingDeclarationtrue이면,
      1. declarationKindsync-dispose로 둔다.
    4. 그렇지 않으면,
      1. declarationKindnormal로 둔다.
  5. 그렇지 않으면,
    1. declarationKindnormal로 둔다.
  6. destructuringlhsIsDestructuring으로 둔다.
  7. destructuringtrue이고 lhsKindassignment이면,
    1. 단언: lhsLeftHandSideExpression이다.
    2. assignmentPatternlhs가 cover하는 AssignmentPattern으로 둔다.
  8. 반복한다.
    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이면,
      1. destructuringtrue이면,
        1. lhsKindassignment이면,
          1. status를 인수 nextValueassignmentPatternDestructuringAssignmentEvaluationCompletion으로 둔다.
        2. 그렇지 않으면,
          1. 단언: lhsKindvar-binding이다.
          2. 단언: lhsForBinding이다.
          3. status를 인수 nextValueundefinedlhsBindingInitializationCompletion으로 둔다.
      2. 그렇지 않으면,
        1. lhsReflhsEvaluationCompletion으로 둔다. (반복해서 평가될 수 있다.)
        2. lhsKindassignment이고 lhsAssignmentTargetTypeweb-compat이면, ReferenceError 예외를 던진다.
        3. lhsRef가 abrupt 완료이면,
          1. statuslhsRef로 둔다.
        4. 그렇지 않으면,
          1. statusCompletion(PutValue(lhsRef.[[Value]], nextValue))로 둔다.
      3. iterationEnvundefined로 둔다.
    8. 그렇지 않으면,
      1. 단언: lhsKindlexical-binding이다.
      2. 단언: lhsForDeclaration이다.
      3. iterationEnvNewDeclarativeEnvironment(oldEnv)로 둔다.
      4. 인수 iterationEnvlhsForDeclarationBindingInstantiation을 수행한다.
      5. 실행 중인 실행 컨텍스트의 LexicalEnvironment를 iterationEnv로 설정한다.
      6. destructuringtrue이면,
        1. status를 인수 nextValueiterationEnvlhsForDeclarationBindingInitializationCompletion으로 둔다.
      7. 그렇지 않으면,
        1. 단언: lhs는 단일 이름을 바인딩한다.
        2. lhsNamelhsBoundNames의 유일한 요소로 둔다.
        3. lhsRef를 ! ResolveBinding(lhsName)으로 둔다.
        4. declarationKindnormal이 아니면,
          1. 단언: IsUnresolvableReference(lhsRef)는 false이다.
          2. baselhsRef.[[Base]]로 둔다.
          3. 단언: baseDeclarative Environment Record이다.
          4. statusCompletion(AddDisposableResource(base.[[DisposableResourceStack]], nextValue, declarationKind))로 둔다.
        5. 그렇지 않으면,
          1. statusNormalCompletion(unused)로 둔다.
        6. status가 정상 완료이면,
          1. statusCompletion(InitializeReferencedBinding(lhsRef, nextValue))로 설정한다.
    9. status가 abrupt 완료이면,
      1. iterationEnvundefined가 아니면,
        1. statusCompletion(DisposeResources(iterationEnv.[[DisposableResourceStack]], status))로 설정한다.
        2. 단언: status는 abrupt 완료이다.
      2. 실행 중인 실행 컨텍스트의 LexicalEnvironment를 oldEnv로 설정한다.
      3. iterationKindenumerate이면, ? status를 반환한다.
      4. 단언: iterationKinditerate이다.
      5. iteratorKindasync이면, ? AsyncIteratorClose(iteratorRecord, status)를 반환한다.
      6. IteratorClose(iteratorRecord, status)를 반환한다.
    10. resultstmtEvaluationCompletion으로 둔다.
    11. iterationEnvundefined가 아니면,
      1. resultCompletion(DisposeResources(iterationEnv.[[DisposableResourceStack]], result))로 설정한다.
    12. 실행 중인 실행 컨텍스트의 LexicalEnvironment를 oldEnv로 설정한다.
    13. LoopContinues(result, labelSet)가 false이면,
      1. statusCompletion(UpdateEmpty(result, iterationResult))로 설정한다.
      2. iterationKindenumerate이면, ? status를 반환한다.
      3. 단언: iterationKinditerate이다.
      4. iteratorKindasync이면, ? AsyncIteratorClose(iteratorRecord, status)를 반환한다.
      5. 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 property의 모든 String-valued key를 iterate하는 next method를 가진 iterator object를 반환한다. iterator object는 ECMAScript code에 의해 never directly accessible하지 않다. property를 enumerating하는 mechanics와 order는 specified되어 있지 않지만, 아래 specified된 rule에 conform해야 한다.

iteratorthrowreturn method는 null이며 never invoked되지 않습니다. iteratornext method는 property keyiterator value로 returned되어야 하는지 determine하기 위해 object property를 process합니다. returned property key는 Symbol인 key를 include하지 않습니다. target object의 property는 enumeration 중에 deleted될 수 있습니다. iteratornext method에 의해 processed되기 전에 deleted된 property는 ignored됩니다. enumeration 중에 target object에 새 property가 added되면, newly added property가 active enumeration에서 processed된다는 guarantee는 없습니다. property name은 어떤 enumeration에서든 iteratornext method에 의해 at most once returned됩니다.

target object의 property를 enumerating하는 것은 그 prototype의 property, 그 prototype의 prototype 등을 recursively enumerating하는 것을 include합니다; 그러나 prototype의 property는 같은 name을 가진 property가 iteratornext method에 의해 이미 processed되었으면 processed되지 않습니다. prototype object의 property가 이미 processed되었는지 determine할 때 [[Enumerable]] attribute의 value는 considered되지 않습니다. prototype object의 enumerable property name은 prototype object를 argument로 passing하여 EnumerateObjectProperties를 invoking함으로써 obtained되어야 합니다. EnumerateObjectProperties는 target object의 [[OwnPropertyKeys]] internal method를 calling하여 own property key를 obtain해야 합니다. target object의 Property attribute는 그 [[GetOwnProperty]] internal method를 calling하여 obtained되어야 합니다.

추가로, obj도 그 prototype chain 안의 어떤 object도 Proxy exotic object, TypedArray, module namespace exotic object 또는 implementation provided exotic object가 아니면, iterator는 다음 중 하나가 occur할 때까지 CreateForInIterator(obj)가 given한 iterator처럼 behave해야 합니다:

  • obj 또는 그 prototype chain 안의 object의 [[Prototype]] internal slot의 value가 changes,
  • obj 또는 그 prototype chain 안의 object에서 property가 removed,
  • obj의 prototype chain 안의 object에 property가 added, 또는
  • obj 또는 그 prototype chain 안의 object의 property의 [[Enumerable]] attribute value가 changes.
Note 1

ECMAScript implementation은 14.7.5.10.2.1의 algorithm을 directly implement할 필요가 없습니다. previous paragraph의 constraint 중 하나가 violated되지 않는 한 그 algorithm에서 deviate하지 않을 behaviour를 가진 어떤 implementation이라도 choose할 수 있습니다.

다음은 이러한 rule에 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
implementation이 CreateForInIterator와 match할 필요가 없는 exotic object의 list는, implementation이 historically those case에서 behaviour가 differed했고, all others에서는 agreed했기 때문에 chosen되었습니다.

14.7.5.10 For-In Iterator Objects

For-In Iterator는 어떤 specific object에 대한 specific iteration을 represent하는 object입니다. For-In Iterator object는 ECMAScript code에 의해 never directly accessible하지 않으며, 오직 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 property를 specific order로 iterate하는 For-In Iterator object를 create하는 데 사용됩니다. 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]]를 새 empty List로 설정한다.
  5. iterator.[[RemainingKeys]]를 새 empty List로 설정한다.
  6. iterator를 반환한다.

14.7.5.10.2 %ForInIteratorPrototype% Object

%ForInIteratorPrototype% object:

  • 모든 For-In Iterator object에 의해 inherited되는 property를 가집니다.
  • ordinary object입니다.
  • value가 %Iterator.prototype%[[Prototype]] internal slot을 가집니다.
  • ECMAScript code에 의해 never directly accessible하지 않습니다.
  • 다음 property를 가집니다:

14.7.5.10.2.1 %ForInIteratorPrototype%.next ( )

  1. iteratorthis value로 둔다.
  2. Assert: iterator는 Object이다.
  3. Assert: iteratorFor-In Iterator instance(14.7.5.10.3)의 모든 internal slot을 가진다.
  4. objiterator.[[Object]]로 둔다.
  5. Repeat,
    1. iterator.[[ObjectWasVisited]]false이면, 다음을 수행한다.
      1. keys를 ? obj.[[OwnPropertyKeys]]()로 둔다.
      2. keys의 각 element key에 대해, 다음을 수행한다.
        1. key가 String이면, 다음을 수행한다.
          1. keyiterator.[[RemainingKeys]]에 append한다.
      3. iterator.[[ObjectWasVisited]]true로 설정한다.
    2. iterator.[[RemainingKeys]]가 empty가 아닌 동안 Repeat,
      1. keyiterator.[[RemainingKeys]]의 first element로 둔다.
      2. iterator.[[RemainingKeys]]에서 first element를 remove한다.
      3. iterator.[[VisitedKeys]]key를 contain하지 않으면, 다음을 수행한다.
        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 instance는 %ForInIteratorPrototype% intrinsic object로부터 property를 inherit하는 ordinary object입니다. For-In Iterator instance는 Table 34에 listed된 internal slot으로 initially created됩니다.

Table 34: Internal Slots of For-In Iterator Instances
Internal Slot Type Description
[[Object]] an Object property가 iterated되고 있는 Object value입니다.
[[ObjectWasVisited]] a Boolean iterator[[Object]]에 대해 [[OwnPropertyKeys]]를 invoked했으면 true, otherwise false입니다.
[[VisitedKeys]] a List of Strings iterator가 thus far emitted한 value입니다.
[[RemainingKeys]] a List of Strings 그 prototype의 property를 iterating하기 전에(그 prototype이 null이 아니면), current object에 대해 emitted될 remaining value입니다.

14.8 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 boundary를 crossing하지 않고) 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 break Statement

Syntax

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

14.9.1 Static Semantics: Early Errors

BreakStatement : break ;

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 return Statement

Syntax

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

return statement는 function이 execution을 cease하게 하고, 대부분의 경우 caller에게 value를 return합니다. Expression이 omitted되면, return value는 undefined입니다. 그렇지 않으면 return value는 Expression의 value입니다. surrounding context에 따라 return statement가 actually caller에게 value를 return하지 않을 수도 있습니다. 예를 들어 try block 안에서, return statement의 Completion Recordfinally block의 evaluation 중에 another Completion Record로 replaced될 수 있습니다.

14.10.1 Runtime Semantics: Evaluation

ReturnStatement : return ;
  1. ReturnCompletion(undefined)를 반환한다.
ReturnStatement : return Expression ;
  1. exprRefExpressionEvaluation으로 ? 둔다.
  2. exprValue를 ? GetValue(exprRef)로 둔다.
  3. GetGeneratorKind()가 async이면, exprValue를 ? Await(exprValue)로 설정한다.
  4. ReturnCompletion(exprValue)를 반환한다.

14.11 with Statement

Note 1

새 ECMAScript code에서는 Legacy with statement의 use가 discouraged됩니다. strict mode codenon-strict code 모두에서 permitted되는 alternative, 예를 들어 destructuring assignment를 consider하십시오.

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에 adds합니다. 그런 다음 이 augmented lexical environment를 사용하여 statement를 executes합니다. Finally, original lexical environment를 restores합니다.

14.11.1 Static Semantics: Early Errors

WithStatement : with ( Expression ) Statement Note

second rule은 B.3.1에 specified된 extension이 implemented된 경우에만 apply할 필요가 있습니다.

14.11.2 Runtime Semantics: Evaluation

WithStatement : with ( Expression ) Statement
  1. valueExpressionEvaluation으로 ? 둔다.
  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를 어떻게 leave하든, normally든 어떤 form의 abrupt completion 또는 exception에 의해서든, LexicalEnvironment는 항상 former state로 restored됩니다.

14.12 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 item의 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. first CaseClauses가 present이면, 다음을 수행한다.
    1. caseClauses를 source text order의 first CaseClauses 안의 CaseClause item의 List로 둔다.
  3. 그렇지 않으면,
    1. caseClauses를 새 empty 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. second CaseClauses가 present이면, 다음을 수행한다.
    1. secondCaseClauses를 source text order의 second CaseClauses 안의 CaseClause item의 List로 둔다.
  8. 그렇지 않으면,
    1. secondCaseClauses를 새 empty 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: 다음은 second CaseClauses의 또 다른 complete 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하는지 determine합니다. It performs the following steps when called:

  1. Assert: caseClauseNode는 production CaseClause : case Expression : StatementListopt 의 instance이다.
  2. exprRefcaseClauseNodeExpressionEvaluation으로 ? 둔다.
  3. clauseSelector를 ? GetValue(exprRef)로 둔다.
  4. IsStrictlyEqual(input, clauseSelector)를 반환한다.
Note

이 operation은 caseClauseNodeStatementList(있는 경우)를 execute하지 않습니다. CaseBlock algorithm은 어떤 StatementList를 executing 시작할지 determine하기 위해 그 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. 단언: blockEnv.[[DisposableResourceStack]]은 빈 List이다.
  9. 실행 중인 실행 컨텍스트의 LexicalEnvironment를 oldEnv로 설정한다.
  10. blockResult를 반환한다.
Note

control이 SwitchStatement를 어떻게 leave하든 LexicalEnvironment는 항상 former state로 restored됩니다.

CaseClause : case Expression :
  1. empty를 반환한다.
CaseClause : case Expression : StatementList
  1. StatementListEvaluation을 ? 반환한다.
DefaultClause : default :
  1. empty를 반환한다.
DefaultClause : default : StatementList
  1. StatementListEvaluation을 ? 반환한다.

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로 prefixed될 수 있습니다. Labelled statement는 labelled breakcontinue statement와 conjunction에서만 사용됩니다. ECMAScript에는 goto statement가 없습니다. StatementLabelledStatement의 part가 될 수 있고, 그 자체가 LabelledStatement의 part가 될 수 있으며, 이런 식으로 계속될 수 있습니다. 이런 way로 introduced된 label은 individual statement의 semantics를 describing할 때 collectively “current label set”이라고 referred됩니다.

14.13.1 Static Semantics: Early Errors

LabelledItem : FunctionDeclaration
  • 이 production에 의해 어떤 source text든 matched되면 Syntax Error입니다. 단, 그 source text가 non-strict code이고 host가 web browser이거나 그 밖에 Labelled Function Declarations를 support하는 경우는 예외입니다.

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. argument « »를 가진 this LabelledStatementLabelledEvaluation을 ? 반환한다.

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를 argument 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를 통해 exited될 수 있는 것입니다.

LabelledStatement : LabelIdentifier : LabelledItem
  1. labelLabelIdentifierStringValue로 둔다.
  2. newLabelSetlabelSet와 « label »의 list-concatenation으로 둔다.
  3. stmtResult를 argument newLabelSet를 가진 LabelledItemLabelledEvaluationCompletion으로 둔다.
  4. stmtResultbreak completion이고 stmtResult.[[Target]]label이면, 다음을 수행한다.
    1. stmtResultNormalCompletion(stmtResult.[[Value]])로 설정한다.
  5. stmtResult를 반환한다.
LabelledItem : FunctionDeclaration
  1. FunctionDeclarationEvaluation을 ? 반환한다.
Statement : BlockStatement VariableStatement EmptyStatement ExpressionStatement IfStatement ContinueStatement BreakStatement ReturnStatement WithStatement ThrowStatement TryStatement DebuggerStatement
  1. StatementEvaluation을 ? 반환한다.
Note 2

LabelledEvaluation을 위한 special semantics를 가진 Statement의 only two production은 BreakableStatementLabelledStatement입니다.

14.14 throw Statement

Syntax

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

14.14.1 Runtime Semantics: Evaluation

ThrowStatement : throw Expression ;
  1. exprRefExpressionEvaluation으로 ? 둔다.
  2. exprValue를 ? GetValue(exprRef)로 둔다.
  3. exprValue를 Throw한다.

14.15 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이 occur할 수 있는 code block을 encloses합니다. catch clause는 exception-handling code를 제공합니다. catch clause가 exception을 catches하면, 그 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의 각 element argName에 대해, 다음을 수행한다.
    1. catchEnv.CreateMutableBinding(argName, false)를 수행한다.
  4. running execution context의 LexicalEnvironment를 catchEnv로 설정한다.
  5. status를 arguments thrownValuecatchEnv를 가진 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. BlockEvaluation을 ? 반환한다.
Note

control이 Block을 어떻게 leave하든 LexicalEnvironment는 항상 former state로 restored됩니다.

14.15.3 Runtime Semantics: Evaluation

TryStatement : try Block Catch
  1. blockResultBlockEvaluationCompletion으로 둔다.
  2. blockResultthrow completion이면 catchResult를 argument 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를 argument blockResult.[[Value]]를 가진 CatchCatchClauseEvaluationCompletion으로 둔다.
  3. 그렇지 않으면 catchResultblockResult로 둔다.
  4. finallyResultFinallyEvaluationCompletion으로 둔다.
  5. finallyResultnormal completion이면, finallyResultcatchResult로 설정한다.
  6. UpdateEmpty(finallyResult, undefined)를 반환한다.

14.16 debugger Statement

Syntax

DebuggerStatement : debugger ;

14.16.1 Runtime Semantics: Evaluation

Note

DebuggerStatement를 evaluating하면 implementation이 debugger 아래에서 run될 때 breakpoint를 cause할 수 있습니다. debugger가 present하지 않거나 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를 반환한다.