8 语法制导操作

除本节中定义的这些之外,本规范各处还定义了专门的语法制导操作

8.1 Runtime Semantics: Evaluation

The syntax-directed operation Evaluation takes no arguments and returns 一个 Completion Record.

Note
此操作的定义分布在本规范的“ECMAScript Language”各节中。每个定义都出现在相关产生式的定义位置之后。

8.2 作用域分析

8.2.1 Static Semantics: BoundNames

The syntax-directed operation BoundNames takes no arguments and returns 一个 String 的 List.

Note

当模块的默认导出没有其他名称时,本规范内部使用 "*default*" 作为该模块默认导出的合成名称。会用这个名字在模块的 [[Environment]] 中创建一个条目并保存相应的值,而通过对该模块调用 ResolveExport ( exportName [ , resolveSet ] ) 来解析名为 "default" 的导出时,将返回一个 [[BindingName]]"*default*" 的 ResolvedBinding Record,随后它会在模块的 [[Environment]] 中解析到上面提到的值。这样做只是为了便于规范表述,使匿名默认导出可以像其他导出一样被解析。这个 "*default*" 字符串永远不能被 ECMAScript 代码或模块链接算法访问到。

It is defined piecewise over the following productions:

BindingIdentifier : Identifier
  1. 返回一个 List,其唯一元素为 IdentifierStringValue
BindingIdentifier : yield
  1. 返回 « "yield" »。
BindingIdentifier : await
  1. 返回 « "await" »。
LexicalDeclaration : LetOrConst BindingList ;
  1. 返回 BindingListBoundNames
BindingList : BindingList , LexicalBinding
  1. names1BindingListBoundNames
  2. names2LexicalBindingBoundNames
  3. 返回 names1names2列表连接
LexicalBinding : BindingIdentifier Initializeropt
  1. 返回 BindingIdentifierBoundNames
LexicalBinding : BindingPattern Initializer
  1. 返回 BindingPatternBoundNames
VariableDeclarationList : VariableDeclarationList , VariableDeclaration
  1. names1VariableDeclarationListBoundNames
  2. names2VariableDeclarationBoundNames
  3. 返回 names1names2列表连接
VariableDeclaration : BindingIdentifier Initializeropt
  1. 返回 BindingIdentifierBoundNames
VariableDeclaration : BindingPattern Initializer
  1. 返回 BindingPatternBoundNames
ObjectBindingPattern : { }
  1. 返回一个新的空 List
ObjectBindingPattern : { BindingPropertyList , BindingRestProperty }
  1. names1BindingPropertyListBoundNames
  2. names2BindingRestPropertyBoundNames
  3. 返回 names1names2列表连接
ArrayBindingPattern : [ Elisionopt ]
  1. 返回一个新的空 List
ArrayBindingPattern : [ Elisionopt BindingRestElement ]
  1. 返回 BindingRestElementBoundNames
ArrayBindingPattern : [ BindingElementList , Elisionopt ]
  1. 返回 BindingElementListBoundNames
ArrayBindingPattern : [ BindingElementList , Elisionopt BindingRestElement ]
  1. names1BindingElementListBoundNames
  2. names2BindingRestElementBoundNames
  3. 返回 names1names2列表连接
BindingPropertyList : BindingPropertyList , BindingProperty
  1. names1BindingPropertyListBoundNames
  2. names2BindingPropertyBoundNames
  3. 返回 names1names2列表连接
BindingElementList : BindingElementList , BindingElisionElement
  1. names1BindingElementListBoundNames
  2. names2BindingElisionElementBoundNames
  3. 返回 names1names2列表连接
BindingElisionElement : Elisionopt BindingElement
  1. 返回 BindingElementBoundNames
BindingProperty : PropertyName : BindingElement
  1. 返回 BindingElementBoundNames
SingleNameBinding : BindingIdentifier Initializeropt
  1. 返回 BindingIdentifierBoundNames
BindingElement : BindingPattern Initializeropt
  1. 返回 BindingPatternBoundNames
ForDeclaration : LetOrConst ForBinding
  1. 返回 ForBindingBoundNames
FunctionDeclaration : function BindingIdentifier ( FormalParameters ) { FunctionBody }
  1. 返回 BindingIdentifierBoundNames
FunctionDeclaration : function ( FormalParameters ) { FunctionBody }
  1. 返回 « "*default*" »。
FormalParameters : [empty]
  1. 返回一个新的空 List
FormalParameters : FormalParameterList , FunctionRestParameter
  1. names1FormalParameterListBoundNames
  2. names2FunctionRestParameterBoundNames
  3. 返回 names1names2列表连接
FormalParameterList : FormalParameterList , FormalParameter
  1. names1FormalParameterListBoundNames
  2. names2FormalParameterBoundNames
  3. 返回 names1names2列表连接
ArrowParameters : CoverParenthesizedExpressionAndArrowParameterList
  1. formals 为被 CoverParenthesizedExpressionAndArrowParameterList 覆盖ArrowFormalParameters
  2. 返回 formalsBoundNames
GeneratorDeclaration : function * BindingIdentifier ( FormalParameters ) { GeneratorBody }
  1. 返回 BindingIdentifierBoundNames
GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody }
  1. 返回 « "*default*" »。
AsyncGeneratorDeclaration : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody }
  1. 返回 BindingIdentifierBoundNames
AsyncGeneratorDeclaration : async function * ( FormalParameters ) { AsyncGeneratorBody }
  1. 返回 « "*default*" »。
ClassDeclaration : class BindingIdentifier ClassTail
  1. 返回 BindingIdentifierBoundNames
ClassDeclaration : class ClassTail
  1. 返回 « "*default*" »。
AsyncFunctionDeclaration : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody }
  1. 返回 BindingIdentifierBoundNames
AsyncFunctionDeclaration : async function ( FormalParameters ) { AsyncFunctionBody }
  1. 返回 « "*default*" »。
CoverCallExpressionAndAsyncArrowHead : MemberExpression Arguments
  1. head 为被 CoverCallExpressionAndAsyncArrowHead 覆盖AsyncArrowHead
  2. 返回 headBoundNames
ImportDeclaration : import ImportClause FromClause WithClauseopt ;
  1. 返回 ImportClauseBoundNames
ImportDeclaration : import ModuleSpecifier WithClauseopt ;
  1. 返回一个新的空 List
ImportClause : ImportedDefaultBinding , NameSpaceImport
  1. names1ImportedDefaultBindingBoundNames
  2. names2NameSpaceImportBoundNames
  3. 返回 names1names2列表连接
ImportClause : ImportedDefaultBinding , NamedImports
  1. names1ImportedDefaultBindingBoundNames
  2. names2NamedImportsBoundNames
  3. 返回 names1names2列表连接
NamedImports : { }
  1. 返回一个新的空 List
ImportsList : ImportsList , ImportSpecifier
  1. names1ImportsListBoundNames
  2. names2ImportSpecifierBoundNames
  3. 返回 names1names2列表连接
ImportSpecifier : ModuleExportName as ImportedBinding
  1. 返回 ImportedBindingBoundNames
ExportDeclaration : export ExportFromClause FromClause WithClauseopt ; export NamedExports ;
  1. 返回一个新的空 List
ExportDeclaration : export VariableStatement
  1. 返回 VariableStatementBoundNames
ExportDeclaration : export Declaration
  1. 返回 DeclarationBoundNames
ExportDeclaration : export default HoistableDeclaration
  1. declarationNamesHoistableDeclarationBoundNames
  2. 如果 declarationNames 不包含元素 "*default*",则将 "*default*" 追加到 declarationNames
  3. 返回 declarationNames
ExportDeclaration : export default ClassDeclaration
  1. declarationNamesClassDeclarationBoundNames
  2. 如果 declarationNames 不包含元素 "*default*",则将 "*default*" 追加到 declarationNames
  3. 返回 declarationNames
ExportDeclaration : export default AssignmentExpression ;
  1. 返回 « "*default*" »。

8.2.2 Static Semantics: DeclarationPart

The syntax-directed operation DeclarationPart takes no arguments and returns 一个 Parse Node. It is defined piecewise over the following productions:

HoistableDeclaration : FunctionDeclaration
  1. 返回 FunctionDeclaration
HoistableDeclaration : GeneratorDeclaration
  1. 返回 GeneratorDeclaration
HoistableDeclaration : AsyncFunctionDeclaration
  1. 返回 AsyncFunctionDeclaration
HoistableDeclaration : AsyncGeneratorDeclaration
  1. 返回 AsyncGeneratorDeclaration
Declaration : ClassDeclaration
  1. 返回 ClassDeclaration
Declaration : LexicalDeclaration
  1. 返回 LexicalDeclaration

8.2.3 Static Semantics: IsConstantDeclaration

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

LexicalDeclaration : LetOrConst BindingList ;
  1. 返回 LetOrConstIsConstantDeclaration
LetOrConst : let
  1. 返回 false
LetOrConst : const
  1. 返回 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. 返回 false
ClassDeclaration : class BindingIdentifier ClassTail class ClassTail
  1. 返回 false
ExportDeclaration : export ExportFromClause FromClause ; export NamedExports ; export default AssignmentExpression ;
  1. 返回 false
Note

不必将 export default AssignmentExpression 视为常量声明,因为不存在任何语法允许对用于引用模块默认对象的内部绑定名进行赋值。

8.2.4 Static Semantics: LexicallyDeclaredNames

The syntax-directed operation LexicallyDeclaredNames takes no arguments and returns 一个 String 的 List. It is defined piecewise over the following productions:

Block : { }
  1. 返回一个新的空 List
StatementList : StatementList StatementListItem
  1. names1StatementListLexicallyDeclaredNames
  2. names2StatementListItemLexicallyDeclaredNames
  3. 返回 names1names2列表连接
StatementListItem : Statement
  1. 如果 Statement Statement : LabelledStatement ,返回 LabelledStatementLexicallyDeclaredNames
  2. 返回一个新的空 List
StatementListItem : Declaration
  1. 返回 DeclarationBoundNames
CaseBlock : { }
  1. 返回一个新的空 List
CaseBlock : { CaseClausesopt DefaultClause CaseClausesopt }
  1. 如果第一个 CaseClauses 存在,令 names1 为第一个 CaseClausesLexicallyDeclaredNames
  2. 否则,令 names1 为一个新的空 List
  3. names2DefaultClauseLexicallyDeclaredNames
  4. 如果第二个 CaseClauses 存在,令 names3 为第二个 CaseClausesLexicallyDeclaredNames
  5. 否则,令 names3 为一个新的空 List
  6. 返回 names1names2names3列表连接
