ECMA-262 (12th Edition) ECMAScript 2021 Language Specification - page 46

 

  Главная      Manuals     ECMA-262 (12th Edition) ECMAScript 2021 Language Specification

 

Search            copyright infringement  

 

 

 

 

 

 

 

 

 

 

 

Content      ..     44      45      46      47     ..

 

 

 

ECMA-262 (12th Edition) ECMAScript 2021 Language Specification - page 46

 

 

NOTE 2

A For-In Iterator is an object that represents a specific iteration over some specific object. For-In Iterator objects are
never directly accessible to ECMAScript code; they exist solely to illustrate the behaviour of

EnumerateObjectProperties

.

The abstract operation CreateForInIterator takes argument 

object

. It is used to create a For-In Iterator object which

iterates over the own and inherited enumerable string properties of 

object

 in a specific order. It performs the following

steps when called:

1. 

Assert

Type

(

object

) is Object.

2.  Let 

iterator

 be ! 

OrdinaryObjectCreate

(

%ForInIteratorPrototype%

, « [[Object]], [[ObjectWasVisited]],

[[VisitedKeys]], [[RemainingKeys]] »).

3.  Set 

iterator

.[[Object]] to 

object

.

4.  Set 

iterator

.[[ObjectWasVisited]] to 

false

.

5.  Set 

iterator

.[[VisitedKeys]] to a new empty 

List

.

6.  Set 

iterator

.[[RemainingKeys]] to a new empty 

List

.

7.  Return 

iterator

.

The 

%ForInIteratorPrototype%

 object:

has properties that are inherited by all For-In Iterator Objects.
is an 

ordinary object

.

has a [[Prototype]] internal slot whose value is 

%IteratorPrototype%

.

is never directly accessible to ECMAScript code.
has the following properties:

1.  Let 

O

 be the 

this

 value.

2. 

Assert

Type

(

O

) is Object.

3. 

Assert

O

 has all of the internal slots of a For-In Iterator Instance (

14.7.5.10.3

).

4.  Let 

object

 be 

O

.[[Object]].

5.  Let 

visited

 be 

O

.[[VisitedKeys]].

6.  Let 

remaining

 be 

O

.[[RemainingKeys]].

7.  Repeat,

a.  If 

O

.[[ObjectWasVisited]] is 

false

, then

i.  Let 

keys

 be ? 

object

.[[OwnPropertyKeys]]().

ii.  For each element 

key

 of 

keys

, do

1.  If 

Type

(

key

) is String, then

a.  Append 

key

 to 

remaining

.

The list of exotic objects for which implementations are not required to match 

CreateForInIterator

was chosen because implementations historically differed in behaviour for those cases, and
agreed in all others.

14.7.5.10  For-In Iterator Objects

14.7.5.10.1  CreateForInIterator ( 

object

 )

14.7.5.10.2  The %ForInIteratorPrototype% Object

14.7.5.10.2.1  %ForInIteratorPrototype%.next ( )

378

iii.  Set 

O

.[[ObjectWasVisited]] to 

true

.

b.  Repeat, while 

remaining

 is not empty,

i.  Let 

r

 be the first element of 

remaining

.

ii.  Remove the first element from 

remaining

.

iii.  If there does not exist an element 

v

 of 

visited

 such that 

SameValue

(

r

v

) is 

true

, then

1.  Let 

desc

 be ? 

object

.[[GetOwnProperty]](

r

).

2.  If 

desc

 is not 

undefined

, then

a.  Append 

r

 to 

visited

.

b.  If 

desc

.[[Enumerable]] is 

true

, return 

CreateIterResultObject

(

r

false

).

c.  Set 

object

 to ? 

object

.[[GetPrototypeOf]]().

d.  Set 

O

.[[Object]] to 

object

.

e.  Set 

O

.[[ObjectWasVisited]] to 

false

.

f.  If 

object

 is 

null

, return 

CreateIterResultObject

(

undefined

true

).

For-In Iterator instances are ordinary objects that inherit properties from the 

%ForInIteratorPrototype%

 intrinsic

object. For-In Iterator instances are initially created with the internal slots listed in 

Table 38

.

Table 38: Internal Slots of For-In Iterator Instances

Internal Slot

Description

[[Object]]

The Object value whose properties are being iterated.

[[ObjectWasVisited]]

true

 if the iterator has invoked [[OwnPropertyKeys]] on [[Object]], 

