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

 

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

 

Search            copyright infringement  

 

 

 

 

 

 

 

 

 

 

 

Content      ..     14      15      16      17     ..

 

 

 

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

 

 

The abstract operation IteratorValue takes argument 

iterResult

. It performs the following steps when called:

1. 

Assert

Type

(

iterResult

) is Object.

2.  Return ? 

Get

(

iterResult

"value"

).

The abstract operation IteratorStep takes argument 

iteratorRecord

. It requests the next value from 

iteratorRecord

.

[[Iterator]] by calling 

iteratorRecord

.[[NextMethod]] and returns either 

false

 indicating that the iterator has reached its

end or the IteratorResult object if a next value is available. It performs the following steps when called:

1.  Let 

result

 be ? 

IteratorNext

(

iteratorRecord

).

2.  Let 

done

 be ? 

IteratorComplete

(

result

).

3.  If 

done

 is 

true

, return 

false

.

4.  Return 

result

.

The abstract operation IteratorClose takes arguments 

iteratorRecord

 and 

completion

. It is used to notify an iterator that it

should perform any actions it would normally perform when it has reached its completed state. It performs the
following steps when called:

1. 

Assert

Type

(

iteratorRecord

.[[Iterator]]) is Object.

2. 

Assert

completion

 is a 

Completion Record

.

3.  Let 

iterator

 be 

iteratorRecord

.[[Iterator]].

4.  Let 

innerResult

 be 

GetMethod

(

iterator

"return"

).

5.  If 

innerResult

.[[Type]] is 

normal

, then

a.  Let 

return

 be 

innerResult

.[[Value]].

b.  If 

return

 is 

undefined

, return 

Completion

(

completion

).

c.  Set 

innerResult

 to 

Call

(

return

iterator

).

6.  If 

completion

.[[Type]] is 

throw

, return 

Completion

(

completion

).

7.  If 

innerResult

.[[Type]] is 

throw

, return 

Completion

(

innerResult

).

8.  If 

Type

(

innerResult

.[[Value]]) is not Object, throw a 

TypeError

 exception.

9.  Return 

Completion

(

completion

).

The abstract operation AsyncIteratorClose takes arguments 

iteratorRecord

 and 

completion

. It is used to notify an async

iterator that it should perform any actions it would normally perform when it has reached its completed state. It
performs the following steps when called:

1. 

Assert

Type

(

iteratorRecord

.[[Iterator]]) is Object.

2. 

Assert

completion

 is a 

Completion Record

.

3.  Let 

iterator

 be 

iteratorRecord

.[[Iterator]].

4.  Let 

innerResult

 be 

GetMethod

(

iterator

"return"

).

5.  If 

innerResult

.[[Type]] is 

normal

, then

a.  Let 

return

 be 

innerResult

.[[Value]].

7.4.4  IteratorValue ( 

iterResult

 )

7.4.5  IteratorStep ( 

iteratorRecord

 )

7.4.6  IteratorClose ( 

iteratorRecord

completion

 )

7.4.7  AsyncIteratorClose ( 

iteratorRecord

completion

 )

138

b.  If 

return

 is 

undefined

, return 

Completion

(

completion

).

c.  Set 

innerResult

 to 

Call

(

return

iterator

).

d.  If 

innerResult

.[[Type]] is 

normal

, set 

innerResult

 to 

Await

(

innerResult

.[[Value]]).

6.  If 

completion

.[[Type]] is 

throw

, return 

Completion

(

completion

).

7.  If 

innerResult

.[[Type]] is 

throw

, return 

Completion

(

innerResult

).

8.  If 

Type

(

innerResult

.[[Value]]) is not Object, throw a 

TypeError

 exception.

9.  Return 

Completion

(

completion

).

The abstract operation CreateIterResultObject takes arguments 

value

 and 

done

. It creates an object that supports the

IteratorResult interface. It performs the following steps when called:

1. 

Assert

Type

(

done

) is Boolean.

2.  Let 

obj

 be ! 

OrdinaryObjectCreate

(

%Object.prototype%

).

3.  Perform ! 

CreateDataPropertyOrThrow

(

obj

"value"

value

).

4.  Perform ! 

CreateDataPropertyOrThrow

(

obj

"done"

done

).

5.  Return 

obj

.

The abstract operation CreateListIteratorRecord takes argument 

list

. It creates an Iterator (

27.1.1.2

) object record whose

next method returns the successive elements of 

list

. It performs the following steps when called:

1.  Let 

closure

 be a new 

Abstract Closure

 with no parameters that captures 

list

 and performs the following steps

when called:

a.  For each element 

E

 of 

list

, do

i.  Perform ? 

Yield

(

E

).

