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

 

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

 

Search            copyright infringement  

 

 

 

 

 

 

 

 

 

 

 

Content      ..     40      41      42      43     ..

 

 

 

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

 

 

1.  Let 

pattern

 be ! 

CodePointsToString

(

BodyText

 of 

RegularExpressionLiteral

).

2.  Let 

flags

 be ! 

CodePointsToString

(

FlagText

 of 

RegularExpressionLiteral

).

3.  Return 

RegExpCreate

(

pattern

flags

).

TemplateLiteral

[Yield, Await, Tagged]

 

:

NoSubstitutionTemplate
SubstitutionTemplate

[?Yield, ?Await, ?Tagged]

SubstitutionTemplate

[Yield, Await, Tagged]

 

:

TemplateHead

 

Expression

[+In, ?Yield, ?Await]

 

TemplateSpans

[?Yield, ?Await, ?Tagged]

TemplateSpans

[Yield, Await, Tagged]

 

:

TemplateTail
TemplateMiddleList

[?Yield, ?Await, ?Tagged]

 

TemplateTail

TemplateMiddleList

[Yield, Await, Tagged]

 

:

TemplateMiddle

 

Expression

[+In, ?Yield, ?Await]

TemplateMiddleList

[?Yield, ?Await, ?Tagged]

 

TemplateMiddle

 

Expression

[+In, ?Yield, ?Await]

TemplateLiteral

[Yield, Await, Tagged]

 

:

 

NoSubstitutionTemplate

It is a Syntax Error if the 

[Tagged]

 parameter was not set and 

NoSubstitutionTemplate

 

Contains

 

NotEscapeSequence

.

TemplateLiteral

[Yield, Await, Tagged]

 

:

 

SubstitutionTemplate

[?Yield, ?Await, ?Tagged]

It is a Syntax Error if the number of elements in the result of 

TemplateStrings

 of 

TemplateLiteral

 with argument

false

 is greater than 2

32

 - 1.

SubstitutionTemplate

[Yield, Await, Tagged]

 

:

 

TemplateHead

 

Expression

[+In, ?Yield, ?Await]

TemplateSpans

[?Yield, ?Await, ?Tagged]

It is a Syntax Error if the 

[Tagged]

 parameter was not set and 

TemplateHead

 

Contains

 

NotEscapeSequence

.

TemplateSpans

[Yield, Await, Tagged]

 

:

 

TemplateTail

It is a Syntax Error if the 

[Tagged]

 parameter was not set and 

TemplateTail

 

Contains

 

NotEscapeSequence

.

TemplateMiddleList

[Yield, Await, Tagged]

 

:

TemplateMiddle

 

Expression

[+In, ?Yield, ?Await]

TemplateMiddleList

[?Yield, ?Await, ?Tagged]

 

TemplateMiddle

 

Expression

[+In, ?Yield, ?Await]

It is a Syntax Error if the 

[Tagged]

 parameter was not set and 

TemplateMiddle

 

Contains

 

NotEscapeSequence

.

13.2.9  Template Literals

Syntax

13.2.9.1  Static Semantics: Early Errors

314

With parameter 

raw

.

TemplateLiteral

 

:

 

NoSubstitutionTemplate

1.  If 

raw

 is 

false

, then

a.  Let 

string

 be the TV of 

NoSubstitutionTemplate

.

2.  Else,

a.  Let 

string

 be the TRV of 

NoSubstitutionTemplate

.

3.  Return a 

List

 whose sole element is 

string

.

SubstitutionTemplate

 

:

 

TemplateHead

 

Expression

 

TemplateSpans

1.  If 

raw

 is 

false

, then

a.  Let 

head

 be the TV of 

TemplateHead

.

2.  Else,

a.  Let 

head

 be the TRV of 

TemplateHead

.

3.  Let 

tail

 be 

TemplateStrings

 of 

TemplateSpans

 with argument 

raw

.

4.  Return a 

List

 whose elements are 

head

 followed by the elements of 

tail

.

TemplateSpans

 

:

 

TemplateTail

1.  If 

raw

 is 

false

, then

a.  Let 

tail

 be the TV of 

TemplateTail

.

2.  Else,

a.  Let 

tail

 be the TRV of 

TemplateTail

.

3.  Return a 

List

 whose sole element is 

tail

.

TemplateSpans

 

:

 

TemplateMiddleList

 

TemplateTail

1.  Let 

middle

 be 

TemplateStrings

 of 

TemplateMiddleList

 with argument 

raw

.

2.  If 

raw

 is 

false

, then

a.  Let 

tail

 be the TV of 

TemplateTail

.

3.  Else,

a.  Let 

tail

 be the TRV of 

TemplateTail

.

4.  Return a 

List

 whose elements are the elements of 

middle

 followed by 

tail

.

TemplateMiddleList

 

:

 

TemplateMiddle

 

Expression

1.  If 

raw

 is 

false

, then

a.  Let 

string

 be the TV of 

TemplateMiddle

.

2.  Else,

a.  Let 

string

 be the TRV of 

TemplateMiddle

.

3.  Return a 

List

 whose sole element is 

string

.

TemplateMiddleList

 

:

 

TemplateMiddleList

 

TemplateMiddle

 

Expression

1.  Let 

front

 be 

TemplateStrings

 of 

TemplateMiddleList

 with argument 

raw

.

2.  If 

raw

 is 