false

 otherwise.

[[VisitedKeys]]

A list of String values which have been emitted by this iterator thus far.

[[RemainingKeys]]

A list of String values remaining to be emitted for the current object, before iterating the
properties of its prototype (if its prototype is not 

null

).

ContinueStatement

[Yield, Await]

 

:

continue

 

;

continue

 [no 

LineTerminator

 here]  

LabelIdentifier

[?Yield, ?Await]

 

;

ContinueStatement

 

:

continue

 

;

continue

 

LabelIdentifier

 

;

It is a Syntax Error if this 

ContinueStatement

 is not nested, directly or indirectly (but not crossing function

boundaries), within an 

IterationStatement

.

14.7.5.10.3  Properties of For-In Iterator Instances

14.8  The 

continue

continue

 Statement

Syntax

14.8.1  Static Semantics: Early Errors

379

ContinueStatement

 

:

 

continue

 

;

1.  Return 

Completion

 { [[Type]]: 

continue

, [[Value]]: 

empty

, [[Target]]: 

empty

 }.

ContinueStatement

 

:

 

continue

 

LabelIdentifier

 

;

1.  Let 

label

 be the 

StringValue

 of 

LabelIdentifier

.

2.  Return 

Completion

 { [[Type]]: 

continue

, [[Value]]: 

empty

, [[Target]]: 

label

 }.

BreakStatement

[Yield, Await]

 

:

break

 

;

break

 [no 

LineTerminator

 here]  

LabelIdentifier

[?Yield, ?Await]

 

;

BreakStatement

 

:

 

break

 

;

It is a Syntax Error if this 

BreakStatement

 is not nested, directly or indirectly (but not crossing function

boundaries), within an 

IterationStatement

 or a 

SwitchStatement

.

BreakStatement

 

:

 

break

 

;

1.  Return 

Completion

 { [[Type]]: 

break

, [[Value]]: 

empty

, [[Target]]: 

empty

 }.

BreakStatement

 

:

 

break

 

LabelIdentifier

 

;

1.  Let 

label

 be the 

StringValue

 of 

LabelIdentifier

.

2.  Return 

Completion

 { [[Type]]: 

break

, [[Value]]: 

empty

, [[Target]]: 

label

 }.

ReturnStatement

[Yield, Await]

 

:

return

 

;

return

 [no 

LineTerminator

 here]  

Expression

[+In, ?Yield, ?Await]

 

;

14.8.2  Runtime Semantics: Evaluation

14.9  The 

break

break

 Statement

Syntax

14.9.1  Static Semantics: Early Errors

14.9.2  Runtime Semantics: Evaluation

14.10  The 

return

return

 Statement

Syntax

380

NOTE

ReturnStatement

 

:

 

return

 

;

1.  Return 

Completion

 { [[Type]]: 

return

, [[Value]]: 

undefined

, [[Target]]: 

empty

 }.

ReturnStatement

 

:

 

return

 

Expression

 

;

1.  Let 

exprRef

 be the result of evaluating 

Expression

.

2.  Let 

exprValue

 be ? 

GetValue

(

exprRef

).

3.  If ! 

GetGeneratorKind

() is 

async

, set 

exprValue

 to ? 

Await

(

exprValue

).

4.  Return 

Completion

 { [[Type]]: 

return

, [[Value]]: 

exprValue

, [[Target]]: 

empty

 }.

WithStatement

[Yield, Await, Return]

 

:

with

 

(

 

Expression

[+In, ?Yield, ?Await]

 

)

 

Statement

[?Yield, ?Await, ?Return]

NOTE

WithStatement

 

:

 

with

 

(

 

Expression

 

)

 

Statement

It is a Syntax Error if the code that matches this production is contained in 

strict mode code

.

It is a Syntax Error if 

IsLabelledFunction

(

Statement

) is 

true

.

NOTE

WithStatement

 

:

 

with

 

(

 

Expression

 

)

 

Statement

1.  Let 

val

 be the result of evaluating 

Expression

.

2.  Let 

obj

 be ? 

ToObject

(? 

GetValue

(

val

)).

3.  Let 

oldEnv

 be the 

running execution context

's LexicalEnvironment.

return

return

 statement causes a function to cease execution and, in most cases, returns a value to

the caller. If 

Expression

 is omitted, the return value is 

undefined

. Otherwise, the return value is

the value of 

Expression

. A 