b.  Return 

undefined

.

2.  Let 

iterator

 be ! 

CreateIteratorFromClosure

(

closure

empty

%IteratorPrototype%

).

3.  Return 

Record

 { [[Iterator]]: 

iterator

, [[NextMethod]]: %GeneratorFunction.prototype.prototype.next%,

[[Done]]: 

false

 }.

NOTE

The abstract operation IterableToList takes argument 

items

 and optional argument 

method

. It performs the following

steps when called:

1.  If 

method

 is present, then

a.  Let 

iteratorRecord

 be ? 

GetIterator

(

items

sync

method

).

2.  Else,

a.  Let 

iteratorRecord

 be ? 

GetIterator

(

items

sync

).

3.  Let 

values

 be a new empty 

List

.

4.  Let 

next

 be 

true

.

5.  Repeat, while 

next

 is not 

false

,

The list iterator object is never directly accessible to ECMAScript code.

7.4.8  CreateIterResultObject ( 

value

done

 )

7.4.9  CreateListIteratorRecord ( 

list

 )

7.4.10  IterableToList ( 

items

 [ , 

method

 ] )

139

a.  Set 

next

 to ? 

IteratorStep

(

iteratorRecord

).

b.  If 

next

 is not 

false

, then

i.  Let 

nextValue

 be ? 

IteratorValue

(

next

).

ii.  Append 

nextValue

 to the end of the 

List

 

values

.

6.  Return 

values

.

In addition to those defined in this section, specialized syntax-directed operations are defined throughout this
specification.

NOTE

BindingIdentifier

 

:

 

Identifier

1.  Return a 

List

 whose sole element is the 

StringValue

 of 

Identifier

.

BindingIdentifier

 

:

 

yield

1.  Return a 

List

 whose sole element is 

"yield"

.

BindingIdentifier

 

:

 

await

1.  Return a 

List

 whose sole element is 

"await"

.

LexicalDeclaration

 

:

 

LetOrConst

 

BindingList

 

;

1.  Return the 

BoundNames

 of 

BindingList

.

BindingList

 

:

 

BindingList

 

,

 

LexicalBinding

1.  Let 

names

 be the 

BoundNames

 of 

BindingList

.

2.  Append to 

names

 the elements of the 

BoundNames

 of 

LexicalBinding

.

3.  Return 

names

.

LexicalBinding

 

:

 

BindingIdentifier

 

Initializer

opt

1.  Return the 

BoundNames

 of 

BindingIdentifier

.

LexicalBinding

 

:

 

BindingPattern

 

Initializer

1.  Return the 

BoundNames

 of 

BindingPattern

.

VariableDeclarationList

 

:

 

VariableDeclarationList

 

,

 

VariableDeclaration

"*default*"

 is used within this specification as a synthetic name for hoistable anonymous

functions that are defined using export declarations.

8  Syntax-Directed Operations

8.1  Scope Analysis

8.1.1  Static Semantics: BoundNames

140

1.  Let 

names

 be 

BoundNames

 of 

VariableDeclarationList

.

2.  Append to 

names

 the elements of 

BoundNames

 of 

VariableDeclaration

.

3.  Return 

names

.

VariableDeclaration

 

:

 

BindingIdentifier

 

Initializer

opt

1.  Return the 

BoundNames

 of 

BindingIdentifier

.

VariableDeclaration

 

:

 

BindingPattern

 

Initializer

1.  Return the 

BoundNames

 of 

BindingPattern

.

ObjectBindingPattern

 

:

 

{

 

}

1.  Return a new empty 

List

.

ObjectBindingPattern

 

:

 

{

 

BindingPropertyList

 

,

 

BindingRestProperty

 

}

1.  Let 

names

 be 

BoundNames

 of 

BindingPropertyList

.

2.  Append to 

names

 the elements of 

BoundNames

 of 

BindingRestProperty

.

3.  Return 

names

.

ArrayBindingPattern

 

:

 

[

 

Elision

opt

 

]

1.  Return a new empty 

List

.

ArrayBindingPattern

 

:

 

[

 

Elision

opt

 

BindingRestElement

 

]

1.  Return the 

BoundNames

 of 

BindingRestElement

.

ArrayBindingPattern

 

:

 

[

 

BindingElementList

 

,

 

Elision

opt

 

]

1.  Return the 

BoundNames

 of 

BindingElementList

.

ArrayBindingPattern

 

:

 

[

 

BindingElementList

 

,

 

Elision

opt

 

BindingRestElement

 

]

1.  Let 

names

 be 

BoundNames

 of 

BindingElementList

.

2.  Append to 

names

 the elements of 

BoundNames

 of 

BindingRestElement

.

3.  Return 