false

, then

a.  Let 

last

 be the TV of 

TemplateMiddle

.

3.  Else,

13.2.9.2  Static Semantics: TemplateStrings

315

a.  Let 

last

 be the TRV of 

TemplateMiddle

.

4.  Append 

last

 as the last element of the 

List

 

front

.

5.  Return 

front

.

The abstract operation GetTemplateObject takes argument 

templateLiteral

 (a 

Parse Node

). It performs the following

steps when called:

1.  Let 

realm

 be 

the current Realm Record

.

2.  Let 

templateRegistry

 be 

realm

.[[TemplateMap]].

3.  For each element 

e

 of 

templateRegistry

, do

a.  If 

e

.[[Site]] is 

the same Parse Node

 as 

templateLiteral

, then

i.  Return 

e

.[[Array]].

4.  Let 

rawStrings

 be 

TemplateStrings

 of 

templateLiteral

 with argument 

true

.

5.  Let 

cookedStrings

 be 

TemplateStrings

 of 

templateLiteral

 with argument 

false

.

6.  Let 

count

 be the number of elements in the 

List

 

cookedStrings

.

7. 

Assert

count

 

 2

32

 - 1.

8.  Let 

template

 be ! 

ArrayCreate

(

count

).

9.  Let 

rawObj

 be ! 

ArrayCreate

(

count

).

10.  Let 

index

 be 0.

11.  Repeat, while 

index

 < 

count

,

a.  Let 

prop

 be ! 

ToString

(

(

index

)).

b.  Let 

cookedValue

 be 

cookedStrings

[

index

].

c.  Perform ! 

DefinePropertyOrThrow

(

template

prop

, PropertyDescriptor { [[Value]]: 

cookedValue

,

[[Writable]]: 

false

, [[Enumerable]]: 

true

, [[Configurable]]: 

false

 }).

d.  Let 

rawValue

 be the String value 

rawStrings

[

index

].

e.  Perform ! 

DefinePropertyOrThrow

(

rawObj

prop

, PropertyDescriptor { [[Value]]: 

rawValue

, [[Writable]]:

false

, [[Enumerable]]: 

true

, [[Configurable]]: 

false

 }).

f.  Set 

index

 to 

index

 + 1.

12.  Perform ! 

SetIntegrityLevel

(

rawObj

frozen

).

13.  Perform ! 

DefinePropertyOrThrow

(

template

"raw"

, PropertyDescriptor { [[Value]]: 

rawObj

, [[Writable]]: 

false

,

[[Enumerable]]: 

false

, [[Configurable]]: 

false

 }).

14.  Perform ! 

SetIntegrityLevel

(

template

frozen

).

15.  Append the 

Record

 { [[Site]]: 

templateLiteral

, [[Array]]: 

template

 } to 

templateRegistry

.

16.  Return 

template

.

NOTE 1

NOTE 2

The creation of a template object cannot result in an 

abrupt completion

.

Each 

TemplateLiteral

 in the program code of a 

realm

 is associated with a unique template object

that is used in the evaluation of tagged Templates (

13.2.9.5

). The template objects are frozen and

the same template object is used each time a specific tagged Template is evaluated. Whether
template objects are created lazily upon first evaluation of the 

TemplateLiteral

 or eagerly prior to

first evaluation is an implementation choice that is not observable to ECMAScript code.

13.2.9.3  GetTemplateObject ( 

templateLiteral

 )

316

NOTE 3

TemplateSpans

 

:

 

TemplateTail

1.  Return a new empty 

List

.

TemplateSpans

 

:

 

TemplateMiddleList

 

TemplateTail

1.  Return the result of 

SubstitutionEvaluation

 of 

TemplateMiddleList

.

TemplateMiddleList

 

:

 

TemplateMiddle

 

Expression

1.  Let 

subRef

 be the result of evaluating 

Expression

.

2.  Let 

sub

 be ? 

GetValue

(

subRef

).

3.  Return a 

List

 whose sole element is 

sub

.

TemplateMiddleList

 

:

 

TemplateMiddleList

 

TemplateMiddle

 

Expression

1.  Let 

preceding

 be ? 

SubstitutionEvaluation

 of 

TemplateMiddleList

.

2.  Let 

nextRef

 be the result of evaluating 

Expression

.

3.  Let 

next

 be ? 

GetValue

(

nextRef

).

4.  Append 

next

 as the last element of the 

List

 

preceding

.

5.  Return 

preceding

.

TemplateLiteral

 

:

 

NoSubstitutionTemplate

1.  Return the TV of 

NoSubstitutionTemplate

 as defined in 

12.8.6

.

SubstitutionTemplate

 

:

 

TemplateHead

 

Expression

 

TemplateSpans

1.  Let 

head

 be the TV of 

TemplateHead

 as defined in 

12.8.6

.

2.  Let 

subRef

 be the result of evaluating 

Expression

.

3.  Let 

sub

 be ? 

GetValue

(

subRef

).

4.  Let 

middle

 be ? 

ToString

(

sub

).

5.  Let 

tail

 be the result of evaluating 

TemplateSpans

.

6. 

ReturnIfAbrupt

(

tail

).

7.  Return the 

string-concatenation

 of 

head

middle

, and 

tail

.

NOTE 1

TemplateSpans

 

:

 

TemplateTail

1.  Return the TV of 

TemplateTail

 as defined in 