return

return

 statement may not actually return a value to the caller

depending on surrounding context. For example, in a 

try

try

 block, a 

return

return

 statement's

completion record may be replaced with another completion record during evaluation of the

finally

finally

 block.

The 

with

with

 statement adds an 

object Environment Record

 for a computed object to the lexical

environment of the 

running execution context

. It then executes a statement using this augmented

lexical environment. Finally, it restores the original lexical environment.

It is only necessary to apply the second rule if the extension specified in 

B.3.2

 is implemented.

14.10.1  Runtime Semantics: Evaluation

14.11  The 

with

with

 Statement

Syntax

14.11.1  Static Semantics: Early Errors

14.11.2  Runtime Semantics: Evaluation

381

4.  Let 

newEnv

 be 

NewObjectEnvironment

(

obj

oldEnv

).

5.  Set the 

withEnvironment

 flag of 

newEnv

 to 

true

.

6.  Set the 

running execution context

's LexicalEnvironment to 

newEnv

.

7.  Let 

C

 be the result of evaluating 

Statement

.

8.  Set the 

running execution context

's LexicalEnvironment to 

oldEnv

.

9.  Return 

Completion

(

UpdateEmpty

(

C

undefined

)).

NOTE

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

SwitchStatement

 

:

 

switch

 

(

 

Expression

 

)

 

CaseBlock

It is a Syntax Error if the 

LexicallyDeclaredNames

 of 

CaseBlock

 contains any duplicate entries.

It is a Syntax Error if any element of the 

LexicallyDeclaredNames

 of 

CaseBlock

 also occurs in the

VarDeclaredNames

 of 

CaseBlock

.

With parameter 

input

.

CaseBlock

 

:

 

{

 

}

1.  Return 

NormalCompletion

(

undefined

).

No matter how control leaves the embedded 

Statement

, whether normally or by some form of

abrupt completion

 or exception, the LexicalEnvironment is always restored to its former state.

14.12  The 

switch

switch

 Statement

Syntax

14.12.1  Static Semantics: Early Errors

14.12.2  Runtime Semantics: CaseBlockEvaluation

382

CaseBlock

 

:

 

{

 

CaseClauses

 

}

1.  Let 

V

 be 

undefined

.

2.  Let 

A

 be the 

List

 of 

CaseClause

 items in 

CaseClauses

, in source text order.

3.  Let 

found

 be 

false

.

4.  For each 

CaseClause

 

C

 of 

A

, do

a.  If 

found

 is 

false

, then

i.  Set 

found

 to ? 

CaseClauseIsSelected

(

C

input

).

b.  If 

found

 is 

true

, then

i.  Let 

R

 be the result of evaluating 

C

.

ii.  If 

R

.[[Value]] is not 

empty

, set 

V

 to 

R

.[[Value]].

iii.  If 

R

 is an 

abrupt completion

, return 

Completion

(

UpdateEmpty

(

R

V

)).

5.  Return 

NormalCompletion

(

V

).

CaseBlock

 

:

 

{

 

CaseClauses

opt

 

DefaultClause

 

CaseClauses

opt

 

}

1.  Let 

V

 be 

undefined

.

2.  If the first 

CaseClauses

 is present, then

a.  Let 

A

 be the 

List

 of 

CaseClause

 items in the first 

CaseClauses

, in source text order.

3.  Else,

a.  Let 

A

 be « ».

4.  Let 

found

 be 

false

.

5.  For each 

CaseClause

 

C

 of 

A

, do

a.  If 

found

 is 

false

, then

i.  Set 

found

 to ? 

CaseClauseIsSelected

(

C

input

).

b.  If 

found

 is 

true

, then

i.  Let 

R

 be the result of evaluating 

C

.

ii.  If 

R

.[[Value]] is not 

empty

, set 

V

 to 

R

.[[Value]].

iii.  If 

R

 is an 

abrupt completion

, return 

Completion

(

UpdateEmpty

(

R

V

)).

6.  Let 

foundInB

 be 

false

.

7.  If the second 

CaseClauses

 is present, then

a.  Let 

B

 be the 

List

 of 

CaseClause

 items in the second 

CaseClauses

, in source text order.

8.  Else,

a.  Let 

B

 be « ».

9.  If 

found

 is 

false

, then

a.  For each 

CaseClause

 

C

 of 

B

, do

i.  If 

foundInB

 is 

false

, then