names

.

BindingPropertyList

 

:

 

BindingPropertyList

 

,

 

BindingProperty

1.  Let 

names

 be 

BoundNames

 of 

BindingPropertyList

.

2.  Append to 

names

 the elements of 

BoundNames

 of 

BindingProperty

.

3.  Return 

names

.

BindingElementList

 

:

 

BindingElementList

 

,

 

BindingElisionElement

1.  Let 

names

 be 

BoundNames

 of 

BindingElementList

.

2.  Append to 

names

 the elements of 

BoundNames

 of 

BindingElisionElement

.

3.  Return 

names

.

BindingElisionElement

 

:

 

Elision

opt

 

BindingElement

141

1.  Return 

BoundNames

 of 

BindingElement

.

BindingProperty

 

:

 

PropertyName

 

:

 

BindingElement

1.  Return the 

BoundNames

 of 

BindingElement

.

SingleNameBinding

 

:

 

BindingIdentifier

 

Initializer

opt

1.  Return the 

BoundNames

 of 

BindingIdentifier

.

BindingElement

 

:

 

BindingPattern

 

Initializer

opt

1.  Return the 

BoundNames

 of 

BindingPattern

.

ForDeclaration

 

:

 

LetOrConst

 

ForBinding

1.  Return the 

BoundNames

 of 

ForBinding

.

FunctionDeclaration

 

:

 

function

 

BindingIdentifier

 

(

 

FormalParameters

 

)

 

{

 

FunctionBody

 

}

1.  Return the 

BoundNames

 of 

BindingIdentifier

.

FunctionDeclaration

 

:

 

function

 

(

 

FormalParameters

 

)

 

{

 

FunctionBody

 

}

1.  Return « 

"*default*"

 ».

FormalParameters

 

:

  [empty]

1.  Return a new empty 

List

.

FormalParameters

 

:

 

FormalParameterList

 

,

 

FunctionRestParameter

1.  Let 

names

 be 

BoundNames

 of 

FormalParameterList

.

2.  Append to 

names

 the 

BoundNames

 of 

FunctionRestParameter

.

3.  Return 

names

.

FormalParameterList

 

:

 

FormalParameterList

 

,

 

FormalParameter

1.  Let 

names

 be 

BoundNames

 of 

FormalParameterList

.

2.  Append to 

names

 the 

BoundNames

 of 

FormalParameter

.

3.  Return 

names

.

ArrowParameters

 

:

 

CoverParenthesizedExpressionAndArrowParameterList

1.  Let 

formals

 be 

CoveredFormalsList

 of 

CoverParenthesizedExpressionAndArrowParameterList

.

2.  Return the 

BoundNames

 of 

formals

.

GeneratorDeclaration

 

:

 

function

 

*

 

BindingIdentifier

 

(

 

FormalParameters

 

)

 

{

 

GeneratorBody

 

}

1.  Return the 

BoundNames

 of 

BindingIdentifier

.

GeneratorDeclaration

 

:

 

function

 

*

 

(

 

FormalParameters

 

)

 

{

 

GeneratorBody

 

}

1.  Return « 

"*default*"

 ».

AsyncGeneratorDeclaration

 

:

 

async

 

function

 

*

 

BindingIdentifier

 

(

 

FormalParameters

 

)

 

{

 

AsyncGeneratorBody

 

}

142

1.  Return the 

BoundNames

 of 

BindingIdentifier

.

AsyncGeneratorDeclaration

 

:

 

async

 

function

 

*

 

(

 

FormalParameters

 

)

 

{

 

AsyncGeneratorBody

 

}

1.  Return « 

"*default*"

 ».

ClassDeclaration

 

:

 

class

 

BindingIdentifier

 

ClassTail

1.  Return the 

BoundNames

 of 

BindingIdentifier

.

ClassDeclaration

 

:

 

class

 

ClassTail

1.  Return « 

"*default*"

 ».

AsyncFunctionDeclaration

 

:

 

async

 

function

 

BindingIdentifier

 

(

 

FormalParameters

 

)

 

{

 

AsyncFunctionBody

 

}

1.  Return the 

BoundNames

 of 

BindingIdentifier

.

AsyncFunctionDeclaration

 

:

 

async

 

function

 

(

 

FormalParameters

 

)

 

{

 

AsyncFunctionBody

 

}

1.  Return « 

"*default*"

 ».

CoverCallExpressionAndAsyncArrowHead

 

:

 

MemberExpression

 

Arguments

1.  Let 

head

 be 

CoveredAsyncArrowHead

 of 

CoverCallExpressionAndAsyncArrowHead

.

2.  Return the 

BoundNames

 of 

head

.

ImportDeclaration

 