CaseClauses : CaseClauses CaseClause
  1. names1CaseClausesLexicallyDeclaredNames
  2. names2CaseClauseLexicallyDeclaredNames
  3. 返回 names1names2列表连接
CaseClause : case Expression : StatementListopt
  1. 如果 StatementList 存在,返回 StatementListLexicallyDeclaredNames
  2. 返回一个新的空 List
DefaultClause : default : StatementListopt
  1. 如果 StatementList 存在,返回 StatementListLexicallyDeclaredNames
  2. 返回一个新的空 List
LabelledStatement : LabelIdentifier : LabelledItem
  1. 返回 LabelledItemLexicallyDeclaredNames
LabelledItem : Statement
  1. 返回一个新的空 List
LabelledItem : FunctionDeclaration
  1. 返回 FunctionDeclarationBoundNames
FunctionStatementList : [empty]
  1. 返回一个新的空 List
FunctionStatementList : StatementList
  1. 返回 StatementListTopLevelLexicallyDeclaredNames
ClassStaticBlockStatementList : [empty]
  1. 返回一个新的空 List
ClassStaticBlockStatementList : StatementList
  1. 返回 StatementListTopLevelLexicallyDeclaredNames
ConciseBody : ExpressionBody
  1. 返回一个新的空 List
AsyncConciseBody : ExpressionBody
  1. 返回一个新的空 List
Script : [empty]
  1. 返回一个新的空 List
ScriptBody : StatementList
  1. 返回 StatementListTopLevelLexicallyDeclaredNames
Note 1

Script 的顶层,函数声明被当作 var 声明处理,而不是词法声明。

Note 2

Module 的 LexicallyDeclaredNames 包含其所有导入绑定的名称。

ModuleItemList : ModuleItemList ModuleItem
  1. names1ModuleItemListLexicallyDeclaredNames
  2. names2ModuleItemLexicallyDeclaredNames
  3. 返回 names1names2列表连接
ModuleItem : ImportDeclaration
  1. 返回 ImportDeclarationBoundNames
ModuleItem : ExportDeclaration
  1. 如果 ExportDeclarationexport VariableStatement,返回一个新的空 List
  2. 返回 ExportDeclarationBoundNames
ModuleItem : StatementListItem
  1. 返回 StatementListItemLexicallyDeclaredNames
Note 3

Module 的顶层,函数声明被当作词法声明处理,而不是 var 声明。

8.2.5 Static Semantics: LexicallyScopedDeclarations

The syntax-directed operation LexicallyScopedDeclarations takes no arguments and returns 一个 Parse Node 的 List. It is defined piecewise over the following productions:

StatementList : StatementList StatementListItem
  1. declarations1StatementListLexicallyScopedDeclarations
  2. declarations2StatementListItemLexicallyScopedDeclarations
  3. 返回 declarations1declarations2列表连接
StatementListItem : Statement
  1. 如果 Statement Statement : LabelledStatement ,返回 LabelledStatementLexicallyScopedDeclarations
  2. 返回一个新的空 List
StatementListItem : Declaration
  1. 返回一个 List,其唯一元素为 DeclarationDeclarationPart
CaseBlock : { }
  1. 返回一个新的空 List
CaseBlock : { CaseClausesopt DefaultClause CaseClausesopt }
  1. 如果第一个 CaseClauses 存在,令 declarations1 为第一个 CaseClausesLexicallyScopedDeclarations
  2. 否则,令 declarations1 为一个新的空 List
  3. declarations2DefaultClauseLexicallyScopedDeclarations
  4. 如果第二个 CaseClauses 存在,令 declarations3 为第二个 CaseClausesLexicallyScopedDeclarations
  5. 否则,令 declarations3 为一个新的空 List
  6. 返回 declarations1declarations2declarations3列表连接
CaseClauses : CaseClauses CaseClause
  1. declarations1CaseClausesLexicallyScopedDeclarations
  2. declarations2CaseClauseLexicallyScopedDeclarations
  3. 返回 declarations1declarations2列表连接
CaseClause : case Expression : StatementListopt
  1. 如果 StatementList 存在,返回 StatementListLexicallyScopedDeclarations
  2. 返回一个新的空 List
DefaultClause : default : StatementListopt
  1. 如果 StatementList 存在,返回 StatementListLexicallyScopedDeclarations
  2. 返回一个新的空 List
LabelledStatement : LabelIdentifier : LabelledItem
  1. 返回 LabelledItemLexicallyScopedDeclarations
LabelledItem : Statement
  1. 返回一个新的空 List
LabelledItem : FunctionDeclaration
  1. 返回 « FunctionDeclaration »。
FunctionStatementList : [empty]
  1. 返回一个新的空 List
FunctionStatementList : StatementList
  1. 返回 StatementListTopLevelLexicallyScopedDeclarations
ClassStaticBlockStatementList : [empty]
  1. 返回一个新的空 List
ClassStaticBlockStatementList : StatementList
  1. 返回 StatementListTopLevelLexicallyScopedDeclarations
ConciseBody : ExpressionBody
  1. 返回一个新的空 List
AsyncConciseBody : ExpressionBody
  1. 返回一个新的空 List
Script : [empty]
  1. 返回一个新的空 List
ScriptBody : StatementList
  1. 返回 StatementListTopLevelLexicallyScopedDeclarations
Module : [empty]
  1. 返回一个新的空 List
ModuleItemList : ModuleItemList ModuleItem
  1. declarations1ModuleItemListLexicallyScopedDeclarations
  2. declarations2ModuleItemLexicallyScopedDeclarations
  3. 返回 declarations1declarations2列表连接
ModuleItem : ImportDeclaration
  1. 返回一个新的空 List
ExportDeclaration : export ExportFromClause FromClause WithClauseopt ; export NamedExports ; export VariableStatement
  1. 返回一个新的空 List
ExportDeclaration : export Declaration
  1. 返回一个 List,其唯一元素为 DeclarationDeclarationPart
ExportDeclaration : export default HoistableDeclaration
  1. 返回一个 List,其唯一元素为 HoistableDeclarationDeclarationPart
ExportDeclaration : export default ClassDeclaration
  1. 返回一个 List,其唯一元素为 ClassDeclaration
ExportDeclaration : export default AssignmentExpression ;
  1. 返回一个 List,其唯一元素为该 ExportDeclaration

8.2.6 Static Semantics: VarDeclaredNames

The syntax-directed operation VarDeclaredNames takes no arguments and returns 一个 String 的 List. It is defined piecewise over the following productions:

Statement : EmptyStatement ExpressionStatement ContinueStatement BreakStatement ReturnStatement ThrowStatement DebuggerStatement
  1. 返回一个新的空 List
Block : { }
  1. 返回一个新的空 List
StatementList : StatementList StatementListItem
  1. names1StatementListVarDeclaredNames
  2. names2StatementListItemVarDeclaredNames
  3. 返回 names1names2列表连接
StatementListItem : Declaration
  1. 返回一个新的空 List
VariableStatement : var VariableDeclarationList ;
  1. 返回 VariableDeclarationListBoundNames
IfStatement : if ( Expression ) Statement else Statement
  1. names1 为第一个 StatementVarDeclaredNames
  2. names2 为第二个 StatementVarDeclaredNames
  3. 返回 names1names2列表连接
IfStatement : if ( Expression ) Statement
  1. 返回 StatementVarDeclaredNames
DoWhileStatement : do Statement while ( Expression ) ;
  1. 返回 StatementVarDeclaredNames
WhileStatement : while ( Expression ) Statement
  1. 返回 StatementVarDeclaredNames
ForStatement : for ( Expressionopt ; Expressionopt ; Expressionopt ) Statement
  1. 返回 StatementVarDeclaredNames
ForStatement : for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
  1. names1VariableDeclarationListBoundNames
  2. names2StatementVarDeclaredNames
  3. 返回 names1names2列表连接
ForStatement : for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
  1. 返回 StatementVarDeclaredNames
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. 返回 StatementVarDeclaredNames
ForInOfStatement : for ( var ForBinding in Expression ) Statement for ( var ForBinding of AssignmentExpression ) Statement for await ( var ForBinding of AssignmentExpression ) Statement
  1. names1ForBindingBoundNames
  2. names2StatementVarDeclaredNames
  3. 返回 names1names2列表连接
Note

本节由附录 B.3.5 扩展。

WithStatement : with ( Expression ) Statement
  1. 返回 StatementVarDeclaredNames
SwitchStatement : switch ( Expression ) CaseBlock
  1. 返回 CaseBlockVarDeclaredNames
CaseBlock : { }
  1. 返回一个新的空 List
CaseBlock : { CaseClausesopt DefaultClause CaseClausesopt }
  1. 如果第一个 CaseClauses 存在,令 names1 为第一个 CaseClausesVarDeclaredNames
  2. 否则,令 names1 为一个新的空 List
  3. names2DefaultClauseVarDeclaredNames
  4. 如果第二个 CaseClauses 存在,令 names3 为第二个 CaseClausesVarDeclaredNames
  5. 否则,令 names3 为一个新的空 List
  6. 返回 names1names2names3列表连接
CaseClauses : CaseClauses CaseClause
  1. names1CaseClausesVarDeclaredNames
  2. names2CaseClauseVarDeclaredNames
  3. 返回 names1names2列表连接
CaseClause : case Expression : StatementListopt
  1. 如果 StatementList 存在,返回 StatementListVarDeclaredNames
  2. 返回一个新的空 List
DefaultClause : default : StatementListopt
  1. 如果 StatementList 存在,返回 StatementListVarDeclaredNames
  2. 返回一个新的空 List
LabelledStatement : LabelIdentifier : LabelledItem
  1. 返回 LabelledItemVarDeclaredNames
LabelledItem : FunctionDeclaration
  1. 返回一个新的空 List
TryStatement : try Block Catch
  1. names1BlockVarDeclaredNames
  2. names2CatchVarDeclaredNames
  3. 返回 names1names2列表连接
TryStatement : try Block Finally
  1. names1BlockVarDeclaredNames
  2. names2FinallyVarDeclaredNames
  3. 返回 names1names2列表连接
TryStatement : try Block Catch Finally
  1. names1BlockVarDeclaredNames
  2. names2CatchVarDeclaredNames
  3. names3FinallyVarDeclaredNames
  4. 返回 names1names2names3列表连接
Catch : catch ( CatchParameter ) Block
  1. 返回 BlockVarDeclaredNames
FunctionStatementList : [empty]
  1. 返回一个新的空 List