1.  Set 

foundInB

 to ? 

CaseClauseIsSelected

(

C

input

).

ii.  If 

foundInB

 is 

true

, then

1.  Let 

R

 be the result of evaluating 

CaseClause

 

C

.

2.  If 

R

.[[Value]] is not 

empty

, set 

V

 to 

R

.[[Value]].

3.  If 

R

 is an 

abrupt completion

, return 

Completion

(

UpdateEmpty

(

R

V

)).

10.  If 

foundInB

 is 

true

, return 

NormalCompletion

(

V

).

11.  Let 

R

 be the result of evaluating 

DefaultClause

.

12.  If 

R

.[[Value]] is not 

empty

, set 

V

 to 

R

.[[Value]].

13.  If 

R

 is an 

abrupt completion

, return 

Completion

(

UpdateEmpty

(

R

V

)).

14.  NOTE: The following is another complete iteration of the second 

CaseClauses

.

15.  For each 

CaseClause

 

C

 of 

B

, do

383

a.  Let 

R

 be the result of evaluating 

CaseClause

 

C

.

b.  If 

R

.[[Value]] is not 

empty

, set 

V

 to 

R

.[[Value]].

c.  If 

R

 is an 

abrupt completion

, return 

Completion

(

UpdateEmpty

(

R

V

)).

16.  Return 

NormalCompletion

(

V

).

The abstract operation CaseClauseIsSelected takes arguments 

C

 (a 

Parse Node

 for 

CaseClause

) and 

input

 (an

ECMAScript language value

). It determines whether 

C

 matches 

input

. It performs the following steps when called:

1. 

Assert

C

 is an instance of the production 

CaseClause

 

:

 

case

 

Expression

 

:

 

StatementList

opt

 .

2.  Let 

exprRef

 be the result of evaluating the 

Expression

 of 

C

.

3.  Let 

clauseSelector

 be ? 

GetValue

(

exprRef

).

4.  Return the result of performing 

Strict Equality Comparison

 

input

 === 

clauseSelector

.

NOTE

SwitchStatement

 

:

 

switch

 

(

 

Expression

 

)

 

CaseBlock

1.  Let 

exprRef

 be the result of evaluating 

Expression

.

2.  Let 

switchValue

 be ? 

GetValue

(

exprRef

).

3.  Let 

oldEnv

 be the 

running execution context

's LexicalEnvironment.

4.  Let 

blockEnv

 be 

NewDeclarativeEnvironment

(

oldEnv

).

5.  Perform 

BlockDeclarationInstantiation

(

CaseBlock

blockEnv

).

6.  Set the 

running execution context

's LexicalEnvironment to 

blockEnv

.

7.  Let 

R

 be 

CaseBlockEvaluation

 of 

CaseBlock

 with argument 

switchValue

.

8.  Set the 

running execution context

's LexicalEnvironment to 

oldEnv

.

9.  Return 

R

.

NOTE

CaseClause

 

:

 

case

 

Expression

 

:

1.  Return 

NormalCompletion

(

empty

).

CaseClause

 

:

 

case

 

Expression

 

:

 

StatementList

1.  Return the result of evaluating 

StatementList

.

DefaultClause

 

:

 

default

 

:

1.  Return 

NormalCompletion

(

empty

).

DefaultClause

 

:

 

default

 

:

 

StatementList

1.  Return the result of evaluating 

StatementList

.

This operation does not execute 

C

's 

StatementList

 (if any). The 

CaseBlock

 algorithm uses its return

value to determine which 

StatementList

 to start executing.

No matter how control leaves the 

SwitchStatement

 the LexicalEnvironment is always restored to

its former state.

14.12.3  CaseClauseIsSelected ( 

C

input

 )

14.12.4  Runtime Semantics: Evaluation

384

LabelledStatement

[Yield, Await, Return]

 

:

LabelIdentifier

[?Yield, ?Await]

 

:

 

LabelledItem

[?Yield, ?Await, ?Return]

LabelledItem

[Yield, Await, Return]

 

:

Statement

[?Yield, ?Await, ?Return]

FunctionDeclaration

[?Yield, ?Await, ~Default]

NOTE

LabelledItem

 

:

 

FunctionDeclaration

It is a Syntax Error if any source text matches this rule.

NOTE

The abstract operation IsLabelledFunction takes argument 

stmt

. It performs the following steps when called:

1.  If 