:

 

import

 

ImportClause

 

FromClause

 

;

1.  Return the 

BoundNames

 of 

ImportClause

.

ImportDeclaration

 

:

 

import

 

ModuleSpecifier

 

;

1.  Return a new empty 

List

.

ImportClause

 

:

 

ImportedDefaultBinding

 

,

 

NameSpaceImport

1.  Let 

names

 be the 

BoundNames

 of 

ImportedDefaultBinding

.

2.  Append to 

names

 the elements of the 

BoundNames

 of 

NameSpaceImport

.

3.  Return 

names

.

ImportClause

 

:

 

ImportedDefaultBinding

 

,

 

NamedImports

1.  Let 

names

 be the 

BoundNames

 of 

ImportedDefaultBinding

.

2.  Append to 

names

 the elements of the 

BoundNames

 of 

NamedImports

.

3.  Return 

names

.

NamedImports

 

:

 

{

 

}

1.  Return a new empty 

List

.

ImportsList

 

:

 

ImportsList

 

,

 

ImportSpecifier

1.  Let 

names

 be the 

BoundNames

 of 

ImportsList

.

2.  Append to 

names

 the elements of the 

BoundNames

 of 

ImportSpecifier

.

3.  Return 

names

.

143

ImportSpecifier

 

:

 

IdentifierName

 

as

 

ImportedBinding

1.  Return the 

BoundNames

 of 

ImportedBinding

.

ExportDeclaration

 

:

export

 

ExportFromClause

 

FromClause

 

;

export

 

NamedExports

 

;

1.  Return a new empty 

List

.

ExportDeclaration

 

:

 

export

 

VariableStatement

1.  Return the 

BoundNames

 of 

VariableStatement

.

ExportDeclaration

 

:

 

export

 

Declaration

1.  Return the 

BoundNames

 of 

Declaration

.

ExportDeclaration

 

:

 

export

 

default

 

HoistableDeclaration

1.  Let 

declarationNames

 be the 

BoundNames

 of 

HoistableDeclaration

.

2.  If 

declarationNames

 does not include the element 

"*default*"

, append 

"*default*"

 to 

declarationNames

.

3.  Return 

declarationNames

.

ExportDeclaration

 

:

 

export

 

default

 

ClassDeclaration

1.  Let 

declarationNames

 be the 

BoundNames

 of 

ClassDeclaration

.

2.  If 

declarationNames

 does not include the element 

"*default*"

, append 

"*default*"

 to 

declarationNames

.

3.  Return 

declarationNames

.

ExportDeclaration

 

:

 

export

 

default

 

AssignmentExpression

 

;

1.  Return « 

"*default*"

 ».

HoistableDeclaration

 

:

 

FunctionDeclaration

1.  Return 

FunctionDeclaration

.

HoistableDeclaration

 

:

 

GeneratorDeclaration

1.  Return 

GeneratorDeclaration

.

HoistableDeclaration

 

:

 

AsyncFunctionDeclaration

1.  Return 

AsyncFunctionDeclaration

.

HoistableDeclaration

 

:

 

AsyncGeneratorDeclaration

1.  Return 

AsyncGeneratorDeclaration

.

Declaration

 

:

 

ClassDeclaration

1.  Return 

ClassDeclaration

.

8.1.2  Static Semantics: DeclarationPart

144

Declaration

 

:

 

LexicalDeclaration

1.  Return 

LexicalDeclaration

.

LexicalDeclaration

 

:

 

LetOrConst

 

BindingList

 

;

1.  Return 

IsConstantDeclaration

 of 

LetOrConst

.

LetOrConst

 

:

 

let

1.  Return 

false

.

LetOrConst

 

:

 

const

1.  Return 

true

.

FunctionDeclaration

 

:

function

 

BindingIdentifier

 

(

 

FormalParameters

 

)

 

{

 

FunctionBody

 

}

function

 

(

 

FormalParameters

 

)

 

{

 

FunctionBody

 

}

GeneratorDeclaration

 

:

function

 

*

 

BindingIdentifier

 

(

 

FormalParameters

 

)

 

{

 

GeneratorBody

 

}

function

 

*

 

(

 

FormalParameters

 

)

 

{

 

GeneratorBody

 

}

AsyncGeneratorDeclaration

 

:

async

 

function

 

*

 

BindingIdentifier

 

(

 

FormalParameters

 

)

 

{

 

AsyncGeneratorBody

 

}

async

 

function

 

*

 

(

 

FormalParameters

 

)

 

{

 

AsyncGeneratorBody

 

}

AsyncFunctionDeclaration

 

:

async

 

function

 

BindingIdentifier

 

(

 

FormalParameters

 

)

 