12.8.6

.

TemplateSpans

 

:

 

TemplateMiddleList

 

TemplateTail

Future editions of this specification may define additional non-enumerable properties of
template objects.

The string conversion semantics applied to the 

Expression

 value are like

String.prototype.concat

String.prototype.concat

 rather than the 

++

 operator.

13.2.9.4  Runtime Semantics: SubstitutionEvaluation

13.2.9.5  Runtime Semantics: Evaluation

317

1.  Let 

head

 be the result of evaluating 

TemplateMiddleList

.

2. 

ReturnIfAbrupt

(

head

).

3.  Let 

tail

 be the TV of 

TemplateTail

 as defined in 

12.8.6

.

4.  Return the 

string-concatenation

 of 

head

 and 

tail

.

TemplateMiddleList

 

:

 

TemplateMiddle

 

Expression

1.  Let 

head

 be the TV of 

TemplateMiddle

 as defined in 

12.8.6

.

2.  Let 

subRef

 be the result of evaluating 

Expression

.

3.  Let 

sub

 be ? 

GetValue

(

subRef

).

4.  Let 

middle

 be ? 

ToString

(

sub

).

5.  Return the 

string-concatenation

 of 

head

 and 

middle

.

NOTE 2

TemplateMiddleList

 

:

 

TemplateMiddleList

 

TemplateMiddle

 

Expression

1.  Let 

rest

 be the result of evaluating 

TemplateMiddleList

.

2. 

ReturnIfAbrupt

(

rest

).

3.  Let 

middle

 be the TV of 

TemplateMiddle

 as defined in 

12.8.6

.

4.  Let 

subRef

 be the result of evaluating 

Expression

.

5.  Let 

sub

 be ? 

GetValue

(

subRef

).

6.  Let 

last

 be ? 

ToString

(

sub

).

7.  Return the 

string-concatenation

 of 

rest

middle

, and 

last

.

NOTE 3

PrimaryExpression

 

:

 

CoverParenthesizedExpressionAndArrowParameterList

It is a Syntax Error if 

CoverParenthesizedExpressionAndArrowParameterList

 is not 

covering

 a 

ParenthesizedExpression

.

All Early Error rules for 

ParenthesizedExpression

 and its derived productions also apply to

CoveredParenthesizedExpression

 of 

CoverParenthesizedExpressionAndArrowParameterList

.

PrimaryExpression

 

:

 

CoverParenthesizedExpressionAndArrowParameterList

1.  Let 

expr

 be 

CoveredParenthesizedExpression

 of 

CoverParenthesizedExpressionAndArrowParameterList

.

2.  Return the result of evaluating 

expr

.

ParenthesizedExpression

 

:

 

(

 

Expression

 

)

1.  Return the result of evaluating 

Expression

. This may be of type Reference.

The string conversion semantics applied to the 

Expression

 value are like

String.prototype.concat

String.prototype.concat

 rather than the 

++

 operator.

The string conversion semantics applied to the 

Expression

 value are like

String.prototype.concat

String.prototype.concat

 rather than the 

++

 operator.

13.2.10  The Grouping Operator

13.2.10.1  Static Semantics: Early Errors

13.2.10.2  Runtime Semantics: Evaluation

318

NOTE

MemberExpression

[Yield, Await]

 

:

PrimaryExpression

[?Yield, ?Await]

MemberExpression

[?Yield, ?Await]

 

[

 

Expression

[+In, ?Yield, ?Await]

 

]

MemberExpression

[?Yield, ?Await]

 

.

 

IdentifierName

MemberExpression

[?Yield, ?Await]

 

TemplateLiteral

[?Yield, ?Await, +Tagged]

SuperProperty

[?Yield, ?Await]

MetaProperty

new

 

MemberExpression

[?Yield, ?Await]

 

Arguments

[?Yield, ?Await]

SuperProperty

[Yield, Await]

 

:

super

 

[

 

Expression

[+In, ?Yield, ?Await]

 

]

super

 

.

 

IdentifierName

MetaProperty

 

:

NewTarget
ImportMeta

NewTarget

 

:

new

 

.

 

target

ImportMeta

 

:

import

 

.

 

meta

NewExpression

[Yield, Await]

 

:

MemberExpression

[?Yield, ?Await]

new

 

NewExpression

[?Yield, ?Await]

CallExpression

[Yield, Await]

 

:

CoverCallExpressionAndAsyncArrowHead

[?Yield, ?Await]

SuperCall

[?Yield, ?Await]

ImportCall

[?Yield, ?Await]

CallExpression

[?Yield, ?Await]

 

Arguments

[?Yield, ?Await]

CallExpression

[?Yield, ?Await]

 

[

 

Expression

[+In, ?Yield, ?Await]

 

]

CallExpression

[?Yield, ?Await]

 

.

 

IdentifierName

CallExpression

[?Yield, ?Await]

 

TemplateLiteral

[?Yield, ?Await, +Tagged]

This algorithm does not apply 

GetValue

 to the result of evaluating 

Expression

. The principal

motivation for this is so that operators such as 

delete

delete

 and 

typeof

typeof

 may be applied to

parenthesized expressions.

13.3  Left-Hand-Side Expressions

Syntax

319

SuperCall

[Yield, Await]

 

:

super

 

Arguments

[?Yield, ?Await]

ImportCall

[Yield, Await]

 

:

import

 