stmt

 is not a 

LabelledStatement

, return 

false

.

2.  Let 

item

 be the 

LabelledItem

 of 

stmt

.

3.  If 

item

 is 

LabelledItem

 

:

 

FunctionDeclaration

 , return 

true

.

4.  Let 

subStmt

 be the 

Statement

 of 

item

.

5.  Return 

IsLabelledFunction

(

subStmt

).

LabelledStatement

 

:

 

LabelIdentifier

 

:

 

LabelledItem

1.  Let 

newLabelSet

 be a new empty 

List

.

2.  Return 

LabelledEvaluation

 of this 

LabelledStatement

 with argument 

newLabelSet

.

With parameter 

labelSet

.

BreakableStatement

 

:

 

IterationStatement

Statement

 may be prefixed by a label. Labelled statements are only used in conjunction with

labelled 

break

break

 and 

continue

continue

 statements. ECMAScript has no 

goto

goto

 statement. A 

Statement

can be part of a 

LabelledStatement

, which itself can be part of a 

LabelledStatement

, and so on. The

labels introduced this way are collectively referred to as the “current label set” when describing
the semantics of individual statements.

An alternative definition for this rule is provided in 

B.3.2

.

14.13  Labelled Statements

Syntax

14.13.1  Static Semantics: Early Errors

14.13.2  Static Semantics: IsLabelledFunction ( 

stmt

 )

14.13.3  Runtime Semantics: Evaluation

14.13.4  Runtime Semantics: LabelledEvaluation

385

1.  Let 

stmtResult

 be 

LoopEvaluation

 of 

IterationStatement

 with argument 

labelSet

.

2.  If 

stmtResult

.[[Type]] is 

break

, then

a.  If 

stmtResult

.[[Target]] is 

empty

, then

i.  If 

stmtResult

.[[Value]] is 

empty

, set 

stmtResult

 to 

NormalCompletion

(

undefined

).

ii.  Else, set 

stmtResult

 to 

NormalCompletion

(

stmtResult

.[[Value]]).

3.  Return 

Completion

(

stmtResult

).

BreakableStatement

 

:

 

SwitchStatement

1.  Let 

stmtResult

 be the result of evaluating 

SwitchStatement

.

2.  If 

stmtResult

.[[Type]] is 

break

, then

a.  If 

stmtResult

.[[Target]] is 

empty

, then

i.  If 

stmtResult

.[[Value]] is 

empty

, set 

stmtResult

 to 

NormalCompletion

(

undefined

).

ii.  Else, set 

stmtResult

 to 

NormalCompletion

(

stmtResult

.[[Value]]).

3.  Return 

Completion

(

stmtResult

).

NOTE 1

LabelledStatement

 

:

 

LabelIdentifier

 

:

 

LabelledItem

1.  Let 

label

 be the 

StringValue

 of 

LabelIdentifier

.

2.  Append 

label

 as an element of 

labelSet

.

3.  Let 

stmtResult

 be 

LabelledEvaluation

 of 

LabelledItem

 with argument 

labelSet

.

4.  If 

stmtResult

.[[Type]] is 

break

 and 

SameValue

(

stmtResult

.[[Target]], 

label

) is 

true

, then

a.  Set 

stmtResult

 to 

NormalCompletion

(

stmtResult

.[[Value]]).

5.  Return 

Completion

(

stmtResult

).

LabelledItem

 

:

 

FunctionDeclaration

1.  Return the result of evaluating 

FunctionDeclaration

.

Statement

 

:

BlockStatement
VariableStatement
EmptyStatement
ExpressionStatement
IfStatement
ContinueStatement
BreakStatement
ReturnStatement
WithStatement
ThrowStatement
TryStatement
DebuggerStatement

1.  Return the result of evaluating 

Statement

.

BreakableStatement

 is one that can be exited via an unlabelled 

BreakStatement

.

386

NOTE 2

ThrowStatement

[Yield, Await]

 

:

throw

 [no 

LineTerminator

 here]  

Expression

[+In, ?Yield, ?Await]

 

;

ThrowStatement

 

:

 

throw

 

Expression

 

;

1.  Let 

exprRef

 be the result of evaluating 

Expression

.

2.  Let 

exprValue

 be ? 

GetValue

(

exprRef

).

3.  Return 

ThrowCompletion

(

exprValue

).

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

The only two productions of 

Statement

 which have special semantics for LabelledEvaluation are 