{

 

AsyncFunctionBody

 

}

async

 

function

 

(

 

FormalParameters

 

)

 

{

 

AsyncFunctionBody

 

}

1.  Return 

false

.

ClassDeclaration

 

:

class

 

BindingIdentifier

 

ClassTail

class

 

ClassTail

1.  Return 

false

.

ExportDeclaration

 

:

export

 

ExportFromClause

 

FromClause

 

;

export

 

NamedExports

 

;

export

 

default

 

AssignmentExpression

 

;

1.  Return 

false

.

NOTE

It is not necessary to treat 

export default

export default

 

AssignmentExpression

 as a constant declaration

because there is no syntax that permits assignment to the internal bound name used to reference
a module's default object.

8.1.3  Static Semantics: IsConstantDeclaration

145

Block

 

:

 

{

 

}

1.  Return a new empty 

List

.

StatementList

 

:

 

StatementList

 

StatementListItem

1.  Let 

names

 be 

LexicallyDeclaredNames

 of 

StatementList

.

2.  Append to 

names

 the elements of the 

LexicallyDeclaredNames

 of 

StatementListItem

.

3.  Return 

names

.

StatementListItem

 

:

 

Statement

1.  If 

Statement

 is 

Statement

 

:

 

LabelledStatement

 , return 

LexicallyDeclaredNames

 of 

LabelledStatement

.

2.  Return a new empty 

List

.

StatementListItem

 

:

 

Declaration

1.  Return the 

BoundNames

 of 

Declaration

.

CaseBlock

 

:

 

{

 

}

1.  Return a new empty 

List

.

CaseBlock

 

:

 

{

 

CaseClauses

opt

 

DefaultClause

 

CaseClauses

opt

 

}

1.  If the first 

CaseClauses

 is present, let 

names

 be the 

LexicallyDeclaredNames

 of the first 

CaseClauses

.

2.  Else, let 

names

 be a new empty 

List

.

3.  Append to 

names

 the elements of the 

LexicallyDeclaredNames

 of 

DefaultClause

.

4.  If the second 

CaseClauses

 is not present, return 

names

.

5.  Return the result of appending to 

names

 the elements of the 

LexicallyDeclaredNames

 of the second 

CaseClauses

.

CaseClauses

 

:

 

CaseClauses

 

CaseClause

1.  Let 

names

 be 

LexicallyDeclaredNames

 of 

CaseClauses

.

2.  Append to 

names

 the elements of the 

LexicallyDeclaredNames

 of 

CaseClause

.

3.  Return 

names

.

CaseClause

 

:

 

case

 

Expression

 

:

 

StatementList

opt

1.  If the 

StatementList

 is present, return the 

LexicallyDeclaredNames

 of 

StatementList

.

2.  Return a new empty 

List

.

DefaultClause

 

:

 

default

 

:

 

StatementList

opt

1.  If the 

StatementList

 is present, return the 

LexicallyDeclaredNames

 of 

StatementList

.

2.  Return a new empty 

List

.

LabelledStatement

 

:

 

LabelIdentifier

 

:

 

LabelledItem

1.  Return the 

LexicallyDeclaredNames

 of 

LabelledItem

.

LabelledItem

 

:

 

Statement

8.1.4  Static Semantics: LexicallyDeclaredNames

146

1.  Return a new empty 

List

.

LabelledItem

 

:

 

FunctionDeclaration

1.  Return 

BoundNames

 of 

FunctionDeclaration

.

FunctionStatementList

 

:

  [empty]

1.  Return a new empty 

List

.

FunctionStatementList

 

:

 

StatementList

1.  Return 

TopLevelLexicallyDeclaredNames

 of 

StatementList

.

ConciseBody

 

:

 

ExpressionBody

1.  Return a new empty 

List

.

AsyncConciseBody

 

:

 

ExpressionBody

1.  Return a new empty 

List

.

ScriptBody

 

:

 

StatementList

1.  Return 

TopLevelLexicallyDeclaredNames

 of 

StatementList

.

NOTE 1

NOTE 2

ModuleItemList

 

:

 

ModuleItemList

 

ModuleItem

1.  Let 

names

 be 

LexicallyDeclaredNames

 of 

ModuleItemList

.

2.  Append to 

names

 the elements of the 

LexicallyDeclaredNames

 of 

ModuleItem

.

3.  Return 

names

.

ModuleItem

 

:

 

ImportDeclaration

1.  Return the 

BoundNames

 of 

ImportDeclaration

.

ModuleItem

 

:

 

ExportDeclaration

1.  If 

ExportDeclaration

 is 

export

export

 

VariableStatement

, return a new empty 

List

.

2.  Return the 

BoundNames

 of 