(

 

AssignmentExpression

[+In, ?Yield, ?Await]

 

)

Arguments

[Yield, Await]

 

:

(

 

)

(

 

ArgumentList

[?Yield, ?Await]

 

)

(

 

ArgumentList

[?Yield, ?Await]

 

,

 

)

ArgumentList

[Yield, Await]

 

:

AssignmentExpression

[+In, ?Yield, ?Await]

...

 

AssignmentExpression

[+In, ?Yield, ?Await]

ArgumentList

[?Yield, ?Await]

 

,

 

AssignmentExpression

[+In, ?Yield, ?Await]

ArgumentList

[?Yield, ?Await]

 

,

 

...

 

AssignmentExpression

[+In, ?Yield, ?Await]

OptionalExpression

[Yield, Await]

 

:

MemberExpression

[?Yield, ?Await]

 

OptionalChain

[?Yield, ?Await]

CallExpression

[?Yield, ?Await]

 

OptionalChain

[?Yield, ?Await]

OptionalExpression

[?Yield, ?Await]

 

OptionalChain

[?Yield, ?Await]

OptionalChain

[Yield, Await]

 

:

?.

 

Arguments

[?Yield, ?Await]

?.

 

[

 

Expression

[+In, ?Yield, ?Await]

 

]

?.

 

IdentifierName

?.

 

TemplateLiteral

[?Yield, ?Await, +Tagged]

OptionalChain

[?Yield, ?Await]

 

Arguments

[?Yield, ?Await]

OptionalChain

[?Yield, ?Await]

 

[

 

Expression

[+In, ?Yield, ?Await]

 

]

OptionalChain

[?Yield, ?Await]

 

.

 

IdentifierName

OptionalChain

[?Yield, ?Await]

 

TemplateLiteral

[?Yield, ?Await, +Tagged]

LeftHandSideExpression

[Yield, Await]

 

:

NewExpression

[?Yield, ?Await]

CallExpression

[?Yield, ?Await]

OptionalExpression

[?Yield, ?Await]

When processing an instance of the production 

CallExpression

 

:

 

CoverCallExpressionAndAsyncArrowHead

 

the interpretation of 

CoverCallExpressionAndAsyncArrowHead

 is refined using the following grammar:

CallMemberExpression

[Yield, Await]

 

:

MemberExpression

[?Yield, ?Await]

 

Arguments

[?Yield, ?Await]

Supplemental Syntax

320

OptionalChain

 

:

?.

 

TemplateLiteral

OptionalChain

 

TemplateLiteral

It is a Syntax Error if any code matches this production.

NOTE

ImportMeta

 

:

import

 

.

 

meta

It is a Syntax Error if the syntactic 

goal symbol

 is not 

Module

.

CoverCallExpressionAndAsyncArrowHead

 

:

 

MemberExpression

 

Arguments

1.  Return the 

CallMemberExpression

 that is 

covered

 by 

CoverCallExpressionAndAsyncArrowHead

.

This production exists in order to prevent automatic semicolon insertion rules (

12.9

) from being

applied to the following code:

so that it would be interpreted as two valid statements. The purpose is to maintain consistency
with similar code without optional chaining:

which is a valid statement and where automatic semicolon insertion does not apply.

a?.b

`c`

a.b

`c`

13.3.1  Static Semantics

13.3.1.1  Static Semantics: Early Errors

13.3.1.2  Static Semantics: CoveredCallExpression

13.3.2  Property Accessors

321

NOTE

MemberExpression

 

:

 

MemberExpression

 

[

 

Expression

 

]

1.  Let 

baseReference

 be the result of evaluating 

MemberExpression

.

2.  Let 

baseValue

 be ? 

GetValue

(

baseReference

).

3.  If the code matched by this 

MemberExpression

 is 

strict mode code

, let 

strict

 be 

true

; else let 

strict

 be 

false

.

4.  Return ? 

EvaluatePropertyAccessWithExpressionKey

(

baseValue

Expression

strict

).

MemberExpression

 

:

 

MemberExpression

 

.

 

IdentifierName

1.  Let 

baseReference

 be the result of evaluating 

MemberExpression

.

2.  Let 

baseValue

 be ? 

GetValue

(

baseReference

).

3.  If the code matched by this 

MemberExpression

 is 

strict mode code

, let 

strict

 be 

true

; else let 

strict

 be 

false

.

4.  Return ? 

EvaluatePropertyAccessWithIdentifierKey

(

baseValue

IdentifierName

strict

).

CallExpression

 

:

 

CallExpression

 

[

 

Expression

 

]

1.  Let 

baseReference

 be the result of evaluating 

CallExpression

.

2.  Let 

baseValue

 be ? 

GetValue

(

baseReference

).

3.  If the code matched by this 

CallExpression

 is 

strict mode code

, let 

strict

 be 

true

; else let 

strict

 be 

false

.

4.  Return ? 

EvaluatePropertyAccessWithExpressionKey

(

baseValue

Expression

strict

).

CallExpression

 

:

 

CallExpression

 

.

 

IdentifierName

Properties are accessed by name, using either the dot notation:

MemberExpression

 

..

 

IdentifierName

 

CallExpression

 

..

 

IdentifierName

or the bracket notation:

MemberExpression

 

[[

 

Expression

 

]]

 

CallExpression

 

[[

 

Expression

 

]]

The dot notation is explained by the following syntactic conversion:

MemberExpression

 

..

 

IdentifierName

is identical in its behaviour to

MemberExpression

 

[[

 <

identifier-name-string

]]

and similarly

CallExpression

 

..

 

IdentifierName

is identical in its behaviour to

CallExpression

 

[[

 <

identifier-name-string

]]

where <

identifier-name-string

> is the result of evaluating 

StringValue

 of 

IdentifierName

.

13.3.2.1  Runtime Semantics: Evaluation

322

1.  Let 

baseReference

 be the result of evaluating 

CallExpression

.

2.  Let 

baseValue

 be ? 

GetValue

(

baseReference

).

3.  If the code matched by this 

CallExpression

 is 

strict mode code

, let 

strict

 be 

true

; else let 

strict

 be 

false

.

4.  Return ? 

EvaluatePropertyAccessWithIdentifierKey

(

baseValue

IdentifierName

strict

).

The abstract operation EvaluatePropertyAccessWithExpressionKey takes arguments 

baseValue

 (an 

ECMAScript

language value

), 

expression

 (a 

Parse Node

), and 

strict

 (a Boolean). It performs the following steps when called:

1.  Let 

propertyNameReference

 be the result of evaluating 

expression

.

2.  Let 

propertyNameValue

 be ? 

GetValue

(

propertyNameReference

).

3.  Let 

bv

 be ? 

RequireObjectCoercible

(

baseValue

).

4.  Let 

propertyKey

 be ? 

ToPropertyKey

(

propertyNameValue

).

5.  Return the 

Reference Record

 { [[Base]]: 

bv

, [[ReferencedName]]: 

propertyKey

, [[Strict]]: 

strict

, [[ThisValue]]:

empty

 }.

The abstract operation EvaluatePropertyAccessWithIdentifierKey takes arguments 

baseValue

 (an 

ECMAScript

language value

), 

identifierName

 (a 

Parse Node

), and 

strict

 (a Boolean). It performs the following steps when called:

1. 

Assert

identifierName

 is an 

IdentifierName

.

2.  Let 

bv

 be ? 

RequireObjectCoercible

(

baseValue

).

3.  Let 

propertyNameString

 be 

StringValue

 of 

identifierName

.

4.  Return the 

Reference Record

 { [[Base]]: 

bv

, [[ReferencedName]]: 

propertyNameString

, [[Strict]]: 

strict

,

[[ThisValue]]: 

empty

 }.

NewExpression

 

:

 

new

 

NewExpression

1.  Return ? 

EvaluateNew

(

NewExpression

empty

).

MemberExpression

 

:

 

new

 

MemberExpression

 

Arguments

1.  Return ? 

EvaluateNew

(

MemberExpression

Arguments

).

The abstract operation EvaluateNew takes arguments 

constructExpr

 and 

arguments

. It performs the following steps

when called:

1. 

Assert

constructExpr

 is either a 

NewExpression

 or a 

MemberExpression

.

2. 

Assert

arguments

 is either 

empty

 or an 

Arguments

.

3.  Let 

ref

 be the result of evaluating 

constructExpr

.

4.  Let 

constructor

 be ? 

GetValue

(

ref

).

5.  If 

arguments

 is 

empty

, let 

argList

 be a new empty 

List

.

13.3.3  EvaluatePropertyAccessWithExpressionKey ( 

baseValue

expression

strict

 )

13.3.4  EvaluatePropertyAccessWithIdentifierKey ( 

baseValue

identifierName

strict

 )

13.3.5  The 

new

new

 Operator

13.3.5.1  Runtime Semantics: Evaluation

13.3.5.1.1  EvaluateNew ( 

constructExpr

arguments

 )

323

6.  Else,

a.  Let 

argList

 be ? 

ArgumentListEvaluation

 of 

arguments

.

7.  If 

IsConstructor

(

constructor

) is 

false

, throw a 

TypeError

 exception.

8.  Return ? 

Construct

(

constructor

argList

).

CallExpression

 

:

 

CoverCallExpressionAndAsyncArrowHead

1.  Let 

expr

 be 

CoveredCallExpression

 of 

CoverCallExpressionAndAsyncArrowHead

.

2.  Let 

memberExpr

 be the 

MemberExpression

 of 

expr

.

3.  Let 

arguments

 be the 

Arguments

 of 

expr

.

4.  Let 

ref

 be the result of evaluating 

memberExpr

.

5.  Let 

func

 be ? 

GetValue

(

ref

).

6.  If 

ref

 is a 

Reference Record

IsPropertyReference

(

ref

) is 

false

, and 

ref

.[[ReferencedName]] is 

"eval"

, then

a.  If 

SameValue

(

func

%eval%

) is 

true

, then

i.  Let 

argList

 be ? 

ArgumentListEvaluation

 of 

arguments

.

ii.  If 

argList

 has no elements, return 

undefined

.

iii.  Let 

evalArg

 be the first element of 

argList

.

iv.  If the source code matching this 

CallExpression

 is 

strict mode code

, let 

strictCaller

 be 

true

.

Otherwise let 

strictCaller

 be 

false

.

v.  Let 

evalRealm

 be 

the current Realm Record

.

vi.  Return ? 

PerformEval

(

evalArg

evalRealm

strictCaller

true

).

7.  Let 

thisCall

 be this 

CallExpression

.

8.  Let 

tailCall

 be 

IsInTailPosition