FunctionStatementList : StatementList
  1. 返回 StatementListTopLevelVarDeclaredNames
ClassStaticBlockStatementList : [empty]
  1. 返回一个新的空 List
ClassStaticBlockStatementList : StatementList
  1. 返回 StatementListTopLevelVarDeclaredNames
ConciseBody : ExpressionBody
  1. 返回一个新的空 List
AsyncConciseBody : ExpressionBody
  1. 返回一个新的空 List
Script : [empty]
  1. 返回一个新的空 List
ScriptBody : StatementList
  1. 返回 StatementListTopLevelVarDeclaredNames
ModuleItemList : ModuleItemList ModuleItem
  1. names1ModuleItemListVarDeclaredNames
  2. names2ModuleItemVarDeclaredNames
  3. 返回 names1names2列表连接
ModuleItem : ImportDeclaration
  1. 返回一个新的空 List
ModuleItem : ExportDeclaration
  1. 如果 ExportDeclarationexport VariableStatement,返回 ExportDeclarationBoundNames
  2. 返回一个新的空 List

8.2.7 Static Semantics: VarScopedDeclarations

The syntax-directed operation VarScopedDeclarations takes no arguments and returns 一个 Parse Node 的 List. It is defined piecewise over the following productions:

Statement : EmptyStatement ExpressionStatement ContinueStatement BreakStatement ReturnStatement ThrowStatement DebuggerStatement
  1. 返回一个新的空 List
Block : { }
  1. 返回一个新的空 List
StatementList : StatementList StatementListItem
  1. declarations1StatementListVarScopedDeclarations
  2. declarations2StatementListItemVarScopedDeclarations
  3. 返回 declarations1declarations2列表连接
StatementListItem : Declaration
  1. 返回一个新的空 List
VariableDeclarationList : VariableDeclaration
  1. 返回 « VariableDeclaration »。
VariableDeclarationList : VariableDeclarationList , VariableDeclaration
  1. declarations1VariableDeclarationListVarScopedDeclarations
  2. 返回 declarations1 与 « VariableDeclaration » 的列表连接
IfStatement : if ( Expression ) Statement else Statement
  1. declarations1 为第一个 StatementVarScopedDeclarations
  2. declarations2 为第二个 StatementVarScopedDeclarations
  3. 返回 declarations1declarations2列表连接
IfStatement : if ( Expression ) Statement
  1. 返回 StatementVarScopedDeclarations
DoWhileStatement : do Statement while ( Expression ) ;
  1. 返回 StatementVarScopedDeclarations
WhileStatement : while ( Expression ) Statement
  1. 返回 StatementVarScopedDeclarations
ForStatement : for ( Expressionopt ; Expressionopt ; Expressionopt ) Statement
  1. 返回 StatementVarScopedDeclarations
ForStatement : for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement
  1. declarations1VariableDeclarationListVarScopedDeclarations
  2. declarations2StatementVarScopedDeclarations
  3. 返回 declarations1declarations2列表连接
ForStatement : for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
  1. 返回 StatementVarScopedDeclarations
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. 返回 StatementVarScopedDeclarations
ForInOfStatement : for ( var ForBinding in Expression ) Statement for ( var ForBinding of AssignmentExpression ) Statement for await ( var ForBinding of AssignmentExpression ) Statement
  1. declarations1 为 « ForBinding »。
  2. declarations2StatementVarScopedDeclarations
  3. 返回 declarations1declarations2列表连接
Note

本节由附录 B.3.5 扩展。

WithStatement : with ( Expression ) Statement
  1. 返回 StatementVarScopedDeclarations
SwitchStatement : switch ( Expression ) CaseBlock
  1. 返回 CaseBlockVarScopedDeclarations
CaseBlock : { }
  1. 返回一个新的空 List
CaseBlock : { CaseClausesopt DefaultClause CaseClausesopt }
  1. 如果第一个 CaseClauses 存在,令 declarations1 为第一个 CaseClausesVarScopedDeclarations
  2. 否则,令 declarations1 为一个新的空 List
  3. declarations2DefaultClauseVarScopedDeclarations
  4. 如果第二个 CaseClauses 存在,令 declarations3 为第二个 CaseClausesVarScopedDeclarations
  5. 否则,令 declarations3 为一个新的空 List
  6. 返回 declarations1declarations2declarations3列表连接
CaseClauses : CaseClauses CaseClause
  1. declarations1CaseClausesVarScopedDeclarations
  2. declarations2CaseClauseVarScopedDeclarations
  3. 返回 declarations1declarations2列表连接
CaseClause : case Expression : StatementListopt
  1. 如果 StatementList 存在,返回 StatementListVarScopedDeclarations
  2. 返回一个新的空 List
DefaultClause : default : StatementListopt
  1. 如果 StatementList 存在,返回 StatementListVarScopedDeclarations
  2. 返回一个新的空 List
LabelledStatement : LabelIdentifier : LabelledItem
  1. 返回 LabelledItemVarScopedDeclarations
LabelledItem : FunctionDeclaration
  1. 返回一个新的空 List
TryStatement : try Block Catch
  1. declarations1BlockVarScopedDeclarations
  2. declarations2CatchVarScopedDeclarations
  3. 返回 declarations1declarations2列表连接
TryStatement : try Block Finally
  1. declarations1BlockVarScopedDeclarations
  2. declarations2FinallyVarScopedDeclarations
  3. 返回 declarations1declarations2列表连接
TryStatement : try Block Catch Finally
  1. declarations1BlockVarScopedDeclarations
  2. declarations2CatchVarScopedDeclarations
  3. declarations3FinallyVarScopedDeclarations
  4. 返回 declarations1declarations2declarations3列表连接
Catch : catch ( CatchParameter ) Block
  1. 返回 BlockVarScopedDeclarations
FunctionStatementList : [empty]
  1. 返回一个新的空 List
FunctionStatementList : StatementList
  1. 返回 StatementListTopLevelVarScopedDeclarations
ClassStaticBlockStatementList : [empty]
  1. 返回一个新的空 List
ClassStaticBlockStatementList : StatementList
  1. 返回 StatementListTopLevelVarScopedDeclarations
ConciseBody : ExpressionBody
  1. 返回一个新的空 List
AsyncConciseBody : ExpressionBody
  1. 返回一个新的空 List
Script : [empty]
  1. 返回一个新的空 List
ScriptBody : StatementList
  1. 返回 StatementListTopLevelVarScopedDeclarations
Module : [empty]
  1. 返回一个新的空 List
ModuleItemList : ModuleItemList ModuleItem
  1. declarations1ModuleItemListVarScopedDeclarations
  2. declarations2ModuleItemVarScopedDeclarations
  3. 返回 declarations1declarations2列表连接
ModuleItem : ImportDeclaration
  1. 返回一个新的空 List
ModuleItem : ExportDeclaration
  1. 如果 ExportDeclarationexport VariableStatement,返回 VariableStatementVarScopedDeclarations
  2. 返回一个新的空 List

8.2.8 Static Semantics: TopLevelLexicallyDeclaredNames

The syntax-directed operation TopLevelLexicallyDeclaredNames takes no arguments and returns 一个 String 的 List. It is defined piecewise over the following productions:

StatementList : StatementList StatementListItem
  1. names1StatementListTopLevelLexicallyDeclaredNames
  2. names2StatementListItemTopLevelLexicallyDeclaredNames
  3. 返回 names1names2列表连接
StatementListItem : Statement
  1. 返回一个新的空 List
StatementListItem : Declaration
  1. 如果 Declaration Declaration : HoistableDeclaration ,那么
    1. 返回一个新的空 List
  2. 返回 DeclarationBoundNames
Note

在函数或脚本的顶层,函数声明被当作 var 声明处理,而不是词法声明。

8.2.9 Static Semantics: TopLevelLexicallyScopedDeclarations

The syntax-directed operation TopLevelLexicallyScopedDeclarations takes no arguments and returns 一个 Parse Node 的 List. It is defined piecewise over the following productions:

StatementList : StatementList StatementListItem
  1. declarations1StatementListTopLevelLexicallyScopedDeclarations
  2. declarations2StatementListItemTopLevelLexicallyScopedDeclarations
  3. 返回 declarations1declarations2列表连接
StatementListItem : Statement
  1. 返回一个新的空 List
StatementListItem : Declaration
  1. 如果 Declaration Declaration : HoistableDeclaration ,那么
    1. 返回一个新的空 List
  2. 返回 « Declaration »。

8.2.10 Static Semantics: TopLevelVarDeclaredNames

The syntax-directed operation TopLevelVarDeclaredNames takes no arguments and returns 一个 String 的 List. It is defined piecewise over the following productions:

StatementList : StatementList StatementListItem
  1. names1StatementListTopLevelVarDeclaredNames
  2. names2StatementListItemTopLevelVarDeclaredNames
  3. 返回 names1names2列表连接
StatementListItem : Declaration
  1. 如果 Declaration Declaration : HoistableDeclaration ,那么
    1. 返回 HoistableDeclarationBoundNames
  2. 返回一个新的空 List
StatementListItem : Statement
  1. 如果 Statement Statement : LabelledStatement ,返回 StatementTopLevelVarDeclaredNames
  2. 返回 StatementVarDeclaredNames
Note

在函数或脚本的顶层,内部函数声明被当作 var 声明处理。

LabelledStatement : LabelIdentifier : LabelledItem
  1. 返回 LabelledItemTopLevelVarDeclaredNames
LabelledItem : Statement
  1. 如果 Statement Statement : LabelledStatement ,返回 StatementTopLevelVarDeclaredNames
  2. 返回 StatementVarDeclaredNames
LabelledItem : FunctionDeclaration
  1. 返回 FunctionDeclarationBoundNames

8.2.11 Static Semantics: TopLevelVarScopedDeclarations

The syntax-directed operation TopLevelVarScopedDeclarations takes no arguments and returns 一个 Parse Node 的 List. It is defined piecewise over the following productions:

StatementList : StatementList StatementListItem
  1. declarations1StatementListTopLevelVarScopedDeclarations
  2. declarations2StatementListItemTopLevelVarScopedDeclarations
  3. 返回 declarations1declarations2列表连接
StatementListItem : Statement
  1. 如果 Statement Statement : LabelledStatement ,返回 StatementTopLevelVarScopedDeclarations
  2. 返回 StatementVarScopedDeclarations
StatementListItem : Declaration
  1. 如果 Declaration Declaration : HoistableDeclaration ,那么
    1. declarationHoistableDeclarationDeclarationPart
    2. 返回 « declaration »。
  2. 返回一个新的空 List