ExportDeclaration

.

ModuleItem

 

:

 

StatementListItem

1.  Return 

LexicallyDeclaredNames

 of 

StatementListItem

.

NOTE 3

At the top level of a 

Script

, function declarations are treated like var declarations rather than like

lexical declarations.

The LexicallyDeclaredNames of a 

Module

 includes the names of all of its imported bindings.

At the top level of a 

Module

, function declarations are treated like lexical declarations rather than

like var declarations.

147

StatementList

 

:

 

StatementList

 

StatementListItem

1.  Let 

declarations

 be 

LexicallyScopedDeclarations

 of 

StatementList

.

2.  Append to 

declarations

 the elements of the 

LexicallyScopedDeclarations

 of 

StatementListItem

.

3.  Return 

declarations

.

StatementListItem

 

:

 

Statement

1.  If 

Statement

 is 

Statement

 

:

 

LabelledStatement

 , return 

LexicallyScopedDeclarations

 of 

LabelledStatement

.

2.  Return a new empty 

List

.

StatementListItem

 

:

 

Declaration

1.  Return a 

List

 whose sole element is 

DeclarationPart

 of 

Declaration

.

CaseBlock

 

:

 

{

 

}

1.  Return a new empty 

List

.

CaseBlock

 

:

 

{

 

CaseClauses

opt

 

DefaultClause

 

CaseClauses

opt

 

}

1.  If the first 

CaseClauses

 is present, let 

declarations

 be the 

LexicallyScopedDeclarations

 of the first 

CaseClauses

.

2.  Else, let 

declarations

 be a new empty 

List

.

3.  Append to 

declarations

 the elements of the 

LexicallyScopedDeclarations

 of 

DefaultClause

.

4.  If the second 

CaseClauses

 is not present, return 

declarations

.

5.  Return the result of appending to 

declarations

 the elements of the 

LexicallyScopedDeclarations

 of the second 

CaseClauses

.

CaseClauses

 

:

 

CaseClauses

 

CaseClause

1.  Let 

declarations

 be 

LexicallyScopedDeclarations

 of 

CaseClauses

.

2.  Append to 

declarations

 the elements of the 

LexicallyScopedDeclarations

 of 

CaseClause

.

3.  Return 

declarations

.

CaseClause

 

:

 

case

 

Expression

 

:

 

StatementList

opt

1.  If the 

StatementList

 is present, return the 

LexicallyScopedDeclarations

 of 

StatementList

.

2.  Return a new empty 

List

.

DefaultClause

 

:

 

default

 

:

 

StatementList

opt

1.  If the 

StatementList

 is present, return the 

LexicallyScopedDeclarations

 of 

StatementList

.

2.  Return a new empty 

List

.

LabelledStatement

 

:

 

LabelIdentifier

 

:

 

LabelledItem

1.  Return the 

LexicallyScopedDeclarations

 of 

LabelledItem

.

LabelledItem

 

:

 

Statement

1.  Return a new empty 

List

.

LabelledItem

 

:

 

FunctionDeclaration

8.1.5  Static Semantics: LexicallyScopedDeclarations

148

1.  Return a 

List

 whose sole element is 

FunctionDeclaration

.

FunctionStatementList

 

:

  [empty]

1.  Return a new empty 

List

.

FunctionStatementList

 

:

 

StatementList

1.  Return the 

TopLevelLexicallyScopedDeclarations

 of 

StatementList

.

ConciseBody

 

:

 

ExpressionBody

1.  Return a new empty 

List

.

AsyncConciseBody

 

:

 

ExpressionBody

1.  Return a new empty 

List

.

ScriptBody

 

:

 

StatementList

1.  Return 

TopLevelLexicallyScopedDeclarations

 of 

StatementList

.

Module

 

:

  [empty]

1.  Return a new empty 

List

.

ModuleItemList

 

:

 

ModuleItemList

 

ModuleItem

1.  Let 

declarations

 be 

LexicallyScopedDeclarations

 of 

ModuleItemList

.

2.  Append to 

declarations

 the elements of the 

LexicallyScopedDeclarations

 of 

ModuleItem

.

3.  Return 

declarations

.

ModuleItem

 

:

 

ImportDeclaration

1.  Return a new empty 

List

.

ExportDeclaration

 

:

export

 

ExportFromClause

 

FromClause

 

;

export

 

NamedExports

 

;

export

 

VariableStatement

1.  Return a new empty 

List

.

ExportDeclaration

 

:

 

export

 

Declaration

1.  Return a 

List

 whose sole element is 

DeclarationPart

 of 

Declaration

.

ExportDeclaration

 

:

 

export

 

default

 

HoistableDeclaration

1.  Return a 