BreakableStatement

 and 

LabelledStatement

.

The 

try

try

 statement encloses a block of code in which an exceptional condition can occur, such as

a runtime error or a 

throw

throw

 statement. The 

catch

catch

 clause provides the exception-handling code.

When a catch clause catches an exception, its 

CatchParameter

 is bound to that exception.

14.14  The 

throw

throw

 Statement

Syntax

14.14.1  Runtime Semantics: Evaluation

14.15  The 

try

try

 Statement

Syntax

14.15.1  Static Semantics: Early Errors

387

Catch

 

:

 

catch

 

(

 

CatchParameter

 

)

 

Block

It is a Syntax Error if 

BoundNames

 of 

CatchParameter

 contains any duplicate elements.

It is a Syntax Error if any element of the 

BoundNames

 of 

CatchParameter

 also occurs in the

LexicallyDeclaredNames

 of 

Block

.

It is a Syntax Error if any element of the 

BoundNames

 of 

CatchParameter

 also occurs in the 

VarDeclaredNames

of 

Block

.

NOTE

With parameter 

thrownValue

.

Catch

 

:

 

catch

 

(

 

CatchParameter

 

)

 

Block

1.  Let 

oldEnv

 be the 

running execution context

's LexicalEnvironment.

2.  Let 

catchEnv

 be 

NewDeclarativeEnvironment

(

oldEnv

).

3.  For each element 

argName

 of the 

BoundNames

 of 

CatchParameter

, do

a.  Perform ! 

catchEnv

.CreateMutableBinding(

argName

false

).

4.  Set the 

running execution context

's LexicalEnvironment to 

catchEnv

.

5.  Let 

status

 be 

BindingInitialization

 of 

CatchParameter

 with arguments 

thrownValue

 and 

catchEnv

.

6.  If 

status

 is an 

abrupt completion

, then

a.  Set the 

running execution context

's LexicalEnvironment to 

oldEnv

.

b.  Return 

Completion

(

status

).

7.  Let 

B

 be the result of evaluating 

Block

.

8.  Set the 

running execution context

's LexicalEnvironment to 

oldEnv

.

9.  Return 

Completion

(

B

).

Catch

 

:

 

catch

 

Block

1.  Return the result of evaluating 

Block

.

NOTE

TryStatement

 

:

 

try

 

Block

 

Catch

1.  Let 

B

 be the result of evaluating 

Block

.

2.  If 

B

.[[Type]] is 

throw

, let 

C

 be 

CatchClauseEvaluation

 of 

Catch

 with argument 

B

.[[Value]].

3.  Else, let 

C

 be 

B

.

4.  Return 

Completion

(

UpdateEmpty

(

C

undefined

)).

TryStatement

 

:

 

try

 

Block

 

Finally

1.  Let 

B

 be the result of evaluating 

Block

.

2.  Let 

F

 be the result of evaluating 

Finally

.

An alternative 

static semantics

 for this production is given in 

B.3.5

.

No matter how control leaves the 

Block

 the LexicalEnvironment is always restored to its former

state.

14.15.2  Runtime Semantics: CatchClauseEvaluation

14.15.3  Runtime Semantics: Evaluation

388

3.  If 

F

.[[Type]] is 

normal

, set 

F

 to 

B

.

4.  Return 

Completion

(

UpdateEmpty

(

F

undefined

)).

TryStatement

 

:

 

try

 

Block

 

Catch

 

Finally

1.  Let 

B

 be the result of evaluating 

Block

.

2.  If 

B

.[[Type]] is 

throw

, let 

C

 be 

CatchClauseEvaluation

 of 

Catch

 with argument 

B

.[[Value]].

3.  Else, let 

C

 be 

B

.

4.  Let 

F

 be the result of evaluating 

Finally

.

5.  If 

F

.[[Type]] is 

normal

, set 

F

 to 

C

.

6.  Return 

Completion

(

UpdateEmpty

(

F

undefined

)).

DebuggerStatement

 

:

debugger

 

;

NOTE

DebuggerStatement

 

:

 

debugger

 

;

1.  If an 

implementation-defined

 debugging facility is available and enabled, then

a.  Perform an 

implementation-defined

 debugging action.

b.  Let 

result

 be an 

implementation-defined

 

Completion

 value.

2.  Else,

a.  Let 

result

 be 

NormalCompletion

(

empty

).

3.  Return 