LabelledStatement : LabelIdentifier : LabelledItem
  1. 返回 LabelledItemTopLevelVarScopedDeclarations
LabelledItem : Statement
  1. 如果 Statement Statement : LabelledStatement ,返回 StatementTopLevelVarScopedDeclarations
  2. 返回 StatementVarScopedDeclarations
LabelledItem : FunctionDeclaration
  1. 返回 « FunctionDeclaration »。

8.3 标签

8.3.1 Static Semantics: ContainsDuplicateLabels

The syntax-directed operation ContainsDuplicateLabels takes argument labelSet (一个 String 的 List,) and returns 一个 Boolean. It is defined piecewise over the following productions:

Statement : VariableStatement EmptyStatement ExpressionStatement ContinueStatement BreakStatement ReturnStatement ThrowStatement DebuggerStatement Block : { } StatementListItem : Declaration
  1. 返回 false
StatementList : StatementList StatementListItem
  1. hasDuplicates 为以 labelSet 作为参数调用 StatementListContainsDuplicateLabels 的结果。
  2. 如果 hasDuplicatestrue,返回 true
  3. 返回以 labelSet 作为参数调用 StatementListItemContainsDuplicateLabels 的结果。
IfStatement : if ( Expression ) Statement else Statement
  1. hasDuplicate 为以 labelSet 作为参数调用第一个 StatementContainsDuplicateLabels 的结果。
  2. 如果 hasDuplicatetrue,返回 true
  3. 返回以 labelSet 作为参数调用第二个 StatementContainsDuplicateLabels 的结果。
IfStatement : if ( Expression ) Statement
  1. 返回以 labelSet 作为参数调用 StatementContainsDuplicateLabels 的结果。
DoWhileStatement : do Statement while ( Expression ) ;
  1. 返回以 labelSet 作为参数调用 StatementContainsDuplicateLabels 的结果。
WhileStatement : while ( Expression ) Statement
  1. 返回以 labelSet 作为参数调用 StatementContainsDuplicateLabels 的结果。
ForStatement : for ( Expressionopt ; Expressionopt ; Expressionopt ) Statement for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
  1. 返回以 labelSet 作为参数调用 StatementContainsDuplicateLabels 的结果。
ForInOfStatement : for ( LeftHandSideExpression in Expression ) Statement for ( var ForBinding in Expression ) Statement for ( ForDeclaration in Expression ) Statement for ( LeftHandSideExpression of AssignmentExpression ) Statement for ( var ForBinding of AssignmentExpression ) Statement for ( ForDeclaration of AssignmentExpression ) Statement for await ( LeftHandSideExpression of AssignmentExpression ) Statement for await ( var ForBinding of AssignmentExpression ) Statement for await ( ForDeclaration of AssignmentExpression ) Statement
  1. 返回以 labelSet 作为参数调用 StatementContainsDuplicateLabels 的结果。
Note

本节由附录 B.3.5 扩展。

WithStatement : with ( Expression ) Statement
  1. 返回以 labelSet 作为参数调用 StatementContainsDuplicateLabels 的结果。
SwitchStatement : switch ( Expression ) CaseBlock
  1. 返回以 labelSet 作为参数调用 CaseBlockContainsDuplicateLabels 的结果。
CaseBlock : { }
  1. 返回 false
CaseBlock : { CaseClausesopt DefaultClause CaseClausesopt }
  1. 如果第一个 CaseClauses 存在,那么
    1. 如果以 labelSet 作为参数调用第一个 CaseClausesContainsDuplicateLabels 的结果是 true,返回 true
  2. 如果以 labelSet 作为参数调用 DefaultClauseContainsDuplicateLabels 的结果是 true,返回 true
  3. 如果第二个 CaseClauses 不存在,返回 false
  4. 返回以 labelSet 作为参数调用第二个 CaseClausesContainsDuplicateLabels 的结果。
CaseClauses : CaseClauses CaseClause
  1. hasDuplicates 为以 labelSet 作为参数调用 CaseClausesContainsDuplicateLabels 的结果。
  2. 如果 hasDuplicatestrue,返回 true
  3. 返回以 labelSet 作为参数调用 CaseClauseContainsDuplicateLabels 的结果。
CaseClause : case Expression : StatementListopt
  1. 如果 StatementList 存在,返回以 labelSet 作为参数调用 StatementListContainsDuplicateLabels 的结果。
  2. 返回 false
DefaultClause : default : StatementListopt
  1. 如果 StatementList 存在,返回以 labelSet 作为参数调用 StatementListContainsDuplicateLabels 的结果。
  2. 返回 false
LabelledStatement : LabelIdentifier : LabelledItem
  1. labelLabelIdentifierStringValue
  2. 如果 labelSet 包含 label,返回 true
  3. newLabelSetlabelSet 与 « label » 的列表连接
  4. 返回以 newLabelSet 作为参数调用 LabelledItemContainsDuplicateLabels 的结果。
LabelledItem : FunctionDeclaration
  1. 返回 false
TryStatement : try Block Catch
  1. hasDuplicates 为以 labelSet 作为参数调用 BlockContainsDuplicateLabels 的结果。
  2. 如果 hasDuplicatestrue,返回 true
  3. 返回以 labelSet 作为参数调用 CatchContainsDuplicateLabels 的结果。
TryStatement : try Block Finally
  1. hasDuplicates 为以 labelSet 作为参数调用 BlockContainsDuplicateLabels 的结果。
  2. 如果 hasDuplicatestrue,返回 true
  3. 返回以 labelSet 作为参数调用 FinallyContainsDuplicateLabels 的结果。
TryStatement : try Block Catch Finally
  1. 如果以 labelSet 作为参数调用 BlockContainsDuplicateLabels 的结果是 true,返回 true
  2. 如果以 labelSet 作为参数调用 CatchContainsDuplicateLabels 的结果是 true,返回 true
  3. 返回以 labelSet 作为参数调用 FinallyContainsDuplicateLabels 的结果。
Catch : catch ( CatchParameter ) Block
  1. 返回以 labelSet 作为参数调用 BlockContainsDuplicateLabels 的结果。
FunctionStatementList : [empty]
  1. 返回 false
ClassStaticBlockStatementList : [empty]
  1. 返回 false
ModuleItemList : ModuleItemList ModuleItem
  1. hasDuplicates 为以 labelSet 作为参数调用 ModuleItemListContainsDuplicateLabels 的结果。
  2. 如果 hasDuplicatestrue,返回 true
  3. 返回以 labelSet 作为参数调用 ModuleItemContainsDuplicateLabels 的结果。
ModuleItem : ImportDeclaration ExportDeclaration
  1. 返回 false

8.3.2 Static Semantics: ContainsUndefinedBreakTarget

The syntax-directed operation ContainsUndefinedBreakTarget takes argument labelSet (一个 String 的 List,) and returns 一个 Boolean. It is defined piecewise over the following productions:

Statement : VariableStatement EmptyStatement ExpressionStatement ContinueStatement ReturnStatement ThrowStatement DebuggerStatement Block : { } StatementListItem : Declaration
  1. 返回 false
StatementList : StatementList StatementListItem
  1. hasUndefinedLabels 为以 labelSet 作为参数调用 StatementListContainsUndefinedBreakTarget 的结果。
  2. 如果 hasUndefinedLabelstrue,返回 true
  3. 返回以 labelSet 作为参数调用 StatementListItemContainsUndefinedBreakTarget 的结果。
IfStatement : if ( Expression ) Statement else Statement
  1. hasUndefinedLabels 为以 labelSet 作为参数调用第一个 StatementContainsUndefinedBreakTarget 的结果。
  2. 如果 hasUndefinedLabelstrue,返回 true
  3. 返回以 labelSet 作为参数调用第二个 StatementContainsUndefinedBreakTarget 的结果。
IfStatement : if ( Expression ) Statement
  1. 返回以 labelSet 作为参数调用 StatementContainsUndefinedBreakTarget 的结果。
DoWhileStatement : do Statement while ( Expression ) ;
  1. 返回以 labelSet 作为参数调用 StatementContainsUndefinedBreakTarget 的结果。
WhileStatement : while ( Expression ) Statement
  1. 返回以 labelSet 作为参数调用 StatementContainsUndefinedBreakTarget 的结果。
ForStatement : for ( Expressionopt ; Expressionopt ; Expressionopt ) Statement for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
  1. 返回以 labelSet 作为参数调用 StatementContainsUndefinedBreakTarget 的结果。
ForInOfStatement : for ( LeftHandSideExpression in Expression ) Statement for ( var ForBinding in Expression ) Statement for ( ForDeclaration in Expression ) Statement for ( LeftHandSideExpression of AssignmentExpression ) Statement for ( var ForBinding of AssignmentExpression ) Statement for ( ForDeclaration of AssignmentExpression ) Statement for await ( LeftHandSideExpression of AssignmentExpression ) Statement for await ( var ForBinding of AssignmentExpression ) Statement for await ( ForDeclaration of AssignmentExpression ) Statement
  1. 返回以 labelSet 作为参数调用 StatementContainsUndefinedBreakTarget 的结果。
Note

本节由附录 B.3.5 扩展。

BreakStatement : break ;
  1. 返回 false
BreakStatement : break LabelIdentifier ;
  1. 如果 labelSet 包含 LabelIdentifierStringValue,返回 false
  2. 返回 true
WithStatement : with ( Expression ) Statement
  1. 返回以 labelSet 作为参数调用 StatementContainsUndefinedBreakTarget 的结果。
SwitchStatement : switch ( Expression ) CaseBlock
  1. 返回以 labelSet 作为参数调用 CaseBlockContainsUndefinedBreakTarget 的结果。
CaseBlock : { }
  1. 返回 false
CaseBlock : { CaseClausesopt DefaultClause CaseClausesopt }
  1. 如果第一个 CaseClauses 存在,那么
    1. 如果以 labelSet 作为参数调用第一个 CaseClausesContainsUndefinedBreakTarget 的结果是 true,返回 true
  2. 如果以 labelSet 作为参数调用 DefaultClauseContainsUndefinedBreakTarget 的结果是 true,返回 true
  3. 如果第二个 CaseClauses 不存在,返回 false
  4. 返回以 labelSet 作为参数调用第二个 CaseClausesContainsUndefinedBreakTarget 的结果。
CaseClauses : CaseClauses CaseClause
  1. hasUndefinedLabels 为以 labelSet 作为参数调用 CaseClausesContainsUndefinedBreakTarget 的结果。
  2. 如果 hasUndefinedLabelstrue,返回 true
  3. 返回以 labelSet 作为参数调用 CaseClauseContainsUndefinedBreakTarget 的结果。