(

thisCall

).

9.  Return ? 

EvaluateCall

(

func

ref

arguments

tailCall

).

CallExpression

 evaluation that executes step 

6.a.vi

 is a 

direct eval

.

CallExpression

 

:

 

CallExpression

 

Arguments

1.  Let 

ref

 be the result of evaluating 

CallExpression

.

2.  Let 

func

 be ? 

GetValue

(

ref

).

3.  Let 

thisCall

 be this 

CallExpression

.

4.  Let 

tailCall

 be 

IsInTailPosition

(

thisCall

).

5.  Return ? 

EvaluateCall

(

func

ref

Arguments

tailCall

).

The abstract operation EvaluateCall takes arguments 

func

 (an 

ECMAScript language value

), 

ref

 (an 

ECMAScript

language value

 or a 

Reference Record

), 

arguments

 (a 

Parse Node

), and 

tailPosition

 (a Boolean). It performs the

following steps when called:

1.  If 

ref

 is a 

Reference Record

, then

a.  If 

IsPropertyReference

(

ref

) is 

true

, then

i.  Let 

thisValue

 be 

GetThisValue

(

ref

).

b.  Else,

i.  Let 

refEnv

 be 

ref

.[[Base]].

13.3.6  Function Calls

13.3.6.1  Runtime Semantics: Evaluation

13.3.6.2  EvaluateCall ( 

func

ref

arguments

tailPosition

 )

324

ii. 

Assert

refEnv

 is an 

Environment Record

.

iii.  Let 

thisValue

 be 

refEnv

.WithBaseObject().

2.  Else,

a.  Let 

thisValue

 be 

undefined

.

3.  Let 

argList

 be ? 

ArgumentListEvaluation

 of 

arguments

.

4.  If 

Type

(

func

) is not Object, throw a 

TypeError

 exception.

5.  If 

IsCallable

(

func

) is 

false

, throw a 

TypeError

 exception.

6.  If 

tailPosition

 is 

true

, perform 

PrepareForTailCall

().

7.  Let 

result

 be 

Call

(

func

thisValue

argList

).

8. 

Assert

: If 

tailPosition

 is 

true

, the above call will not return here, but instead evaluation will continue as if the

following return has already occurred.

9. 

Assert

: If 

result

 is not an 

abrupt completion

, then 

Type

(

result

) is an 

ECMAScript language type

.

10.  Return 

result

.

SuperProperty

 

:

 

super

 

[

 

Expression

 

]

1.  Let 

env

 be 

GetThisEnvironment

().

2.  Let 

actualThis

 be ? 

env

.GetThisBinding().

3.  Let 

propertyNameReference

 be the result of evaluating 

Expression

.

4.  Let 

propertyNameValue

 be ? 

GetValue

(

propertyNameReference

).

5.  Let 

propertyKey

 be ? 

ToPropertyKey

(

propertyNameValue

).

6.  If the code matched by this 

SuperProperty

 is 

strict mode code

, let 

strict

 be 

true

; else let 

strict

 be 

false

.

7.  Return ? 

MakeSuperPropertyReference

(

actualThis

propertyKey

strict

).

SuperProperty

 

:

 

super

 

.

 

IdentifierName

1.  Let 

env

 be 

GetThisEnvironment

().

2.  Let 

actualThis

 be ? 

env

.GetThisBinding().

3.  Let 

propertyKey

 be 

StringValue

 of 

IdentifierName

.

4.  If the code matched by this 

SuperProperty

 is 

strict mode code

, let 

strict

 be 

true

; else let 

strict

 be 

false

.

5.  Return ? 

MakeSuperPropertyReference

(

actualThis

propertyKey

strict

).

SuperCall

 

:

 

super

 

Arguments

1.  Let 

newTarget

 be 

GetNewTarget

().

2. 

Assert

Type

(

newTarget

) is Object.

3.  Let 

func

 be ! 

GetSuperConstructor

().

4.  Let 

argList

 be ? 

ArgumentListEvaluation

 of 

Arguments

.

5.  If 

IsConstructor

(

func

) is 

false

, throw a 

TypeError

 exception.

6.  Let 

result

 be ? 

Construct

(

func

argList

newTarget

).

7.  Let 

thisER

 be 

GetThisEnvironment

().

8.  Return ? 

thisER

.BindThisValue(

result

).

The abstract operation GetSuperConstructor takes no arguments. It performs the following steps when called:

13.3.7  The 

super

super

 Keyword

13.3.7.1  Runtime Semantics: Evaluation

13.3.7.2  GetSuperConstructor ( )

325

1.  Let 

envRec

 be 

GetThisEnvironment

().

2. 

Assert

envRec

 is a 

function Environment Record

.

3.  Let 

activeFunction

 be 

envRec

.[[FunctionObject]].

4. 

Assert

activeFunction

 is an ECMAScript 

function object

.

5.  Let 

superConstructor

 be ! 

activeFunction

.[[GetPrototypeOf]]().

6.  Return 

superConstructor

.

The abstract operation MakeSuperPropertyReference takes arguments 

actualThis

propertyKey

, and 

strict

. It performs

the following steps when called:

1.  Let 

env

 be 

GetThisEnvironment

().

2. 

Assert

env

.HasSuperBinding() is 

true

.

3.  Let 

baseValue

 be ? 

env

.GetSuperBase().

4.  Let 