result

.

NOTE

UniqueFormalParameters

[Yield, Await]

 

:

Evaluating a 

DebuggerStatement

 may allow an implementation to cause a breakpoint when run

under a debugger. If a debugger is not present or active this statement has no observable effect.

Various ECMAScript language elements cause the creation of ECMAScript function objects (

10.2

).

Evaluation of such functions starts with the execution of their [[Call]] internal method (

10.2.1

).

14.16  The 

debugger

debugger

 Statement

Syntax

14.16.1  Runtime Semantics: Evaluation

15  ECMAScript Language: Functions and Classes

15.1  Parameter Lists

Syntax

389

FormalParameters

[?Yield, ?Await]

FormalParameters

[Yield, Await]

 

:

[empty]

FunctionRestParameter

[?Yield, ?Await]

FormalParameterList

[?Yield, ?Await]

FormalParameterList

[?Yield, ?Await]

 

,

FormalParameterList

[?Yield, ?Await]

 

,

 

FunctionRestParameter

[?Yield, ?Await]

FormalParameterList

[Yield, Await]

 

:

FormalParameter

[?Yield, ?Await]

FormalParameterList

[?Yield, ?Await]

 

,

 

FormalParameter

[?Yield, ?Await]

FunctionRestParameter

[Yield, Await]

 

:

BindingRestElement

[?Yield, ?Await]

FormalParameter

[Yield, Await]

 

:

BindingElement

[?Yield, ?Await]

UniqueFormalParameters

 

:

 

FormalParameters

It is a Syntax Error if 

BoundNames

 of 

FormalParameters

 contains any duplicate elements.

FormalParameters

 

:

 

FormalParameterList

It is a Syntax Error if 

IsSimpleParameterList

 of 

FormalParameterList

 is 

false

 and 

BoundNames

 of 

FormalParameterList

 contains any duplicate elements.

NOTE

ObjectBindingPattern

 

:

{

 

}

{

 

BindingRestProperty

 

}

1.  Return 

false

.

ObjectBindingPattern

 

:

 

{

 

BindingPropertyList

 

,

 

BindingRestProperty

 

}

1.  Return 

ContainsExpression

 of 

BindingPropertyList

.

ArrayBindingPattern

 

:

 

[

 

Elision

opt

 

]

1.  Return 

false

.

Multiple occurrences of the same 

BindingIdentifier

 in a 

FormalParameterList

 is only allowed for

functions which have simple parameter lists and which are not defined in 

strict mode code

.

15.1.1  Static Semantics: Early Errors

15.1.2  Static Semantics: ContainsExpression

390

ArrayBindingPattern

 

:

 

[

 

Elision

opt

 

BindingRestElement

 

]

1.  Return 

ContainsExpression

 of 

BindingRestElement

.

ArrayBindingPattern

 

:

 

[

 

BindingElementList

 

,

 

Elision

opt

 

]

1.  Return 

ContainsExpression

 of 

BindingElementList

.

ArrayBindingPattern

 

:

 

[

 

BindingElementList

 

,

 

Elision

opt

 

BindingRestElement

 

]

1.  Let 

has

 be 

ContainsExpression

 of 

BindingElementList

.

2.  If 

has

 is 

true

, return 

true

.

3.  Return 

ContainsExpression

 of 

BindingRestElement

.

BindingPropertyList

 

:

 

BindingPropertyList

 

,

 

BindingProperty

1.  Let 

has

 be 

ContainsExpression

 of 

BindingPropertyList

.

2.  If 

has

 is 

true

, return 

true

.

3.  Return 

ContainsExpression

 of 

BindingProperty

.

BindingElementList

 

:

 

BindingElementList

 

,

 

BindingElisionElement

1.  Let 

has

 be 

ContainsExpression

 of 

BindingElementList

.

2.  If 

has

 is 

true

, return 

true

.

3.  Return 

ContainsExpression

 of 

BindingElisionElement

.

BindingElisionElement

 

:

 

Elision

opt

 

BindingElement

1.  Return 

ContainsExpression

 of 

BindingElement

.

BindingProperty

 

:

 

PropertyName

 

:

 

BindingElement

1.  Let 

has

 be 

IsComputedPropertyKey

 of 

PropertyName

.

2.  If 

has

 is 

true

, return 

true

.

3.  Return 

ContainsExpression

 of 

BindingElement

.

BindingElement

 

:

 