CaseClause : case Expression : StatementListopt
  1. 如果 StatementList 存在,返回以 labelSet 作为参数调用 StatementListContainsUndefinedBreakTarget 的结果。
  2. 返回 false
DefaultClause : default : StatementListopt
  1. 如果 StatementList 存在,返回以 labelSet 作为参数调用 StatementListContainsUndefinedBreakTarget 的结果。
  2. 返回 false
LabelledStatement : LabelIdentifier : LabelledItem
  1. labelLabelIdentifierStringValue
  2. newLabelSetlabelSet 与 « label » 的列表连接
  3. 返回以 newLabelSet 作为参数调用 LabelledItemContainsUndefinedBreakTarget 的结果。
LabelledItem : FunctionDeclaration
  1. 返回 false
TryStatement : try Block Catch
  1. hasUndefinedLabels 为以 labelSet 作为参数调用 BlockContainsUndefinedBreakTarget 的结果。
  2. 如果 hasUndefinedLabelstrue,返回 true
  3. 返回以 labelSet 作为参数调用 CatchContainsUndefinedBreakTarget 的结果。
TryStatement : try Block Finally
  1. hasUndefinedLabels 为以 labelSet 作为参数调用 BlockContainsUndefinedBreakTarget 的结果。
  2. 如果 hasUndefinedLabelstrue,返回 true
  3. 返回以 labelSet 作为参数调用 FinallyContainsUndefinedBreakTarget 的结果。
TryStatement : try Block Catch Finally
  1. 如果以 labelSet 作为参数调用 BlockContainsUndefinedBreakTarget 的结果是 true,返回 true
  2. 如果以 labelSet 作为参数调用 CatchContainsUndefinedBreakTarget 的结果是 true,返回 true
  3. 返回以 labelSet 作为参数调用 FinallyContainsUndefinedBreakTarget 的结果。
Catch : catch ( CatchParameter ) Block
  1. 返回以 labelSet 作为参数调用 BlockContainsUndefinedBreakTarget 的结果。
FunctionStatementList : [empty]
  1. 返回 false
ClassStaticBlockStatementList : [empty]
  1. 返回 false
ModuleItemList : ModuleItemList ModuleItem
  1. hasUndefinedLabels 为以 labelSet 作为参数调用 ModuleItemListContainsUndefinedBreakTarget 的结果。
  2. 如果 hasUndefinedLabelstrue,返回 true
  3. 返回以 labelSet 作为参数调用 ModuleItemContainsUndefinedBreakTarget 的结果。
ModuleItem : ImportDeclaration ExportDeclaration
  1. 返回 false

8.3.3 Static Semantics: ContainsUndefinedContinueTarget

The syntax-directed operation ContainsUndefinedContinueTarget takes arguments iterationSet (一个 String 的 List,) and labelSet (一个 String 的 List,) and returns 一个 Boolean. It is defined piecewise over the following productions:

Statement : VariableStatement EmptyStatement ExpressionStatement BreakStatement ReturnStatement ThrowStatement DebuggerStatement Block : { } StatementListItem : Declaration
  1. 返回 false
Statement : BlockStatement
  1. 返回以 iterationSet 和 « » 作为参数调用 BlockStatementContainsUndefinedContinueTarget 的结果。
BreakableStatement : IterationStatement
  1. newIterationSetiterationSetlabelSet列表连接
  2. 返回以 newIterationSet 和 « » 作为参数调用 IterationStatementContainsUndefinedContinueTarget 的结果。
StatementList : StatementList StatementListItem
  1. hasUndefinedLabels 为以 iterationSet 和 « » 作为参数调用 StatementListContainsUndefinedContinueTarget 的结果。
  2. 如果 hasUndefinedLabelstrue,返回 true
  3. 返回以 iterationSet 和 « » 作为参数调用 StatementListItemContainsUndefinedContinueTarget 的结果。
IfStatement : if ( Expression ) Statement else Statement
  1. hasUndefinedLabels 为以 iterationSet 和 « » 作为参数调用第一个 StatementContainsUndefinedContinueTarget 的结果。
  2. 如果 hasUndefinedLabelstrue,返回 true
  3. 返回以 iterationSet 和 « » 作为参数调用第二个 StatementContainsUndefinedContinueTarget 的结果。
IfStatement : if ( Expression ) Statement
  1. 返回以 iterationSet 和 « » 作为参数调用 StatementContainsUndefinedContinueTarget 的结果。
DoWhileStatement : do Statement while ( Expression ) ;
  1. 返回以 iterationSet 和 « » 作为参数调用 StatementContainsUndefinedContinueTarget 的结果。
WhileStatement : while ( Expression ) Statement
  1. 返回以 iterationSet 和 « » 作为参数调用 StatementContainsUndefinedContinueTarget 的结果。
ForStatement : for ( Expressionopt ; Expressionopt ; Expressionopt ) Statement for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
  1. 返回以 iterationSet 和 « » 作为参数调用 StatementContainsUndefinedContinueTarget 的结果。
ForInOfStatement : for ( LeftHandSideExpression in Expression ) Statement for ( var ForBinding in Expression ) Statement for ( ForDeclaration in Expression ) Statement for ( LeftHandSideExpression of AssignmentExpression ) Statement for ( var ForBinding of AssignmentExpression ) Statement for ( ForDeclaration of AssignmentExpression ) Statement for await ( LeftHandSideExpression of AssignmentExpression ) Statement for await ( var ForBinding of AssignmentExpression ) Statement for await ( ForDeclaration of AssignmentExpression ) Statement
  1. 返回以 iterationSet 和 « » 作为参数调用 StatementContainsUndefinedContinueTarget 的结果。
Note

本节由附录 B.3.5 扩展。

ContinueStatement : continue ;
  1. 返回 false
ContinueStatement : continue LabelIdentifier ;
  1. 如果 iterationSet 包含 LabelIdentifierStringValue,返回 false
  2. 返回 true
WithStatement : with ( Expression ) Statement
  1. 返回以 iterationSet 和 « » 作为参数调用 StatementContainsUndefinedContinueTarget 的结果。
SwitchStatement : switch ( Expression ) CaseBlock
  1. 返回以 iterationSet 和 « » 作为参数调用 CaseBlockContainsUndefinedContinueTarget 的结果。
CaseBlock : { }
  1. 返回 false
CaseBlock : { CaseClausesopt DefaultClause CaseClausesopt }
  1. 如果第一个 CaseClauses 存在,那么
    1. 如果以 iterationSet 和 « » 作为参数调用第一个 CaseClausesContainsUndefinedContinueTarget 的结果是 true,返回 true
  2. 如果以 iterationSet 和 « » 作为参数调用 DefaultClauseContainsUndefinedContinueTarget 的结果是 true,返回 true
  3. 如果第二个 CaseClauses 不存在,返回 false
  4. 返回以 iterationSet 和 « » 作为参数调用第二个 CaseClausesContainsUndefinedContinueTarget 的结果。
CaseClauses : CaseClauses CaseClause
  1. hasUndefinedLabels 为以 iterationSet 和 « » 作为参数调用 CaseClausesContainsUndefinedContinueTarget 的结果。
  2. 如果 hasUndefinedLabelstrue,返回 true
  3. 返回以 iterationSet 和 « » 作为参数调用 CaseClauseContainsUndefinedContinueTarget 的结果。
CaseClause : case Expression : StatementListopt
  1. 如果 StatementList 存在,返回以 iterationSet 和 « » 作为参数调用 StatementListContainsUndefinedContinueTarget 的结果。
  2. 返回 false
DefaultClause : default : StatementListopt
  1. 如果 StatementList 存在,返回以 iterationSet 和 « » 作为参数调用 StatementListContainsUndefinedContinueTarget 的结果。
  2. 返回 false
LabelledStatement : LabelIdentifier : LabelledItem
  1. labelLabelIdentifierStringValue
  2. newLabelSetlabelSet 与 « label » 的列表连接
  3. 返回以 iterationSetnewLabelSet 作为参数调用 LabelledItemContainsUndefinedContinueTarget 的结果。
LabelledItem : FunctionDeclaration
  1. 返回 false
TryStatement : try Block Catch
  1. hasUndefinedLabels 为以 iterationSet 和 « » 作为参数调用 BlockContainsUndefinedContinueTarget 的结果。
  2. 如果 hasUndefinedLabelstrue,返回 true
  3. 返回以 iterationSet 和 « » 作为参数调用 CatchContainsUndefinedContinueTarget 的结果。
TryStatement : try Block Finally
  1. hasUndefinedLabels 为以 iterationSet 和 « » 作为参数调用 BlockContainsUndefinedContinueTarget 的结果。
  2. 如果 hasUndefinedLabelstrue,返回 true
  3. 返回以 iterationSet 和 « » 作为参数调用 FinallyContainsUndefinedContinueTarget 的结果。
TryStatement : try Block Catch Finally
  1. 如果以 iterationSet 和 « » 作为参数调用 BlockContainsUndefinedContinueTarget 的结果是 true,返回 true
  2. 如果以 iterationSet 和 « » 作为参数调用 CatchContainsUndefinedContinueTarget 的结果是 true,返回 true
  3. 返回以 iterationSet 和 « » 作为参数调用 FinallyContainsUndefinedContinueTarget 的结果。
Catch : catch ( CatchParameter ) Block
  1. 返回以 iterationSet 和 « » 作为参数调用 BlockContainsUndefinedContinueTarget 的结果。
FunctionStatementList : [empty]
  1. 返回 false
ClassStaticBlockStatementList : [empty]
  1. 返回 false
ModuleItemList : ModuleItemList ModuleItem
  1. hasUndefinedLabels 为以 iterationSet 和 « » 作为参数调用 ModuleItemListContainsUndefinedContinueTarget 的结果。
  2. 如果 hasUndefinedLabelstrue,返回 true
  3. 返回以 iterationSet 和 « » 作为参数调用 ModuleItemContainsUndefinedContinueTarget 的结果。
ModuleItem : ImportDeclaration ExportDeclaration
  1. 返回 false

8.4 函数名推断

8.4.1 Static Semantics: HasName

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

PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList
  1. expr 为被 CoverParenthesizedExpressionAndArrowParameterList 覆盖ParenthesizedExpression
  2. 如果 exprIsFunctionDefinitionfalse,返回 false
  3. 返回 exprHasName