bv

 be ? 

RequireObjectCoercible

(

baseValue

).

5.  Return the 

Reference Record

 { [[Base]]: 

bv

, [[ReferencedName]]: 

propertyKey

, [[Strict]]: 

strict

, [[ThisValue]]:

actualThis

 }.

6.  NOTE: This returns a 

Super Reference Record

.

NOTE

Arguments

 

:

 

(

 

)

1.  Return a new empty 

List

.

ArgumentList

 

:

 

AssignmentExpression

1.  Let 

ref

 be the result of evaluating 

AssignmentExpression

.

2.  Let 

arg

 be ? 

GetValue

(

ref

).

3.  Return a 

List

 whose sole element is 

arg

.

ArgumentList

 

:

 

...

 

AssignmentExpression

1.  Let 

list

 be a new empty 

List

.

2.  Let 

spreadRef

 be the result of evaluating 

AssignmentExpression

.

3.  Let 

spreadObj

 be ? 

GetValue

(

spreadRef

).

4.  Let 

iteratorRecord

 be ? 

GetIterator

(

spreadObj

).

5.  Repeat,

a.  Let 

next

 be ? 

IteratorStep

(

iteratorRecord

).

b.  If 

next

 is 

false

, return 

list

.

c.  Let 

nextArg

 be ? 

IteratorValue

(

next

).

d.  Append 

nextArg

 as the last element of 

list

.

ArgumentList

 

:

 

ArgumentList

 

,

 

AssignmentExpression

The evaluation of an argument list produces a 

List

 of values.

13.3.7.3  MakeSuperPropertyReference ( 

actualThis

propertyKey

strict

 )

13.3.8  Argument Lists

13.3.8.1  Runtime Semantics: ArgumentListEvaluation

326

1.  Let 

precedingArgs

 be ? 

ArgumentListEvaluation

 of 

ArgumentList

.

2.  Let 

ref

 be the result of evaluating 

AssignmentExpression

.

3.  Let 

arg

 be ? 

GetValue

(

ref

).

4.  Append 

arg

 to the end of 

precedingArgs

.

5.  Return 

precedingArgs

.

ArgumentList

 

:

 

ArgumentList

 

,

 

...

 

AssignmentExpression

1.  Let 

precedingArgs

 be ? 

ArgumentListEvaluation

 of 

ArgumentList

.

2.  Let 

spreadRef

 be the result of evaluating 

AssignmentExpression

.

3.  Let 

iteratorRecord

 be ? 

GetIterator

(? 

GetValue

(

spreadRef

)).

4.  Repeat,

a.  Let 

next

 be ? 

IteratorStep

(

iteratorRecord

).

b.  If 

next

 is 

false

, return 

precedingArgs

.

c.  Let 

nextArg

 be ? 

IteratorValue

(

next

).

d.  Append 

nextArg

 as the last element of 

precedingArgs

.

TemplateLiteral

 

:

 

NoSubstitutionTemplate

1.  Let 

templateLiteral

 be this 

TemplateLiteral

.

2.  Let 

siteObj

 be 

GetTemplateObject

(

templateLiteral

).

3.  Return a 

List

 whose sole element is 

siteObj

.

TemplateLiteral

 

:

 

SubstitutionTemplate

1.  Let 

templateLiteral

 be this 

TemplateLiteral

.

2.  Let 

siteObj

 be 

GetTemplateObject

(

templateLiteral

).

3.  Let 

remaining

 be ? 

ArgumentListEvaluation

 of 

SubstitutionTemplate

.

4.  Return a 

List

 whose first element is 

siteObj

 and whose subsequent elements are the elements of 

remaining

.

SubstitutionTemplate

 

:

 

TemplateHead

 

Expression

 

TemplateSpans

1.  Let 

firstSubRef

 be the result of evaluating 

Expression

.

2.  Let 

firstSub

 be ? 

GetValue

(

firstSubRef

).

3.  Let 

restSub

 be ? 

SubstitutionEvaluation

 of 

TemplateSpans

.

4. 

Assert

restSub

 is a 

List

.

5.  Return a 

List

 whose first element is 

firstSub

 and whose subsequent elements are the elements of 

restSub

restSub

may contain no elements.

NOTE

OptionalExpression

 

:

MemberExpression

 

OptionalChain

1.  Let 

baseReference

 be the result of evaluating 

MemberExpression

.

An optional chain is a chain of one or more property accesses and function calls, the first of
which begins with the token 

?.

?.

.

13.3.9  Optional Chains

13.3.9.1  Runtime Semantics: Evaluation

327

2.  Let 

baseValue

 be ? 

GetValue

(

baseReference

).

3.  If 

baseValue

 is 

undefined

 or 

null

, then

a.  Return 

undefined

.

4.  Return the result of performing 

ChainEvaluation

 of 

OptionalChain

 with arguments 

baseValue

 and 

baseReference

.

OptionalExpression

 

:

CallExpression

 

OptionalChain

1.  Let 

baseReference

 be the result of evaluating 

CallExpression

.

2.  Let 

baseValue

 be ? 

GetValue

(

baseReference

).

3.  If 

baseValue

 is 

undefined

 or 

null

, then

a.  Return 

undefined

.

4.  Return the result of performing 

ChainEvaluation

 of 

OptionalChain

 with arguments 

baseValue

 and 

baseReference

.

OptionalExpression

 

:

OptionalExpression

 