BindingPattern

 

Initializer

1.  Return 

true

.

SingleNameBinding

 

:

 

BindingIdentifier

1.  Return 

false

.

SingleNameBinding

 

:

 

BindingIdentifier

 

Initializer

1.  Return 

true

.

BindingRestElement

 

:

 

...

 

BindingIdentifier

1.  Return 

false

.

BindingRestElement

 

:

 

...

 

BindingPattern

1.  Return 

ContainsExpression

 of 

BindingPattern

.

391

FormalParameters

 

:

  [empty]

1.  Return 

false

.

FormalParameters

 

:

 

FormalParameterList

 

,

 

FunctionRestParameter

1.  If 

ContainsExpression

 of 

FormalParameterList

 is 

true

, return 

true

.

2.  Return 

ContainsExpression

 of 

FunctionRestParameter

.

FormalParameterList

 

:

 

FormalParameterList

 

,

 

FormalParameter

1.  If 

ContainsExpression

 of 

FormalParameterList

 is 

true

, return 

true

.

2.  Return 

ContainsExpression

 of 

FormalParameter

.

ArrowParameters

 

:

 

BindingIdentifier

1.  Return 

false

.

ArrowParameters

 

:

 

CoverParenthesizedExpressionAndArrowParameterList

1.  Let 

formals

 be 

CoveredFormalsList

 of 

CoverParenthesizedExpressionAndArrowParameterList

.

2.  Return 

ContainsExpression

 of 

formals

.

AsyncArrowBindingIdentifier

 

:

 

BindingIdentifier

1.  Return 

false

.

BindingElement

 

:

 

BindingPattern

1.  Return 

false

.

BindingElement

 

:

 

BindingPattern

 

Initializer

1.  Return 

false

.

SingleNameBinding

 

:

 

BindingIdentifier

1.  Return 

true

.

SingleNameBinding

 

:

 

BindingIdentifier

 

Initializer

1.  Return 

false

.

FormalParameters

 

:

  [empty]

1.  Return 

true

.

FormalParameters

 

:

 

FunctionRestParameter

1.  Return 

false

.

FormalParameters

 

:

 

FormalParameterList

 

,

 

FunctionRestParameter

1.  Return 

false

.

15.1.3  Static Semantics: IsSimpleParameterList

392

FormalParameterList

 

:

 

FormalParameterList

 

,

 

FormalParameter

1.  If 

IsSimpleParameterList

 of 

FormalParameterList

 is 

false

, return 

false

.

2.  Return 

IsSimpleParameterList

 of 

FormalParameter

.

FormalParameter

 

:

 

BindingElement

1.  Return 

IsSimpleParameterList

 of 

BindingElement

.

ArrowParameters

 

:

 

BindingIdentifier

1.  Return 

true

.

ArrowParameters

 

:

 

CoverParenthesizedExpressionAndArrowParameterList

1.  Let 

formals

 be 

CoveredFormalsList

 of 

CoverParenthesizedExpressionAndArrowParameterList

.

2.  Return 

IsSimpleParameterList

 of 

formals

.

AsyncArrowBindingIdentifier

[Yield]

 

:

 

BindingIdentifier

[?Yield, +Await]

1.  Return 

true

.

CoverCallExpressionAndAsyncArrowHead

 

:

 

MemberExpression

 

Arguments

1.  Let 

head

 be 

CoveredAsyncArrowHead

 of 

CoverCallExpressionAndAsyncArrowHead

.

2.  Return 

IsSimpleParameterList

 of 

head

.

BindingElement

 

:

 

BindingPattern

1.  Return 

false

.

BindingElement

 

:

 

BindingPattern

 

Initializer

1.  Return 

true

.

SingleNameBinding

 

:

 

BindingIdentifier

1.  Return 

false

.

SingleNameBinding

 

:

 

BindingIdentifier

 

Initializer

1.  Return 

true

.

FormalParameterList

 

:

 

FormalParameterList

 

,

 

FormalParameter

1.  If 

HasInitializer

 of 

FormalParameterList

 is 

true

, return 

true

.

2.  Return 

HasInitializer

 of 

FormalParameter

.

FormalParameters

 

:

[empty]

FunctionRestParameter

15.1.4  Static Semantics: HasInitializer

15.1.5  Static Semantics: ExpectedArgumentCount

393

 

 

 

 

 

 

 

Content      ..     44      45      46      47     ..