FunctionExpression : function ( FormalParameters ) { FunctionBody } GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } AsyncGeneratorExpression : async function * ( FormalParameters ) { AsyncGeneratorBody } AsyncFunctionExpression : async function ( FormalParameters ) { AsyncFunctionBody } ArrowFunction : ArrowParameters => ConciseBody AsyncArrowFunction : async AsyncArrowBindingIdentifier => AsyncConciseBody CoverCallExpressionAndAsyncArrowHead => AsyncConciseBody ClassExpression : class ClassTail
  1. 返回 false
FunctionExpression : function BindingIdentifier ( FormalParameters ) { FunctionBody } GeneratorExpression : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } AsyncGeneratorExpression : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } AsyncFunctionExpression : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } ClassExpression : class BindingIdentifier ClassTail
  1. 返回 true

8.4.2 Static Semantics: IsFunctionDefinition

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

PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList
  1. expr 为被 CoverParenthesizedExpressionAndArrowParameterList 覆盖ParenthesizedExpression
  2. 返回 exprIsFunctionDefinition
PrimaryExpression : this IdentifierReference Literal ArrayLiteral ObjectLiteral RegularExpressionLiteral TemplateLiteral MemberExpression : MemberExpression [ Expression ] MemberExpression . IdentifierName MemberExpression TemplateLiteral SuperProperty MetaProperty new MemberExpression Arguments MemberExpression . PrivateIdentifier NewExpression : new NewExpression LeftHandSideExpression : CallExpression OptionalExpression UpdateExpression : LeftHandSideExpression ++ LeftHandSideExpression -- ++ UnaryExpression -- UnaryExpression UnaryExpression : delete UnaryExpression void UnaryExpression typeof UnaryExpression + UnaryExpression - UnaryExpression ~ UnaryExpression ! UnaryExpression AwaitExpression ExponentiationExpression : UpdateExpression ** ExponentiationExpression MultiplicativeExpression : MultiplicativeExpression MultiplicativeOperator ExponentiationExpression AdditiveExpression : AdditiveExpression + MultiplicativeExpression AdditiveExpression - MultiplicativeExpression ShiftExpression : ShiftExpression << AdditiveExpression ShiftExpression >> AdditiveExpression ShiftExpression >>> AdditiveExpression RelationalExpression : RelationalExpression < ShiftExpression RelationalExpression > ShiftExpression RelationalExpression <= ShiftExpression RelationalExpression >= ShiftExpression RelationalExpression instanceof ShiftExpression RelationalExpression in ShiftExpression PrivateIdentifier in ShiftExpression EqualityExpression : EqualityExpression == RelationalExpression EqualityExpression != RelationalExpression EqualityExpression === RelationalExpression EqualityExpression !== RelationalExpression BitwiseANDExpression : BitwiseANDExpression & EqualityExpression BitwiseXORExpression : BitwiseXORExpression ^ BitwiseANDExpression BitwiseORExpression : BitwiseORExpression | BitwiseXORExpression LogicalANDExpression : LogicalANDExpression && BitwiseORExpression LogicalORExpression : LogicalORExpression || LogicalANDExpression CoalesceExpression : CoalesceExpressionHead ?? BitwiseORExpression ConditionalExpression : ShortCircuitExpression ? AssignmentExpression : AssignmentExpression AssignmentExpression : YieldExpression LeftHandSideExpression = AssignmentExpression LeftHandSideExpression AssignmentOperator AssignmentExpression LeftHandSideExpression &&= AssignmentExpression LeftHandSideExpression ||= AssignmentExpression LeftHandSideExpression ??= AssignmentExpression Expression : Expression , AssignmentExpression
  1. 返回 false
AssignmentExpression : ArrowFunction AsyncArrowFunction FunctionExpression : function BindingIdentifieropt ( FormalParameters ) { FunctionBody } GeneratorExpression : function * BindingIdentifieropt ( FormalParameters ) { GeneratorBody } AsyncGeneratorExpression : async function * BindingIdentifieropt ( FormalParameters ) { AsyncGeneratorBody } AsyncFunctionExpression : async function BindingIdentifieropt ( FormalParameters ) { AsyncFunctionBody } ClassExpression : class BindingIdentifieropt ClassTail
  1. 返回 true

8.4.3 Static Semantics: IsAnonymousFunctionDefinition ( expr )

The abstract operation IsAnonymousFunctionDefinition takes argument expr (一个 AssignmentExpression Parse Node、一个 Initializer Parse Node 或一个 Expression Parse Node,) and returns 一个 Boolean. 它判定其参数是否为一个不绑定名称的函数定义。 It performs the following steps when called:

  1. 如果 exprIsFunctionDefinitionfalse,返回 false
  2. hasNameexprHasName
  3. 如果 hasNametrue,返回 false
  4. 返回 true

8.4.4 Static Semantics: IsIdentifierRef

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

PrimaryExpression : IdentifierReference
  1. 返回 true
PrimaryExpression : this Literal ArrayLiteral ObjectLiteral FunctionExpression ClassExpression GeneratorExpression AsyncFunctionExpression AsyncGeneratorExpression RegularExpressionLiteral TemplateLiteral CoverParenthesizedExpressionAndArrowParameterList MemberExpression : MemberExpression [ Expression ] MemberExpression . IdentifierName MemberExpression TemplateLiteral SuperProperty MetaProperty new MemberExpression Arguments MemberExpression . PrivateIdentifier NewExpression : new NewExpression LeftHandSideExpression : CallExpression OptionalExpression
  1. 返回 false

8.4.5 Runtime Semantics: NamedEvaluation

The syntax-directed operation NamedEvaluation takes argument name (一个属性键或一个 Private Name,) and returns 要么是包含函数对象正常完成,要么是突兀完成. It is defined piecewise over the following productions:

PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList
  1. expr 为被 CoverParenthesizedExpressionAndArrowParameterList 覆盖ParenthesizedExpression
  2. 返回 ? 以 name 作为参数对 expr 进行 NamedEvaluation 的结果。
ParenthesizedExpression : ( Expression )
  1. 断言:IsAnonymousFunctionDefinition(Expression) 是 true
  2. 返回 ? 以 name 作为参数对 Expression 进行 NamedEvaluation 的结果。
FunctionExpression : function ( FormalParameters ) { FunctionBody }
  1. 返回以 name 作为参数对 FunctionExpression 进行 InstantiateOrdinaryFunctionExpression 的结果。
GeneratorExpression : function * ( FormalParameters ) { GeneratorBody }
  1. 返回以 name 作为参数对 GeneratorExpression 进行 InstantiateGeneratorFunctionExpression 的结果。
AsyncGeneratorExpression : async function * ( FormalParameters ) { AsyncGeneratorBody }
  1. 返回以 name 作为参数对 AsyncGeneratorExpression 进行 InstantiateAsyncGeneratorFunctionExpression 的结果。
AsyncFunctionExpression : async function ( FormalParameters ) { AsyncFunctionBody }
  1. 返回以 name 作为参数对 AsyncFunctionExpression 进行 InstantiateAsyncFunctionExpression 的结果。
ArrowFunction : ArrowParameters => ConciseBody
  1. 返回以 name 作为参数对 ArrowFunction 进行 InstantiateArrowFunctionExpression 的结果。
AsyncArrowFunction : async AsyncArrowBindingIdentifier => AsyncConciseBody CoverCallExpressionAndAsyncArrowHead => AsyncConciseBody
  1. 返回以 name 作为参数对 AsyncArrowFunction 进行 InstantiateAsyncArrowFunctionExpression 的结果。
ClassExpression : class ClassTail
  1. sourceTextClassExpression匹配的源文本
  2. 返回 ? 以 undefinednamesourceText 作为参数对 ClassTail 进行 ClassDefinitionEvaluation 的结果。

8.5 Contains

8.5.1 Static Semantics: Contains

The syntax-directed operation Contains takes argument symbol (一个文法符号,) and returns 一个 Boolean.

本规范中未在下方列出的每个文法产生式备选项,都隐含具有如下 Contains 默认定义:

  1. 对该 Parse Node 的每个子节点 child,执行
    1. 如果 childsymbol 的一个实例,返回 true
    2. 如果 child 是一个非终结符的实例,那么
      1. containedchild Contains symbol 的结果。
      2. 如果 containedtrue,返回 true
  2. 返回 false
FunctionDeclaration : function BindingIdentifier ( FormalParameters ) { FunctionBody } function ( FormalParameters ) { FunctionBody } FunctionExpression : function BindingIdentifieropt ( FormalParameters ) { FunctionBody } GeneratorDeclaration : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } function * ( FormalParameters ) { GeneratorBody } GeneratorExpression : function * BindingIdentifieropt ( FormalParameters ) { GeneratorBody } AsyncGeneratorDeclaration : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } async function * ( FormalParameters ) { AsyncGeneratorBody } AsyncGeneratorExpression : async function * BindingIdentifieropt ( FormalParameters ) { AsyncGeneratorBody } AsyncFunctionDeclaration : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } async function ( FormalParameters ) { AsyncFunctionBody } AsyncFunctionExpression : async function BindingIdentifieropt ( FormalParameters ) { AsyncFunctionBody }
  1. 返回 false
Note 1

依赖于子结构的静态语义规则通常不会深入查看函数定义内部。

ClassTail : ClassHeritageopt { ClassBody }
  1. 如果 symbolClassBody,返回 true
  2. 如果 symbolClassHeritage,那么
    1. 如果 ClassHeritage 存在,返回 true
    2. 返回 false
  3. 如果 ClassHeritage 存在,那么
    1. 如果 ClassHeritage Contains symboltrue,返回 true
  4. 返回以 symbol 作为参数对 ClassBody 进行 ComputedPropertyContains 的结果。
Note 2

依赖于子结构的静态语义规则通常不会深入查看类体内部,除了 PropertyName 之外。

ClassStaticBlock : static { ClassStaticBlockBody }
  1. 返回 false
Note 3

依赖于子结构的静态语义规则通常不会深入查看 static 初始化块内部。

ArrowFunction : ArrowParameters => ConciseBody
  1. 如果 symbol 不是 NewTargetSuperPropertySuperCallsuperthis 之一,返回 false
  2. 如果 ArrowParameters Contains symboltrue,返回 true
  3. 返回 ConciseBody Contains symbol
ArrowParameters : CoverParenthesizedExpressionAndArrowParameterList
  1. formals 为被 CoverParenthesizedExpressionAndArrowParameterList 覆盖ArrowFormalParameters
  2. 返回 formals Contains symbol
AsyncArrowFunction : async AsyncArrowBindingIdentifier => AsyncConciseBody
  1. 如果 symbol 不是 NewTargetSuperPropertySuperCallsuperthis 之一,返回 false
  2. 返回 AsyncConciseBody Contains symbol