List

 whose sole element is 

DeclarationPart

 of 

HoistableDeclaration

.

ExportDeclaration

 

:

 

export

 

default

 

ClassDeclaration

1.  Return a 

List

 whose sole element is 

ClassDeclaration

.

ExportDeclaration

 

:

 

export

 

default

 

AssignmentExpression

 

;

149

1.  Return a 

List

 whose sole element is this 

ExportDeclaration

.

Statement

 

:

EmptyStatement
ExpressionStatement
ContinueStatement
BreakStatement
ReturnStatement
ThrowStatement
DebuggerStatement

1.  Return a new empty 

List

.

Block

 

:

 

{

 

}

1.  Return a new empty 

List

.

StatementList

 

:

 

StatementList

 

StatementListItem

1.  Let 

names

 be 

VarDeclaredNames

 of 

StatementList

.

2.  Append to 

names

 the elements of the 

VarDeclaredNames

 of 

StatementListItem

.

3.  Return 

names

.

StatementListItem

 

:

 

Declaration

1.  Return a new empty 

List

.

VariableStatement

 

:

 

var

 

VariableDeclarationList

 

;

1.  Return 

BoundNames

 of 

VariableDeclarationList

.

IfStatement

 

:

 

if

 

(

 

Expression

 

)

 

Statement

 

else

 

Statement

1.  Let 

names

 be 

VarDeclaredNames

 of the first 

Statement

.

2.  Append to 

names

 the elements of the 

VarDeclaredNames

 of the second 

Statement

.

3.  Return 

names

.

IfStatement

 

:

 

if

 

(

 

Expression

 

)

 

Statement

1.  Return the 

VarDeclaredNames

 of 

Statement

.

DoWhileStatement

 

:

 

do

 

Statement

 

while

 

(

 

Expression

 

)

 

;

1.  Return the 

VarDeclaredNames

 of 

Statement

.

WhileStatement

 

:

 

while

 

(

 

Expression

 

)

 

Statement

1.  Return the 

VarDeclaredNames

 of 

Statement

.

ForStatement

 

:

 

for

 

(

 

Expression

opt

 

;

 

Expression

opt

 

;

 

Expression

opt

 

)

 

Statement

1.  Return the 

VarDeclaredNames

 of 

Statement

.

8.1.6  Static Semantics: VarDeclaredNames

150

ForStatement

 

:

 

for

 

(

 

var

 

VariableDeclarationList

 

;

 

Expression

opt

 

;

 

Expression

opt

 

)

 

Statement

1.  Let 

names

 be 

BoundNames

 of 

VariableDeclarationList

.

2.  Append to 

names

 the elements of the 

VarDeclaredNames

 of 

Statement

.

3.  Return 

names

.

ForStatement

 

:

 

for

 

(

 

LexicalDeclaration

 

Expression

opt

 

;

 

Expression

opt

 

)

 

Statement

1.  Return the 

VarDeclaredNames

 of 

Statement

.

ForInOfStatement

 

:

for

 

(

 

LeftHandSideExpression

 

in

 

Expression

 

)

 

Statement

for

 

(

 

ForDeclaration

 

in

 

Expression

 

)

 

Statement

for

 

(

 

LeftHandSideExpression

 

of

 

AssignmentExpression

 

)

 

Statement

for

 

(

 

ForDeclaration

 

of

 

AssignmentExpression

 

)

 

Statement

for

 

await

 

(

 

LeftHandSideExpression

 

of

 

AssignmentExpression

 

)

 

Statement

for

 

await

 

(

 

ForDeclaration

 

of

 

AssignmentExpression

 

)

 

Statement

1.  Return the 

VarDeclaredNames

 of 

Statement

.

ForInOfStatement

 

:

for

 

(

 

var

 

ForBinding

 

in

 

Expression

 

)

 

Statement

for

 

(

 

var

 

ForBinding

 

of

 

AssignmentExpression

 

)

 

Statement

for

 

await

 

(

 

var

 

ForBinding

 

of

 

AssignmentExpression

 

)

 

Statement

1.  Let 

names

 be the 

BoundNames

 of 

ForBinding

.

2.  Append to 

names

 the elements of the 

VarDeclaredNames

 of 

Statement

.

3.  Return 

names

.

NOTE

WithStatement

 

:

 

with

 

(

 

Expression

 

)

 

Statement

1.  Return the 

VarDeclaredNames

 of 

Statement

.

SwitchStatement

 

:

 

switch

 

(

 

Expression

 

)

 

CaseBlock

1.  Return the 

VarDeclaredNames

 of 

CaseBlock

.

CaseBlock

 

:

 

{

 

}

1.  Return a new empty 

List

.