OptionalChain

1.  Let 

baseReference

 be the result of evaluating 

OptionalExpression

.

2.  Let 

baseValue

 be ? 

GetValue

(

baseReference

).

3.  If 

baseValue

 is 

undefined

 or 

null

, then

a.  Return 

undefined

.

4.  Return the result of performing 

ChainEvaluation

 of 

OptionalChain

 with arguments 

baseValue

 and 

baseReference

.

With parameters 

baseValue

 and 

baseReference

.

OptionalChain

 

:

 

?.

 

Arguments

1.  Let 

thisChain

 be this 

OptionalChain

.

2.  Let 

tailCall

 be 

IsInTailPosition

(

thisChain

).

3.  Return ? 

EvaluateCall

(

baseValue

baseReference

Arguments

tailCall

).

OptionalChain

 

:

 

?.

 

[

 

Expression

 

]

1.  If the code matched by this 

OptionalChain

 is 

strict mode code

, let 

strict

 be 

true

; else let 

strict

 be 

false

.

2.  Return ? 

EvaluatePropertyAccessWithExpressionKey

(

baseValue

Expression

strict

).

OptionalChain

 

:

 

?.

 

IdentifierName

1.  If the code matched by this 

OptionalChain

 is 

strict mode code

, let 

strict

 be 

true

; else let 

strict

 be 

false

.

2.  Return ? 

EvaluatePropertyAccessWithIdentifierKey

(

baseValue

IdentifierName

strict

).

OptionalChain

 

:

 

OptionalChain

 

Arguments

1.  Let 

optionalChain

 be 

OptionalChain

.

2.  Let 

newReference

 be ? 

ChainEvaluation

 of 

optionalChain

 with arguments 

baseValue

 and 

baseReference

.

3.  Let 

newValue

 be ? 

GetValue

(

newReference

).

4.  Let 

thisChain

 be this 

OptionalChain

.

5.  Let 

tailCall

 be 

IsInTailPosition

(

thisChain

).

6.  Return ? 

EvaluateCall

(

newValue

newReference

Arguments

tailCall

).

13.3.9.2  Runtime Semantics: ChainEvaluation

328

OptionalChain

 

:

 

OptionalChain

 

[

 

Expression

 

]

1.  Let 

optionalChain

 be 

OptionalChain

.

2.  Let 

newReference

 be ? 

ChainEvaluation

 of 

optionalChain

 with arguments 

baseValue

 and 

baseReference

.

3.  Let 

newValue

 be ? 

GetValue

(

newReference

).

4.  If the code matched by this 

OptionalChain

 is 

strict mode code

, let 

strict

 be 

true

; else let 

strict

 be 

false

.

5.  Return ? 

EvaluatePropertyAccessWithExpressionKey

(

newValue

Expression

strict

).

OptionalChain

 

:

 

OptionalChain

 

.

 

IdentifierName

1.  Let 

optionalChain

 be 

OptionalChain

.

2.  Let 

newReference

 be ? 

ChainEvaluation

 of 

optionalChain

 with arguments 

baseValue

 and 

baseReference

.

3.  Let 

newValue

 be ? 

GetValue

(

newReference

).

4.  If the code matched by this 

OptionalChain

 is 

strict mode code

, let 

strict

 be 

true

; else let 

strict

 be 

false

.

5.  Return ? 

EvaluatePropertyAccessWithIdentifierKey

(

newValue

IdentifierName

strict

).

ImportCall

 

:

 

import

 

(

 

AssignmentExpression

 

)

1.  Let 

referencingScriptOrModule

 be ! 

GetActiveScriptOrModule

().

2.  Let 

argRef

 be the result of evaluating 

AssignmentExpression

.

3.  Let 

specifier

 be ? 

GetValue

(

argRef

).

4.  Let 

promiseCapability

 be ! 

NewPromiseCapability

(

%Promise%

).

5.  Let 

specifierString

 be 

ToString

(

specifier

).

6. 

IfAbruptRejectPromise

(

specifierString

promiseCapability

).

7.  Perform ! 

HostImportModuleDynamically

(

referencingScriptOrModule

specifierString

promiseCapability

).

8.  Return 

promiseCapability

.[[Promise]].

NOTE

MemberExpression

 

:

 

MemberExpression

 

TemplateLiteral

1.  Let 

tagRef

 be the result of evaluating 

MemberExpression

.

2.  Let 

tagFunc

 be ? 

GetValue

(

tagRef

).

3.  Let 

thisCall

 be this 

MemberExpression

.

4.  Let 

tailCall

 be 

IsInTailPosition

(

thisCall

).

5.  Return ? 

EvaluateCall

(

tagFunc

tagRef

TemplateLiteral

tailCall

).

CallExpression

 

:

 

CallExpression

 

TemplateLiteral

1.  Let 

tagRef

 be the result of evaluating 

CallExpression

.

A tagged template is a function call where the arguments of the call are derived from a 

TemplateLiteral

 (

13.2.9

). The actual arguments include a template object (

13.2.9.3

) and the values

produced by evaluating the expressions embedded within the 

TemplateLiteral

.

13.3.10  Import Calls

13.3.10.1  Runtime Semantics: Evaluation

13.3.11  Tagged Templates

13.3.11.1  Runtime Semantics: Evaluation

329

 

 

 

 

 

 

 

Content      ..     40      41      42      43     ..