AsyncArrowFunction : CoverCallExpressionAndAsyncArrowHead => AsyncConciseBody
  1. 如果 symbol 不是 NewTargetSuperPropertySuperCallsuperthis 之一,返回 false
  2. head 为被 CoverCallExpressionAndAsyncArrowHead 覆盖AsyncArrowHead
  3. 如果 head Contains symboltrue,返回 true
  4. 返回 AsyncConciseBody Contains symbol
Note 4

Contains 用于检测 ArrowFunctionAsyncArrowFunction 中对 new.targetthissuper 的使用。

PropertyDefinition : MethodDefinition
  1. 如果 symbolMethodDefinition,返回 true
  2. 返回以 symbol 作为参数对 MethodDefinition 进行 ComputedPropertyContains 的结果。
LiteralPropertyName : IdentifierName
  1. 返回 false
MemberExpression : MemberExpression . IdentifierName
  1. 如果 MemberExpression Contains symboltrue,返回 true
  2. 返回 false
SuperProperty : super . IdentifierName
  1. 如果 symbol保留字 ReservedWord super,返回 true
  2. 返回 false
CallExpression : CallExpression . IdentifierName
  1. 如果 CallExpression Contains symboltrue,返回 true
  2. 返回 false
OptionalChain : ?. IdentifierName
  1. 返回 false
OptionalChain : OptionalChain . IdentifierName
  1. 如果 OptionalChain Contains symboltrue,返回 true
  2. 返回 false

8.5.2 Static Semantics: ComputedPropertyContains

The syntax-directed operation ComputedPropertyContains takes argument symbol (一个文法符号,) and returns 一个 Boolean. It is defined piecewise over the following productions:

ClassElementName : PrivateIdentifier PropertyName : LiteralPropertyName
  1. 返回 false
PropertyName : ComputedPropertyName
  1. 返回 ComputedPropertyName Contains symbol 的结果。
MethodDefinition : ClassElementName ( UniqueFormalParameters ) { FunctionBody } get ClassElementName ( ) { FunctionBody } set ClassElementName ( PropertySetParameterList ) { FunctionBody }
  1. 返回以 symbol 作为参数对 ClassElementName 进行 ComputedPropertyContains 的结果。
GeneratorMethod : * ClassElementName ( UniqueFormalParameters ) { GeneratorBody }
  1. 返回以 symbol 作为参数对 ClassElementName 进行 ComputedPropertyContains 的结果。
AsyncGeneratorMethod : async * ClassElementName ( UniqueFormalParameters ) { AsyncGeneratorBody }
  1. 返回以 symbol 作为参数对 ClassElementName 进行 ComputedPropertyContains 的结果。
ClassElementList : ClassElementList ClassElement
  1. inList 为以 symbol 作为参数对 ClassElementList 进行 ComputedPropertyContains 的结果。
  2. 如果 inListtrue,返回 true
  3. 返回以 symbol 作为参数对 ClassElement 进行 ComputedPropertyContains 的结果。
ClassElement : ClassStaticBlock
  1. 返回 false
ClassElement : ;
  1. 返回 false
AsyncMethod : async ClassElementName ( UniqueFormalParameters ) { AsyncFunctionBody }
  1. 返回以 symbol 作为参数对 ClassElementName 进行 ComputedPropertyContains 的结果。
FieldDefinition : ClassElementName Initializeropt
  1. 返回以 symbol 作为参数对 ClassElementName 进行 ComputedPropertyContains 的结果。

8.6 杂项

这些操作会在本规范的多个位置中使用。

8.6.1 Runtime Semantics: InstantiateFunctionObject

The syntax-directed operation InstantiateFunctionObject takes arguments env (一个 Environment Record,) and privateEnv (一个 PrivateEnvironment Recordnull,) and returns 一个 ECMAScript 函数对象. It is defined piecewise over the following productions:

FunctionDeclaration : function BindingIdentifier ( FormalParameters ) { FunctionBody } function ( FormalParameters ) { FunctionBody }
  1. 返回以 envprivateEnv 作为参数对 FunctionDeclaration 进行 InstantiateOrdinaryFunctionObject 的结果。
GeneratorDeclaration : function * BindingIdentifier ( FormalParameters ) { GeneratorBody } function * ( FormalParameters ) { GeneratorBody }
  1. 返回以 envprivateEnv 作为参数对 GeneratorDeclaration 进行 InstantiateGeneratorFunctionObject 的结果。
AsyncGeneratorDeclaration : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody } async function * ( FormalParameters ) { AsyncGeneratorBody }
  1. 返回以 envprivateEnv 作为参数对 AsyncGeneratorDeclaration 进行 InstantiateAsyncGeneratorFunctionObject 的结果。
AsyncFunctionDeclaration : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } async function ( FormalParameters ) { AsyncFunctionBody }
  1. 返回以 envprivateEnv 作为参数对 AsyncFunctionDeclaration 进行 InstantiateAsyncFunctionObject 的结果。

8.6.2 Runtime Semantics: BindingInitialization

The syntax-directed operation BindingInitialization takes arguments value (一个 ECMAScript 语言值,) and environment (一个 Environment Recordundefined,) and returns 要么是包含 unused正常完成,要么是突兀完成.

Note

undefined 传给 environment 表示应使用 PutValue 操作为初始化值赋值。这适用于 var 语句以及某些非严格函数的形式参数列表(见 10.2.11)。在这些情况下,会在求值其初始化器之前提升并预初始化一个词法绑定。

It is defined piecewise over the following productions:

BindingIdentifier : Identifier
  1. nameIdentifierStringValue
  2. 返回 ? InitializeBoundName(name, value, environment)。
BindingIdentifier : yield
  1. 返回 ? InitializeBoundName("yield", value, environment)。
BindingIdentifier : await
  1. 返回 ? InitializeBoundName("await", value, environment)。
BindingPattern : ObjectBindingPattern
  1. 执行 ? RequireObjectCoercible(value)。
  2. 返回 ? 以 valueenvironment 作为参数对 ObjectBindingPattern 进行 BindingInitialization 的结果。
BindingPattern : ArrayBindingPattern
  1. iteratorRecord 为 ? GetIterator(value, sync)。
  2. resultCompletion(以 iteratorRecordenvironment 作为参数对 ArrayBindingPattern 进行 IteratorBindingInitialization 的结果)。
  3. 如果 iteratorRecord.[[Done]]false,返回 ? IteratorClose(iteratorRecord, result)。
  4. 返回 ? result
ObjectBindingPattern : { }
  1. 返回 unused
ObjectBindingPattern : { BindingPropertyList } { BindingPropertyList , }
  1. 执行 ? 以 valueenvironment 作为参数对 BindingPropertyList 进行 PropertyBindingInitialization
  2. 返回 unused
ObjectBindingPattern : { BindingRestProperty }
  1. excludedNames 为一个新的空 List
  2. 返回 ? 以 valueenvironmentexcludedNames 作为参数对 BindingRestProperty 进行 RestBindingInitialization 的结果。
ObjectBindingPattern : { BindingPropertyList , BindingRestProperty }
  1. excludedNames 为 ? 以 valueenvironment 作为参数对 BindingPropertyList 进行 PropertyBindingInitialization 的结果。
  2. 返回 ? 以 valueenvironmentexcludedNames 作为参数对 BindingRestProperty 进行 RestBindingInitialization 的结果。

8.6.2.1 InitializeBoundName ( name, value, environment )

The abstract operation InitializeBoundName takes arguments name (一个 String,), value (一个 ECMAScript 语言值,), and environment (一个 Environment Recordundefined,) and returns 要么是包含 unused正常完成,要么是突兀完成. It performs the following steps when called:

  1. 如果 environment 不是 undefined,那么
    1. 执行 ! environment.InitializeBinding(name, value)。
    2. 返回 unused
  2. lhs 为 ? ResolveBinding(name)。
  3. 返回 ? PutValue(lhs, value)。

8.6.3 Runtime Semantics: IteratorBindingInitialization

The syntax-directed operation IteratorBindingInitialization takes arguments iteratorRecord (一个 Iterator Record,) and environment (一个 Environment Recordundefined,) and returns 要么是包含 unused正常完成,要么是突兀完成.

Note

当向 environment 传入 undefined 时,表示应使用 PutValue 操作为初始化值赋值。这适用于非严格函数的形式参数列表。在这种情况下,形式参数绑定会被预初始化,以处理可能存在多个同名参数的情况。

It is defined piecewise over the following productions:

ArrayBindingPattern : [ ]
  1. 返回 unused
ArrayBindingPattern : [ Elision ]
  1. 返回 ? 以 iteratorRecord 作为参数对 Elision 进行 IteratorDestructuringAssignmentEvaluation 的结果。
ArrayBindingPattern : [ Elisionopt BindingRestElement ]
  1. 如果 Elision 存在,那么
    1. 执行 ? 以 iteratorRecord 作为参数对 Elision 进行 IteratorDestructuringAssignmentEvaluation
  2. 返回 ? 以 iteratorRecordenvironment 作为参数对 BindingRestElement 进行 IteratorBindingInitialization 的结果。
ArrayBindingPattern : [ BindingElementList , Elision ]
  1. 执行 ? 以 iteratorRecordenvironment 作为参数对 BindingElementList 进行 IteratorBindingInitialization
  2. 返回 ? 以 iteratorRecord 作为参数对 Elision 进行 IteratorDestructuringAssignmentEvaluation 的结果。
ArrayBindingPattern : [ BindingElementList , Elisionopt BindingRestElement ]
  1. 执行 ? 以 iteratorRecordenvironment 作为参数对 BindingElementList 进行 IteratorBindingInitialization
  2. 如果 Elision 存在,那么
    1. 执行 ? 以 iteratorRecord 作为参数对 Elision 进行 IteratorDestructuringAssignmentEvaluation
  3. 返回 ? 以 iteratorRecordenvironment 作为参数对 BindingRestElement 进行 IteratorBindingInitialization 的结果。
BindingElementList : BindingElementList , BindingElisionElement
  1. 执行 ? 以 iteratorRecordenvironment 作为参数对 BindingElementList 进行 IteratorBindingInitialization
  2. 返回 ? 以 iteratorRecordenvironment 作为参数对 BindingElisionElement 进行 IteratorBindingInitialization 的结果。
BindingElisionElement : Elision BindingElement
  1. 执行 ? 以 iteratorRecord 作为参数对 Elision 进行 IteratorDestructuringAssignmentEvaluation
  2. 返回 ? 以 iteratorRecordenvironment 作为参数对 BindingElement 进行 IteratorBindingInitialization 的结果。