CaseBlock

 

:

 

{

 

CaseClauses

opt

 

DefaultClause

 

CaseClauses

opt

 

}

1.  If the first 

CaseClauses

 is present, let 

names

 be the 

VarDeclaredNames

 of the first 

CaseClauses

.

2.  Else, let 

names

 be a new empty 

List

.

3.  Append to 

names

 the elements of the 

VarDeclaredNames

 of 

DefaultClause

.

4.  If the second 

CaseClauses

 is not present, return 

names

.

5.  Return the result of appending to 

names

 the elements of the 

VarDeclaredNames

 of the second 

CaseClauses

.

This section is extended by Annex 

B.3.6

.

151

CaseClauses

 

:

 

CaseClauses

 

CaseClause

1.  Let 

names

 be 

VarDeclaredNames

 of 

CaseClauses

.

2.  Append to 

names

 the elements of the 

VarDeclaredNames

 of 

CaseClause

.

3.  Return 

names

.

CaseClause

 

:

 

case

 

Expression

 

:

 

StatementList

opt

1.  If the 

StatementList

 is present, return the 

VarDeclaredNames

 of 

StatementList

.

2.  Return a new empty 

List

.

DefaultClause

 

:

 

default

 

:

 

StatementList

opt

1.  If the 

StatementList

 is present, return the 

VarDeclaredNames

 of 

StatementList

.

2.  Return a new empty 

List

.

LabelledStatement

 

:

 

LabelIdentifier

 

:

 

LabelledItem

1.  Return the 

VarDeclaredNames

 of 

LabelledItem

.

LabelledItem

 

:

 

FunctionDeclaration

1.  Return a new empty 

List

.

TryStatement

 

:

 

try

 

Block

 

Catch

1.  Let 

names

 be 

VarDeclaredNames

 of 

Block

.

2.  Append to 

names

 the elements of the 

VarDeclaredNames

 of 

Catch

.

3.  Return 

names

.

TryStatement

 

:

 

try

 

Block

 

Finally

1.  Let 

names

 be 

VarDeclaredNames

 of 

Block

.

2.  Append to 

names

 the elements of the 

VarDeclaredNames

 of 

Finally

.

3.  Return 

names

.

TryStatement

 

:

 

try

 

Block

 

Catch

 

Finally

1.  Let 

names

 be 

VarDeclaredNames

 of 

Block

.

2.  Append to 

names

 the elements of the 

VarDeclaredNames

 of 

Catch

.

3.  Append to 

names

 the elements of the 

VarDeclaredNames

 of 

Finally

.

4.  Return 

names

.

Catch

 

:

 

catch

 

(

 

CatchParameter

 

)

 

Block

1.  Return the 

VarDeclaredNames

 of 

Block

.

FunctionStatementList

 

:

  [empty]

1.  Return a new empty 

List

.

FunctionStatementList

 

:

 

StatementList

1.  Return 

TopLevelVarDeclaredNames

 of 

StatementList

.

152

ConciseBody

 

:

 

ExpressionBody

1.  Return a new empty 

List

.

AsyncConciseBody

 

:

 

ExpressionBody

1.  Return a new empty 

List

.

ScriptBody

 

:

 

StatementList

1.  Return 

TopLevelVarDeclaredNames

 of 

StatementList

.

Module

 

:

  [empty]

1.  Return a new empty 

List

.

ModuleItemList

 

:

 

ModuleItemList

 

ModuleItem

1.  Let 

names

 be 

VarDeclaredNames

 of 

ModuleItemList

.

2.  Append to 

names

 the elements of the 

VarDeclaredNames

 of 

ModuleItem

.

3.  Return 

names

.

ModuleItem

 

:

 

ImportDeclaration

1.  Return a new empty 

List

.

ModuleItem

 

:

 

ExportDeclaration

1.  If 

ExportDeclaration

 is 

export

export

 

VariableStatement

, return 

BoundNames

 of 

ExportDeclaration

.

2.  Return a new empty 

List

.

Statement

 

:

EmptyStatement
ExpressionStatement
ContinueStatement
BreakStatement
ReturnStatement
ThrowStatement
DebuggerStatement

1.  Return a new empty 

List

.

Block

 

:

 

{

 

}

1.  Return a new empty 

List

.

StatementList

 

:

 

StatementList

 

StatementListItem

1.  Let 

declarations

 be 

VarScopedDeclarations

 of 

StatementList

.

2.  Append to 

declarations

 the elements of the 

VarScopedDeclarations

 of 

StatementListItem

.

3.  Return 

declarations

.

8.1.7  Static Semantics: VarScopedDeclarations

153

 

 

 

 

 

 

 

Content      ..     14      15      16      17     ..