SingleNameBinding : BindingIdentifier Initializeropt
  1. bindingIdBindingIdentifierStringValue
  2. lhs 为 ? ResolveBinding(bindingId, environment)。
  3. vundefined
  4. 如果 iteratorRecord.[[Done]]false,那么
    1. next 为 ? IteratorStepValue(iteratorRecord)。
    2. 如果 next 不是 done,那么
      1. v 设为 next
  5. 如果 Initializer 存在且 vundefined,那么
    1. 如果 IsAnonymousFunctionDefinition(Initializer) 是 true,那么
      1. v 设为 ? 以 bindingId 作为参数对 Initializer 进行 NamedEvaluation 的结果。
    2. 否则,
      1. defaultValue 为 ? 对 Initializer 进行 Evaluation 的结果。
      2. v 设为 ? GetValue(defaultValue)。
  6. 如果 environmentundefined,返回 ? PutValue(lhs, v)。
  7. 返回 ? InitializeReferencedBinding(lhs, v)。
BindingElement : BindingPattern Initializeropt
  1. vundefined
  2. 如果 iteratorRecord.[[Done]]false,那么
    1. next 为 ? IteratorStepValue(iteratorRecord)。
    2. 如果 next 不是 done,那么
      1. v 设为 next
  3. 如果 Initializer 存在且 vundefined,那么
    1. defaultValue 为 ? 对 Initializer 进行 Evaluation 的结果。
    2. v 设为 ? GetValue(defaultValue)。
  4. 返回 ? 以 venvironment 作为参数对 BindingPattern 进行 BindingInitialization 的结果。
BindingRestElement : ... BindingIdentifier
  1. lhs 为 ? ResolveBinding(BindingIdentifierStringValue, environment)。
  2. array 为 ! ArrayCreate(0)。
  3. n 为 0。
  4. 重复,
    1. nextdone
    2. 如果 iteratorRecord.[[Done]]false,那么
      1. next 设为 ? IteratorStepValue(iteratorRecord)。
    3. 如果 nextdone,那么
      1. 如果 environmentundefined,返回 ? PutValue(lhs, array)。
      2. 返回 ? InitializeReferencedBinding(lhs, array)。
    4. 执行 ! CreateDataPropertyOrThrow(array, ! ToString(𝔽(n)), next)。
    5. n 设为 n + 1。
BindingRestElement : ... BindingPattern
  1. array 为 ! ArrayCreate(0)。
  2. n 为 0。
  3. 重复,
    1. nextdone
    2. 如果 iteratorRecord.[[Done]]false,那么
      1. next 设为 ? IteratorStepValue(iteratorRecord)。
    3. 如果 nextdone,那么
      1. 返回 ? 以 arrayenvironment 作为参数对 BindingPattern 进行 BindingInitialization 的结果。
    4. 执行 ! CreateDataPropertyOrThrow(array, ! ToString(𝔽(n)), next)。
    5. n 设为 n + 1。
FormalParameters : [empty]
  1. 返回 unused
FormalParameters : FormalParameterList , FunctionRestParameter
  1. 执行 ? 以 iteratorRecordenvironment 作为参数对 FormalParameterList 进行 IteratorBindingInitialization
  2. 返回 ? 以 iteratorRecordenvironment 作为参数对 FunctionRestParameter 进行 IteratorBindingInitialization 的结果。
FormalParameterList : FormalParameterList , FormalParameter
  1. 执行 ? 以 iteratorRecordenvironment 作为参数对 FormalParameterList 进行 IteratorBindingInitialization
  2. 返回 ? 以 iteratorRecordenvironment 作为参数对 FormalParameter 进行 IteratorBindingInitialization 的结果。
ArrowParameters : BindingIdentifier
  1. vundefined
  2. 断言:iteratorRecord.[[Done]]false
  3. next 为 ? IteratorStepValue(iteratorRecord)。
  4. 如果 next 不是 done,那么
    1. v 设为 next
  5. 返回 ? 以 venvironment 作为参数对 BindingIdentifier 进行 BindingInitialization 的结果。
ArrowParameters : CoverParenthesizedExpressionAndArrowParameterList
  1. formals 为被 CoverParenthesizedExpressionAndArrowParameterList 覆盖ArrowFormalParameters
  2. 返回 ? 以 iteratorRecordenvironment 作为参数对 formals 进行 IteratorBindingInitialization 的结果。
AsyncArrowBindingIdentifier : BindingIdentifier
  1. vundefined
  2. 断言:iteratorRecord.[[Done]]false
  3. next 为 ? IteratorStepValue(iteratorRecord)。
  4. 如果 next 不是 done,那么
    1. v 设为 next
  5. 返回 ? 以 venvironment 作为参数对 BindingIdentifier 进行 BindingInitialization 的结果。

8.6.4 Static Semantics: AssignmentTargetType

The syntax-directed operation AssignmentTargetType takes no arguments and returns simpleweb-compatinvalid. It is defined piecewise over the following productions:

IdentifierReference : Identifier
  1. 如果 IsStrict(this IdentifierReference) 是 true,且 IdentifierStringValue"eval""arguments" 之一,返回 invalid
  2. 返回 simple
IdentifierReference : yield await CallExpression : CallExpression [ Expression ] CallExpression . IdentifierName CallExpression . PrivateIdentifier MemberExpression : MemberExpression [ Expression ] MemberExpression . IdentifierName SuperProperty MemberExpression . PrivateIdentifier
  1. 返回 simple
PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList
  1. expr 为被 CoverParenthesizedExpressionAndArrowParameterList 覆盖ParenthesizedExpression
  2. 返回 exprAssignmentTargetType
CallExpression : CoverCallExpressionAndAsyncArrowHead CallExpression Arguments
  1. Normative Optional
    如果宿主是网页浏览器,或以其他方式支持 函数调用作为赋值目标时的运行时错误,并且 IsStrict(this CallExpression) 是 false,那么
    1. 返回 web-compat
  2. 返回 invalid
PrimaryExpression : this Literal ArrayLiteral ObjectLiteral FunctionExpression ClassExpression GeneratorExpression AsyncFunctionExpression AsyncGeneratorExpression RegularExpressionLiteral TemplateLiteral CallExpression : SuperCall ImportCall CallExpression TemplateLiteral NewExpression : new NewExpression MemberExpression : MemberExpression TemplateLiteral new MemberExpression Arguments NewTarget : new . target ImportMeta : import . meta LeftHandSideExpression : OptionalExpression UpdateExpression : LeftHandSideExpression ++ LeftHandSideExpression -- ++ UnaryExpression -- UnaryExpression UnaryExpression : delete UnaryExpression void UnaryExpression typeof UnaryExpression + UnaryExpression - UnaryExpression ~ UnaryExpression ! UnaryExpression AwaitExpression ExponentiationExpression : UpdateExpression ** ExponentiationExpression MultiplicativeExpression : MultiplicativeExpression MultiplicativeOperator ExponentiationExpression AdditiveExpression : AdditiveExpression + MultiplicativeExpression AdditiveExpression - MultiplicativeExpression ShiftExpression : ShiftExpression << AdditiveExpression ShiftExpression >> AdditiveExpression ShiftExpression >>> AdditiveExpression RelationalExpression : RelationalExpression < ShiftExpression RelationalExpression > ShiftExpression RelationalExpression <= ShiftExpression RelationalExpression >= ShiftExpression RelationalExpression instanceof ShiftExpression RelationalExpression in ShiftExpression PrivateIdentifier in ShiftExpression EqualityExpression : EqualityExpression == RelationalExpression EqualityExpression != RelationalExpression EqualityExpression === RelationalExpression EqualityExpression !== RelationalExpression BitwiseANDExpression : BitwiseANDExpression & EqualityExpression BitwiseXORExpression : BitwiseXORExpression ^ BitwiseANDExpression BitwiseORExpression : BitwiseORExpression | BitwiseXORExpression LogicalANDExpression : LogicalANDExpression && BitwiseORExpression LogicalORExpression : LogicalORExpression || LogicalANDExpression CoalesceExpression : CoalesceExpressionHead ?? BitwiseORExpression ConditionalExpression : ShortCircuitExpression ? AssignmentExpression : AssignmentExpression AssignmentExpression : YieldExpression ArrowFunction AsyncArrowFunction LeftHandSideExpression = AssignmentExpression LeftHandSideExpression AssignmentOperator AssignmentExpression LeftHandSideExpression &&= AssignmentExpression LeftHandSideExpression ||= AssignmentExpression LeftHandSideExpression ??= AssignmentExpression Expression : Expression , AssignmentExpression
  1. 返回 invalid

8.6.5 Static Semantics: PropName

The syntax-directed operation PropName takes no arguments and returns 一个 String 或 empty. It is defined piecewise over the following productions:

PropertyDefinition : IdentifierReference
  1. 返回 IdentifierReferenceStringValue
PropertyDefinition : ... AssignmentExpression
  1. 返回 empty
PropertyDefinition : PropertyName : AssignmentExpression
  1. 返回 PropertyNamePropName
LiteralPropertyName : IdentifierName AttributeKey : IdentifierName
  1. 返回 IdentifierNameStringValue
LiteralPropertyName : StringLiteral AttributeKey : StringLiteral
  1. 返回 StringLiteralSV
LiteralPropertyName : NumericLiteral
  1. nbrNumericLiteralNumericValue
  2. 返回 ! ToString(nbr)。
ComputedPropertyName : [ AssignmentExpression ]
  1. 返回 empty
MethodDefinition : ClassElementName ( UniqueFormalParameters ) { FunctionBody } get ClassElementName ( ) { FunctionBody } set ClassElementName ( PropertySetParameterList ) { FunctionBody }
  1. 返回 ClassElementNamePropName
GeneratorMethod : * ClassElementName ( UniqueFormalParameters ) { GeneratorBody }
  1. 返回 ClassElementNamePropName
AsyncGeneratorMethod : async * ClassElementName ( UniqueFormalParameters ) { AsyncGeneratorBody }
  1. 返回 ClassElementNamePropName
ClassElement : ClassStaticBlock
  1. 返回 empty
ClassElement : ;
  1. 返回 empty
AsyncMethod : async ClassElementName ( UniqueFormalParameters ) { AsyncFunctionBody }
  1. 返回 ClassElementNamePropName
FieldDefinition : ClassElementName Initializeropt
  1. 返回 ClassElementNamePropName
ClassElementName : PrivateIdentifier
  1. 返回 empty