页面模式偏好

8 语法制导操作

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

8.1 Runtime Semantics: Evaluation

语法制导操作 Evaluation,接收无参数;返回值:完成记录。

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

8.2 作用域分析

8.2.1 Static Semantics: BoundNames

语法制导操作 BoundNames,接收无参数;返回值:列表 (元素:String)。

注

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

它按以下产生式分别定义:

BindingIdentifier : Identifier
  1. 返回一个 List,其唯一元素为 Identifier 的 StringValue。
BindingIdentifier : yield
  1. 返回 « "yield" »。
BindingIdentifier : await
  1. 返回 « "await" »。
LexicalDeclaration : LetOrConst BindingList ;
  1. 返回 BindingList 的 BoundNames。
UsingDeclaration : using BindingList ; AwaitUsingDeclaration : CoverAwaitExpressionAndAwaitUsingDeclarationHead BindingList ;
  1. 返回 BindingList 的 BoundNames。
BindingList : BindingList , LexicalBinding
  1. 令 names1 为 BindingList 的 BoundNames。
  2. 令 names2 为 LexicalBinding 的 BoundNames。
  3. 返回 names1 和 names2 的列表连接。
LexicalBinding : BindingIdentifier Initializeropt
  1. 返回 BindingIdentifier 的 BoundNames。
LexicalBinding : BindingPattern Initializer
  1. 返回 BindingPattern 的 BoundNames。
VariableDeclarationList : VariableDeclarationList , VariableDeclaration
  1. 令 names1 为 VariableDeclarationList 的 BoundNames。
  2. 令 names2 为 VariableDeclaration 的 BoundNames。
  3. 返回 names1 和 names2 的列表连接。
VariableDeclaration : BindingIdentifier Initializeropt
  1. 返回 BindingIdentifier 的 BoundNames。
VariableDeclaration : BindingPattern Initializer
  1. 返回 BindingPattern 的 BoundNames。
ObjectBindingPattern : { }
  1. 返回新的空 List。
ObjectBindingPattern : { BindingPropertyList , BindingRestProperty }
  1. 令 names1 为 BindingPropertyList 的 BoundNames。
  2. 令 names2 为 BindingRestProperty 的 BoundNames。
  3. 返回 names1 和 names2 的列表连接。
ArrayBindingPattern : [ Elisionopt ]
  1. 返回新的空 List。
ArrayBindingPattern : [ Elisionopt BindingRestElement ]
  1. 返回 BindingRestElement 的 BoundNames。
ArrayBindingPattern : [ BindingElementList , Elisionopt ]
  1. 返回 BindingElementList 的 BoundNames。
ArrayBindingPattern : [ BindingElementList , Elisionopt BindingRestElement ]
  1. 令 names1 为 BindingElementList 的 BoundNames。
  2. 令 names2 为 BindingRestElement 的 BoundNames。
  3. 返回 names1 和 names2 的列表连接。
BindingPropertyList : BindingPropertyList , BindingProperty
  1. 令 names1 为 BindingPropertyList 的 BoundNames。
  2. 令 names2 为 BindingProperty 的 BoundNames。
  3. 返回 names1 和 names2 的列表连接。
BindingElementList : BindingElementList , BindingElisionElement
  1. 令 names1 为 BindingElementList 的 BoundNames。
  2. 令 names2 为 BindingElisionElement 的 BoundNames。
  3. 返回 names1 和 names2 的列表连接。
BindingElisionElement : Elisionopt BindingElement
  1. 返回 BindingElement 的 BoundNames。
BindingProperty : PropertyName : BindingElement
  1. 返回 BindingElement 的 BoundNames。
SingleNameBinding : BindingIdentifier Initializeropt
  1. 返回 BindingIdentifier 的 BoundNames。
BindingElement : BindingPattern Initializeropt
  1. 返回 BindingPattern 的 BoundNames。
ForDeclaration : LetOrConst ForBinding
  1. 返回 ForBinding 的 BoundNames。
FunctionDeclaration : function BindingIdentifier ( FormalParameters ) { FunctionBody }
  1. 返回 BindingIdentifier 的 BoundNames。
FunctionDeclaration : function ( FormalParameters ) { FunctionBody }
  1. 返回 « "*default*" »。
FormalParameters : [empty]
  1. 返回新的空 List。
FormalParameters : FormalParameterList , FunctionRestParameter
  1. 令 names1 为 FormalParameterList 的 BoundNames。
  2. 令 names2 为 FunctionRestParameter 的 BoundNames。
  3. 返回 names1 和 names2 的列表连接。
FormalParameterList : FormalParameterList , FormalParameter
  1. 令 names1 为 FormalParameterList 的 BoundNames。
  2. 令 names2 为 FormalParameter 的 BoundNames。
  3. 返回 names1 和 names2 的列表连接。
ArrowParameters : CoverParenthesizedExpressionAndArrowParameterList
  1. 令 formals 为 CoverParenthesizedExpressionAndArrowParameterList 所覆盖的 ArrowFormalParameters。
  2. 返回 formals 的 BoundNames。
GeneratorDeclaration : function * BindingIdentifier ( FormalParameters ) { GeneratorBody }
  1. 返回 BindingIdentifier 的 BoundNames。
GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody }
  1. 返回 « "*default*" »。
AsyncGeneratorDeclaration : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody }
  1. 返回 BindingIdentifier 的 BoundNames。
AsyncGeneratorDeclaration : async function * ( FormalParameters ) { AsyncGeneratorBody }
  1. 返回 « "*default*" »。
ClassDeclaration : class BindingIdentifier ClassTail
  1. 返回 BindingIdentifier 的 BoundNames。
ClassDeclaration : class ClassTail
  1. 返回 « "*default*" »。
AsyncFunctionDeclaration : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody }
  1. 返回 BindingIdentifier 的 BoundNames。
AsyncFunctionDeclaration : async function ( FormalParameters ) { AsyncFunctionBody }
  1. 返回 « "*default*" »。
CoverCallExpressionAndAsyncArrowHead : MemberExpression Arguments
  1. 令 head 为 CoverCallExpressionAndAsyncArrowHead 所覆盖的 AsyncArrowHead。
  2. 返回 head 的 BoundNames。
ImportDeclaration : import ImportClause FromClause WithClauseopt ;
  1. 返回 ImportClause 的 BoundNames。
ImportDeclaration : import ModuleSpecifier WithClauseopt ;
  1. 返回新的空 List。
ImportClause : ImportedDefaultBinding , NameSpaceImport
  1. 令 names1 为 ImportedDefaultBinding 的 BoundNames。
  2. 令 names2 为 NameSpaceImport 的 BoundNames。
  3. 返回 names1 和 names2 的列表连接。
ImportClause : ImportedDefaultBinding , NamedImports
  1. 令 names1 为 ImportedDefaultBinding 的 BoundNames。
  2. 令 names2 为 NamedImports 的 BoundNames。
  3. 返回 names1 和 names2 的列表连接。
NamedImports : { }
  1. 返回新的空 List。
ImportsList : ImportsList , ImportSpecifier
  1. 令 names1 为 ImportsList 的 BoundNames。
  2. 令 names2 为 ImportSpecifier 的 BoundNames。
  3. 返回 names1 和 names2 的列表连接。
ImportSpecifier : ModuleExportName as ImportedBinding
  1. 返回 ImportedBinding 的 BoundNames。
ExportDeclaration : export ExportFromClause FromClause WithClauseopt ; export NamedExports ;
  1. 返回新的空 List。
ExportDeclaration : export VariableStatement
  1. 返回 VariableStatement 的 BoundNames。
ExportDeclaration : export Declaration
  1. 返回 Declaration 的 BoundNames。
ExportDeclaration : export default HoistableDeclaration
  1. 令 declNames 为 HoistableDeclaration 的 BoundNames。
  2. 如果 declNames 不包含元素 "*default*",则将 "*default*" 追加到 declNames。
  3. 返回 declNames。
ExportDeclaration : export default ClassDeclaration
  1. 令 declNames 为 ClassDeclaration 的 BoundNames。
  2. 如果 declNames 不包含元素 "*default*",则将 "*default*" 追加到 declNames。
  3. 返回 declNames。
ExportDeclaration : export default AssignmentExpression ;
  1. 返回 « "*default*" »。

8.2.2 Static Semantics: DeclarationPart

语法制导操作 DeclarationPart,接收无参数;返回值:解析节点。 它按以下产生式分别定义:

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

语法制导操作 IsConstantDeclaration,接收无参数;返回值:Boolean。 它按以下产生式分别定义:

LexicalDeclaration : LetOrConst BindingList ;
  1. 返回 LetOrConst 的 IsConstantDeclaration。
LetOrConst : let
  1. 返回 false。
LetOrConst : const
  1. 返回 true。
UsingDeclaration : using BindingList ; AwaitUsingDeclaration : CoverAwaitExpressionAndAwaitUsingDeclarationHead BindingList ;
  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。
注

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

8.2.4 Static Semantics: IsUsingDeclaration

语法制导操作 IsUsingDeclaration,接收无参数;返回值:Boolean。 它按以下产生式分别定义:

LexicalDeclaration : LetOrConst BindingList ;
  1. 返回 false。
UsingDeclaration : using BindingList ;
  1. 返回 true。
AwaitUsingDeclaration : CoverAwaitExpressionAndAwaitUsingDeclarationHead BindingList ;
  1. 返回 false。
ForDeclaration : LetOrConst ForBinding
  1. 返回 false。
ForDeclaration : using ForBinding
  1. 返回 true。
ForDeclaration : await using ForBinding
  1. 返回 false。
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。

8.2.5 Static Semantics: IsAwaitUsingDeclaration

语法制导操作 IsAwaitUsingDeclaration,接收无参数;返回值:Boolean。 它按以下产生式分别定义:

LexicalDeclaration : LetOrConst BindingList ;
  1. 返回 false。
UsingDeclaration : using BindingList ;
  1. 返回 false。
AwaitUsingDeclaration : CoverAwaitExpressionAndAwaitUsingDeclarationHead BindingList ;
  1. 返回 true。
ForDeclaration : LetOrConst ForBinding
  1. 返回 false。
ForDeclaration : using ForBinding
  1. 返回 false。
ForDeclaration : await using ForBinding
  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。

8.2.6 Static Semantics: LexicallyDeclaredNames

语法制导操作 LexicallyDeclaredNames,接收无参数;返回值:列表 (元素:String)。 它按以下产生式分别定义:

Block : { }
  1. 返回新的空 List。
StatementList : StatementList StatementListItem
  1. 令 names1 为 StatementList 的 LexicallyDeclaredNames。
  2. 令 names2 为 StatementListItem 的 LexicallyDeclaredNames。
  3. 返回 names1 和 names2 的列表连接。
StatementListItem : Statement
  1. 如果 Statement 是 Statement : LabelledStatement ,则返回 LabelledStatement 的 LexicallyDeclaredNames。
  2. 返回新的空 List。
StatementListItem : Declaration
  1. 返回 Declaration 的 BoundNames。
CaseBlock : { }
  1. 返回新的空 List。
CaseBlock : { CaseClausesopt DefaultClause CaseClausesopt }
  1. 如果存在第一个 CaseClauses,则令 names1 为第一个 CaseClauses 的 LexicallyDeclaredNames。
  2. 否则,令 names1 为新的空 List。
  3. 令 names2 为 DefaultClause 的 LexicallyDeclaredNames。
  4. 如果存在第二个 CaseClauses,则令 names3 为第二个 CaseClauses 的 LexicallyDeclaredNames。
  5. 否则,令 names3 为新的空 List。
  6. 返回 names1、names2 和 names3 的列表连接。
CaseClauses : CaseClauses CaseClause
  1. 令 names1 为 CaseClauses 的 LexicallyDeclaredNames。
  2. 令 names2 为 CaseClause 的 LexicallyDeclaredNames。
  3. 返回 names1 和 names2 的列表连接。
CaseClause : case Expression : StatementListopt
  1. 如果存在 StatementList,则返回 StatementList 的 LexicallyDeclaredNames。
  2. 返回新的空 List。
DefaultClause : default : StatementListopt
  1. 如果存在 StatementList,则返回 StatementList 的 LexicallyDeclaredNames。
  2. 返回新的空 List。
LabelledStatement : LabelIdentifier : LabelledItem
  1. 返回 LabelledItem 的 LexicallyDeclaredNames。
LabelledItem : Statement
  1. 返回新的空 List。
LabelledItem : FunctionDeclaration
  1. 返回 FunctionDeclaration 的 BoundNames。
FunctionStatementList : [empty]
  1. 返回新的空 List。
FunctionStatementList : StatementList
  1. 返回 StatementList 的 TopLevelLexicallyDeclaredNames。
ClassStaticBlockStatementList : [empty]
  1. 返回新的空 List。
ClassStaticBlockStatementList : StatementList
  1. 返回 StatementList 的 TopLevelLexicallyDeclaredNames。
ConciseBody : ExpressionBody
  1. 返回新的空 List。
AsyncConciseBody : ExpressionBody
  1. 返回新的空 List。
Script : [empty]
  1. 返回新的空 List。
ScriptBody : StatementList
  1. 返回 StatementList 的 TopLevelLexicallyDeclaredNames。
注 1

在 Script 的顶层,函数声明被视为类似 var 声明,而不是词法声明。

注 2

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

ModuleItemList : ModuleItemList ModuleItem
  1. 令 names1 为 ModuleItemList 的 LexicallyDeclaredNames。
  2. 令 names2 为 ModuleItem 的 LexicallyDeclaredNames。
  3. 返回 names1 和 names2 的列表连接。
ModuleItem : ImportDeclaration
  1. 返回 ImportDeclaration 的 BoundNames。
ModuleItem : ExportDeclaration
  1. 如果 ExportDeclaration 是 export VariableStatement,则返回新的空 List。
  2. 返回 ExportDeclaration 的 BoundNames。
ModuleItem : StatementListItem
  1. 返回 StatementListItem 的 LexicallyDeclaredNames。
注 3

在 Module 的顶层,函数声明被视为类似词法声明,而不是 var 声明。

8.2.7 Static Semantics: LexicallyScopedDeclarations

语法制导操作 LexicallyScopedDeclarations,接收无参数;返回值:列表 (元素:解析节点)。 它按以下产生式分别定义:

StatementList : StatementList StatementListItem
  1. 令 decls1 为 StatementList 的 LexicallyScopedDeclarations。
  2. 令 decls2 为 StatementListItem 的 LexicallyScopedDeclarations。
  3. 返回 decls1 和 decls2 的列表连接。
StatementListItem : Statement
  1. 如果 Statement 是 Statement : LabelledStatement ,则返回 LabelledStatement 的 LexicallyScopedDeclarations。
  2. 返回新的空 List。
StatementListItem : Declaration
  1. 返回一个 List,其唯一元素为 Declaration 的 DeclarationPart。
CaseBlock : { }
  1. 返回新的空 List。
CaseBlock : { CaseClausesopt DefaultClause CaseClausesopt }
  1. 如果存在第一个 CaseClauses,则令 decls1 为第一个 CaseClauses 的 LexicallyScopedDeclarations。
  2. 否则,令 decls1 为新的空 List。
  3. 令 decls2 为 DefaultClause 的 LexicallyScopedDeclarations。
  4. 如果存在第二个 CaseClauses,则令 decls3 为第二个 CaseClauses 的 LexicallyScopedDeclarations。
  5. 否则,令 decls3 为新的空 List。
  6. 返回 decls1、decls2 和 decls3 的列表连接。
CaseClauses : CaseClauses CaseClause
  1. 令 decls1 为 CaseClauses 的 LexicallyScopedDeclarations。
  2. 令 decls2 为 CaseClause 的 LexicallyScopedDeclarations。
  3. 返回 decls1 和 decls2 的列表连接。
CaseClause : case Expression : StatementListopt
  1. 如果存在 StatementList,则返回 StatementList 的 LexicallyScopedDeclarations。
  2. 返回新的空 List。
DefaultClause : default : StatementListopt
  1. 如果存在 StatementList,则返回 StatementList 的 LexicallyScopedDeclarations。
  2. 返回新的空 List。
LabelledStatement : LabelIdentifier : LabelledItem
  1. 返回 LabelledItem 的 LexicallyScopedDeclarations。
LabelledItem : Statement
  1. 返回新的空 List。
LabelledItem : FunctionDeclaration
  1. 返回 « FunctionDeclaration »。
FunctionStatementList : [empty]
  1. 返回新的空 List。
FunctionStatementList : StatementList
  1. 返回 StatementList 的 TopLevelLexicallyScopedDeclarations。
ClassStaticBlockStatementList : [empty]
  1. 返回新的空 List。
ClassStaticBlockStatementList : StatementList
  1. 返回 StatementList 的 TopLevelLexicallyScopedDeclarations。
ConciseBody : ExpressionBody
  1. 返回新的空 List。
AsyncConciseBody : ExpressionBody
  1. 返回新的空 List。
Script : [empty]
  1. 返回新的空 List。
ScriptBody : StatementList
  1. 返回 StatementList 的 TopLevelLexicallyScopedDeclarations。
Module : [empty]
  1. 返回新的空 List。
ModuleItemList : ModuleItemList ModuleItem
  1. 令 decls1 为 ModuleItemList 的 LexicallyScopedDeclarations。
  2. 令 decls2 为 ModuleItem 的 LexicallyScopedDeclarations。
  3. 返回 decls1 和 decls2 的列表连接。
ModuleItem : ImportDeclaration
  1. 返回新的空 List。
ExportDeclaration : export ExportFromClause FromClause WithClauseopt ; export NamedExports ; export VariableStatement
  1. 返回新的空 List。
ExportDeclaration : export Declaration
  1. 返回一个 List,其唯一元素为 Declaration 的 DeclarationPart。
ExportDeclaration : export default HoistableDeclaration
  1. 返回一个 List,其唯一元素为 HoistableDeclaration 的 DeclarationPart。
ExportDeclaration : export default ClassDeclaration
  1. 返回一个 List,其唯一元素为 ClassDeclaration。
ExportDeclaration : export default AssignmentExpression ;
  1. 返回一个 List,其唯一元素为此 ExportDeclaration。

8.2.8 Static Semantics: VarDeclaredNames

语法制导操作 VarDeclaredNames,接收无参数;返回值:列表 (元素:String)。 它按以下产生式分别定义:

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

本节由附录 B.3.5 扩展。

WithStatement : with ( Expression ) Statement
  1. 返回 Statement 的 VarDeclaredNames。
SwitchStatement : switch ( Expression ) CaseBlock
  1. 返回 CaseBlock 的 VarDeclaredNames。
CaseBlock : { }
  1. 返回新的空 List。
CaseBlock : { CaseClausesopt DefaultClause CaseClausesopt }
  1. 如果存在第一个 CaseClauses,则令 names1 为第一个 CaseClauses 的 VarDeclaredNames。
  2. 否则,令 names1 为新的空 List。
  3. 令 names2 为 DefaultClause 的 VarDeclaredNames。
  4. 如果存在第二个 CaseClauses,则令 names3 为第二个 CaseClauses 的 VarDeclaredNames。
  5. 否则,令 names3 为新的空 List。
  6. 返回 names1、names2 和 names3 的列表连接。
CaseClauses : CaseClauses CaseClause
  1. 令 names1 为 CaseClauses 的 VarDeclaredNames。
  2. 令 names2 为 CaseClause 的 VarDeclaredNames。
  3. 返回 names1 和 names2 的列表连接。
CaseClause : case Expression : StatementListopt
  1. 如果存在 StatementList,则返回 StatementList 的 VarDeclaredNames。
  2. 返回新的空 List。
DefaultClause : default : StatementListopt
  1. 如果存在 StatementList,则返回 StatementList 的 VarDeclaredNames。
  2. 返回新的空 List。
LabelledStatement : LabelIdentifier : LabelledItem
  1. 返回 LabelledItem 的 VarDeclaredNames。
LabelledItem : FunctionDeclaration
  1. 返回新的空 List。
TryStatement : try Block Catch
  1. 令 names1 为 Block 的 VarDeclaredNames。
  2. 令 names2 为 Catch 的 VarDeclaredNames。
  3. 返回 names1 和 names2 的列表连接。
TryStatement : try Block Finally
  1. 令 names1 为 Block 的 VarDeclaredNames。
  2. 令 names2 为 Finally 的 VarDeclaredNames。
  3. 返回 names1 和 names2 的列表连接。
TryStatement : try Block Catch Finally
  1. 令 names1 为 Block 的 VarDeclaredNames。
  2. 令 names2 为 Catch 的 VarDeclaredNames。
  3. 令 names3 为 Finally 的 VarDeclaredNames。
  4. 返回 names1、names2 和 names3 的列表连接。
Catch : catch ( CatchParameter ) Block
  1. 返回 Block 的 VarDeclaredNames。
FunctionStatementList : [empty]
  1. 返回新的空 List。
FunctionStatementList : StatementList
  1. 返回 StatementList 的 TopLevelVarDeclaredNames。
ClassStaticBlockStatementList : [empty]
  1. 返回新的空 List。
ClassStaticBlockStatementList : StatementList
  1. 返回 StatementList 的 TopLevelVarDeclaredNames。
ConciseBody : ExpressionBody
  1. 返回新的空 List。
AsyncConciseBody : ExpressionBody
  1. 返回新的空 List。
Script : [empty]
  1. 返回新的空 List。
ScriptBody : StatementList
  1. 返回 StatementList 的 TopLevelVarDeclaredNames。
ModuleItemList : ModuleItemList ModuleItem
  1. 令 names1 为 ModuleItemList 的 VarDeclaredNames。
  2. 令 names2 为 ModuleItem 的 VarDeclaredNames。
  3. 返回 names1 和 names2 的列表连接。
ModuleItem : ImportDeclaration
  1. 返回新的空 List。
ModuleItem : ExportDeclaration
  1. 如果 ExportDeclaration 是 export VariableStatement,则返回 ExportDeclaration 的 BoundNames。
  2. 返回新的空 List。

8.2.9 Static Semantics: VarScopedDeclarations

语法制导操作 VarScopedDeclarations,接收无参数;返回值:列表 (元素:解析节点)。 它按以下产生式分别定义:

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

本节由附录 B.3.5 扩展。

WithStatement : with ( Expression ) Statement
  1. 返回 Statement 的 VarScopedDeclarations。
SwitchStatement : switch ( Expression ) CaseBlock
  1. 返回 CaseBlock 的 VarScopedDeclarations。
CaseBlock : { }
  1. 返回新的空 List。
CaseBlock : { CaseClausesopt DefaultClause CaseClausesopt }
  1. 如果存在第一个 CaseClauses,则令 decls1 为第一个 CaseClauses 的 VarScopedDeclarations。
  2. 否则,令 decls1 为新的空 List。
  3. 令 decls2 为 DefaultClause 的 VarScopedDeclarations。
  4. 如果存在第二个 CaseClauses,则令 decls3 为第二个 CaseClauses 的 VarScopedDeclarations。
  5. 否则,令 decls3 为新的空 List。
  6. 返回 decls1、decls2 和 decls3 的列表连接。
CaseClauses : CaseClauses CaseClause
  1. 令 decls1 为 CaseClauses 的 VarScopedDeclarations。
  2. 令 decls2 为 CaseClause 的 VarScopedDeclarations。
  3. 返回 decls1 和 decls2 的列表连接。
CaseClause : case Expression : StatementListopt
  1. 如果存在 StatementList,则返回 StatementList 的 VarScopedDeclarations。
  2. 返回新的空 List。
DefaultClause : default : StatementListopt
  1. 如果存在 StatementList,则返回 StatementList 的 VarScopedDeclarations。
  2. 返回新的空 List。
LabelledStatement : LabelIdentifier : LabelledItem
  1. 返回 LabelledItem 的 VarScopedDeclarations。
LabelledItem : FunctionDeclaration
  1. 返回新的空 List。
TryStatement : try Block Catch
  1. 令 decls1 为 Block 的 VarScopedDeclarations。
  2. 令 decls2 为 Catch 的 VarScopedDeclarations。
  3. 返回 decls1 和 decls2 的列表连接。
TryStatement : try Block Finally
  1. 令 decls1 为 Block 的 VarScopedDeclarations。
  2. 令 decls2 为 Finally 的 VarScopedDeclarations。
  3. 返回 decls1 和 decls2 的列表连接。
TryStatement : try Block Catch Finally
  1. 令 decls1 为 Block 的 VarScopedDeclarations。
  2. 令 decls2 为 Catch 的 VarScopedDeclarations。
  3. 令 decls3 为 Finally 的 VarScopedDeclarations。
  4. 返回 decls1、decls2 和 decls3 的列表连接。
Catch : catch ( CatchParameter ) Block
  1. 返回 Block 的 VarScopedDeclarations。
FunctionStatementList : [empty]
  1. 返回新的空 List。
FunctionStatementList : StatementList
  1. 返回 StatementList 的 TopLevelVarScopedDeclarations。
ClassStaticBlockStatementList : [empty]
  1. 返回新的空 List。
ClassStaticBlockStatementList : StatementList
  1. 返回 StatementList 的 TopLevelVarScopedDeclarations。
ConciseBody : ExpressionBody
  1. 返回新的空 List。
AsyncConciseBody : ExpressionBody
  1. 返回新的空 List。
Script : [empty]
  1. 返回新的空 List。
ScriptBody : StatementList
  1. 返回 StatementList 的 TopLevelVarScopedDeclarations。
Module : [empty]
  1. 返回新的空 List。
ModuleItemList : ModuleItemList ModuleItem
  1. 令 decls1 为 ModuleItemList 的 VarScopedDeclarations。
  2. 令 decls2 为 ModuleItem 的 VarScopedDeclarations。
  3. 返回 decls1 和 decls2 的列表连接。
ModuleItem : ImportDeclaration
  1. 返回新的空 List。
ModuleItem : ExportDeclaration
  1. 如果 ExportDeclaration 是 export VariableStatement,则返回 VariableStatement 的 VarScopedDeclarations。
  2. 返回新的空 List。

8.2.10 Static Semantics: TopLevelLexicallyDeclaredNames

语法制导操作 TopLevelLexicallyDeclaredNames,接收无参数;返回值:列表 (元素:String)。 它按以下产生式分别定义:

StatementList : StatementList StatementListItem
  1. 令 names1 为 StatementList 的 TopLevelLexicallyDeclaredNames。
  2. 令 names2 为 StatementListItem 的 TopLevelLexicallyDeclaredNames。
  3. 返回 names1 和 names2 的列表连接。
StatementListItem : Statement
  1. 返回新的空 List。
StatementListItem : Declaration
  1. 如果 Declaration 是 Declaration : HoistableDeclaration ,则
    1. 返回新的空 List。
  2. 返回 Declaration 的 BoundNames。
注

在函数或脚本的顶层,函数声明被视为类似 var 声明,而不是词法声明。

8.2.11 Static Semantics: TopLevelLexicallyScopedDeclarations

语法制导操作 TopLevelLexicallyScopedDeclarations,接收无参数;返回值:列表 (元素:解析节点)。 它按以下产生式分别定义:

StatementList : StatementList StatementListItem
  1. 令 decls1 为 StatementList 的 TopLevelLexicallyScopedDeclarations。
  2. 令 decls2 为 StatementListItem 的 TopLevelLexicallyScopedDeclarations。
  3. 返回 decls1 和 decls2 的列表连接。
StatementListItem : Statement
  1. 返回新的空 List。
StatementListItem : Declaration
  1. 如果 Declaration 是 Declaration : HoistableDeclaration ,则
    1. 返回新的空 List。
  2. 返回 « Declaration »。

8.2.12 Static Semantics: TopLevelVarDeclaredNames

语法制导操作 TopLevelVarDeclaredNames,接收无参数;返回值:列表 (元素:String)。 它按以下产生式分别定义:

StatementList : StatementList StatementListItem
  1. 令 names1 为 StatementList 的 TopLevelVarDeclaredNames。
  2. 令 names2 为 StatementListItem 的 TopLevelVarDeclaredNames。
  3. 返回 names1 和 names2 的列表连接。
StatementListItem : Declaration
  1. 如果 Declaration 是 Declaration : HoistableDeclaration ,则
    1. 返回 HoistableDeclaration 的 BoundNames。
  2. 返回新的空 List。
StatementListItem : Statement
  1. 如果 Statement 是 Statement : LabelledStatement ,则返回 Statement 的 TopLevelVarDeclaredNames。
  2. 返回 Statement 的 VarDeclaredNames。
注

在函数或脚本的顶层,内部函数声明被视为类似 var 声明。

LabelledStatement : LabelIdentifier : LabelledItem
  1. 返回 LabelledItem 的 TopLevelVarDeclaredNames。
LabelledItem : Statement
  1. 如果 Statement 是 Statement : LabelledStatement ,则返回 Statement 的 TopLevelVarDeclaredNames。
  2. 返回 Statement 的 VarDeclaredNames。
LabelledItem : FunctionDeclaration
  1. 返回 FunctionDeclaration 的 BoundNames。

8.2.13 Static Semantics: TopLevelVarScopedDeclarations

语法制导操作 TopLevelVarScopedDeclarations,接收无参数;返回值:列表 (元素:解析节点)。 它按以下产生式分别定义:

StatementList : StatementList StatementListItem
  1. 令 decls1 为 StatementList 的 TopLevelVarScopedDeclarations。
  2. 令 decls2 为 StatementListItem 的 TopLevelVarScopedDeclarations。
  3. 返回 decls1 和 decls2 的列表连接。
StatementListItem : Statement
  1. 如果 Statement 是 Statement : LabelledStatement ,则返回 Statement 的 TopLevelVarScopedDeclarations。
  2. 返回 Statement 的 VarScopedDeclarations。
StatementListItem : Declaration
  1. 如果 Declaration 是 Declaration : HoistableDeclaration ,则
    1. 令 decl 为 HoistableDeclaration 的 DeclarationPart。
    2. 返回 « decl »。
  2. 返回新的空 List。
LabelledStatement : LabelIdentifier : LabelledItem
  1. 返回 LabelledItem 的 TopLevelVarScopedDeclarations。
LabelledItem : Statement
  1. 如果 Statement 是 Statement : LabelledStatement ,则返回 Statement 的 TopLevelVarScopedDeclarations。
  2. 返回 Statement 的 VarScopedDeclarations。
LabelledItem : FunctionDeclaration
  1. 返回 « FunctionDeclaration »。

8.3 标签

8.3.1 Static Semantics: ContainsDuplicateLabels

语法制导操作 ContainsDuplicateLabels,接收参数 labelSet (列表 (元素:String));返回值:Boolean。 它按以下产生式分别定义:

Statement : VariableStatement EmptyStatement ExpressionStatement ContinueStatement BreakStatement ReturnStatement ThrowStatement DebuggerStatement Block : { } StatementListItem : Declaration
  1. 返回 false。
StatementList : StatementList StatementListItem
  1. 令 hasDuplicates 为以 labelSet 为参数对 StatementList 执行 ContainsDuplicateLabels 的结果。
  2. 如果 hasDuplicates 是 true,则返回 true。
  3. 返回以 labelSet 为参数对 StatementListItem 执行 ContainsDuplicateLabels 的结果。
IfStatement : if ( Expression ) Statement else Statement
  1. 令 hasDuplicate 为以 labelSet 为参数对第一个 Statement 执行 ContainsDuplicateLabels 的结果。
  2. 如果 hasDuplicate 是 true,则返回 true。
  3. 返回以 labelSet 为参数对第二个 Statement 执行 ContainsDuplicateLabels 的结果。
IfStatement : if ( Expression ) Statement
  1. 返回以 labelSet 为参数对 Statement 执行 ContainsDuplicateLabels 的结果。
DoWhileStatement : do Statement while ( Expression ) ;
  1. 返回以 labelSet 为参数对 Statement 执行 ContainsDuplicateLabels 的结果。
WhileStatement : while ( Expression ) Statement
  1. 返回以 labelSet 为参数对 Statement 执行 ContainsDuplicateLabels 的结果。
ForStatement : for ( Expressionopt ; Expressionopt ; Expressionopt ) Statement for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
  1. 返回以 labelSet 为参数对 Statement 执行 ContainsDuplicateLabels 的结果。
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 为参数对 Statement 执行 ContainsDuplicateLabels 的结果。
注

本节由附录 B.3.5 扩展。

WithStatement : with ( Expression ) Statement
  1. 返回以 labelSet 为参数对 Statement 执行 ContainsDuplicateLabels 的结果。
SwitchStatement : switch ( Expression ) CaseBlock
  1. 返回以 labelSet 为参数对 CaseBlock 执行 ContainsDuplicateLabels 的结果。
CaseBlock : { }
  1. 返回 false。
CaseBlock : { CaseClausesopt DefaultClause CaseClausesopt }
  1. 如果存在第一个 CaseClauses,则
    1. 如果以 labelSet 为参数对第一个 CaseClauses 执行 ContainsDuplicateLabels 的结果是 true,则返回 true。
  2. 如果以 labelSet 为参数对 DefaultClause 执行 ContainsDuplicateLabels 的结果是 true,则返回 true。
  3. 如果不存在第二个 CaseClauses,则返回 false。
  4. 返回以 labelSet 为参数对第二个 CaseClauses 执行 ContainsDuplicateLabels 的结果。
CaseClauses : CaseClauses CaseClause
  1. 令 hasDuplicates 为以 labelSet 为参数对 CaseClauses 执行 ContainsDuplicateLabels 的结果。
  2. 如果 hasDuplicates 是 true,则返回 true。
  3. 返回以 labelSet 为参数对 CaseClause 执行 ContainsDuplicateLabels 的结果。
CaseClause : case Expression : StatementListopt
  1. 如果存在 StatementList,则返回以 labelSet 为参数对 StatementList 执行 ContainsDuplicateLabels 的结果。
  2. 返回 false。
DefaultClause : default : StatementListopt
  1. 如果存在 StatementList,则返回以 labelSet 为参数对 StatementList 执行 ContainsDuplicateLabels 的结果。
  2. 返回 false。
LabelledStatement : LabelIdentifier : LabelledItem
  1. 令 label 为 LabelIdentifier 的 StringValue。
  2. 如果 labelSet 包含 label,则返回 true。
  3. 令 newLabelSet 为 labelSet 与 « label » 的列表连接。
  4. 返回以 newLabelSet 为参数对 LabelledItem 执行 ContainsDuplicateLabels 的结果。
LabelledItem : FunctionDeclaration
  1. 返回 false。
TryStatement : try Block Catch
  1. 令 hasDuplicates 为以 labelSet 为参数对 Block 执行 ContainsDuplicateLabels 的结果。
  2. 如果 hasDuplicates 是 true,则返回 true。
  3. 返回以 labelSet 为参数对 Catch 执行 ContainsDuplicateLabels 的结果。
TryStatement : try Block Finally
  1. 令 hasDuplicates 为以 labelSet 为参数对 Block 执行 ContainsDuplicateLabels 的结果。
  2. 如果 hasDuplicates 是 true,则返回 true。
  3. 返回以 labelSet 为参数对 Finally 执行 ContainsDuplicateLabels 的结果。
TryStatement : try Block Catch Finally
  1. 如果以 labelSet 为参数对 Block 执行 ContainsDuplicateLabels 的结果是 true,则返回 true。
  2. 如果以 labelSet 为参数对 Catch 执行 ContainsDuplicateLabels 的结果是 true,则返回 true。
  3. 返回以 labelSet 为参数对 Finally 执行 ContainsDuplicateLabels 的结果。
Catch : catch ( CatchParameter ) Block
  1. 返回以 labelSet 为参数对 Block 执行 ContainsDuplicateLabels 的结果。
FunctionStatementList : [empty]
  1. 返回 false。
ClassStaticBlockStatementList : [empty]
  1. 返回 false。
ModuleItemList : ModuleItemList ModuleItem
  1. 令 hasDuplicates 为以 labelSet 为参数对 ModuleItemList 执行 ContainsDuplicateLabels 的结果。
  2. 如果 hasDuplicates 是 true,则返回 true。
  3. 返回以 labelSet 为参数对 ModuleItem 执行 ContainsDuplicateLabels 的结果。
ModuleItem : ImportDeclaration ExportDeclaration
  1. 返回 false。

8.3.2 Static Semantics: ContainsUndefinedBreakTarget

语法制导操作 ContainsUndefinedBreakTarget,接收参数 labelSet (列表 (元素:String));返回值:Boolean。 它按以下产生式分别定义:

Statement : VariableStatement EmptyStatement ExpressionStatement ContinueStatement ReturnStatement ThrowStatement DebuggerStatement Block : { } StatementListItem : Declaration
  1. 返回 false。
StatementList : StatementList StatementListItem
  1. 令 hasUndefinedLabels 为以 labelSet 为参数对 StatementList 执行 ContainsUndefinedBreakTarget 的结果。
  2. 如果 hasUndefinedLabels 是 true,则返回 true。
  3. 返回以 labelSet 为参数对 StatementListItem 执行 ContainsUndefinedBreakTarget 的结果。
IfStatement : if ( Expression ) Statement else Statement
  1. 令 hasUndefinedLabels 为以 labelSet 为参数对第一个 Statement 执行 ContainsUndefinedBreakTarget 的结果。
  2. 如果 hasUndefinedLabels 是 true,则返回 true。
  3. 返回以 labelSet 为参数对第二个 Statement 执行 ContainsUndefinedBreakTarget 的结果。
IfStatement : if ( Expression ) Statement
  1. 返回以 labelSet 为参数对 Statement 执行 ContainsUndefinedBreakTarget 的结果。
DoWhileStatement : do Statement while ( Expression ) ;
  1. 返回以 labelSet 为参数对 Statement 执行 ContainsUndefinedBreakTarget 的结果。
WhileStatement : while ( Expression ) Statement
  1. 返回以 labelSet 为参数对 Statement 执行 ContainsUndefinedBreakTarget 的结果。
ForStatement : for ( Expressionopt ; Expressionopt ; Expressionopt ) Statement for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
  1. 返回以 labelSet 为参数对 Statement 执行 ContainsUndefinedBreakTarget 的结果。
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 为参数对 Statement 执行 ContainsUndefinedBreakTarget 的结果。
注

本节由附录 B.3.5 扩展。

BreakStatement : break ;
  1. 返回 false。
BreakStatement : break LabelIdentifier ;
  1. 如果 labelSet 包含 LabelIdentifier 的 StringValue,则返回 false。
  2. 返回 true。
WithStatement : with ( Expression ) Statement
  1. 返回以 labelSet 为参数对 Statement 执行 ContainsUndefinedBreakTarget 的结果。
SwitchStatement : switch ( Expression ) CaseBlock
  1. 返回以 labelSet 为参数对 CaseBlock 执行 ContainsUndefinedBreakTarget 的结果。
CaseBlock : { }
  1. 返回 false。
CaseBlock : { CaseClausesopt DefaultClause CaseClausesopt }
  1. 如果存在第一个 CaseClauses,则
    1. 如果以 labelSet 为参数对第一个 CaseClauses 执行 ContainsUndefinedBreakTarget 的结果是 true,则返回 true。
  2. 如果以 labelSet 为参数对 DefaultClause 执行 ContainsUndefinedBreakTarget 的结果是 true,则返回 true。
  3. 如果不存在第二个 CaseClauses,则返回 false。
  4. 返回以 labelSet 为参数对第二个 CaseClauses 执行 ContainsUndefinedBreakTarget 的结果。
CaseClauses : CaseClauses CaseClause
  1. 令 hasUndefinedLabels 为以 labelSet 为参数对 CaseClauses 执行 ContainsUndefinedBreakTarget 的结果。
  2. 如果 hasUndefinedLabels 是 true,则返回 true。
  3. 返回以 labelSet 为参数对 CaseClause 执行 ContainsUndefinedBreakTarget 的结果。
CaseClause : case Expression : StatementListopt
  1. 如果存在 StatementList,则返回以 labelSet 为参数对 StatementList 执行 ContainsUndefinedBreakTarget 的结果。
  2. 返回 false。
DefaultClause : default : StatementListopt
  1. 如果存在 StatementList,则返回以 labelSet 为参数对 StatementList 执行 ContainsUndefinedBreakTarget 的结果。
  2. 返回 false。
LabelledStatement : LabelIdentifier : LabelledItem
  1. 令 label 为 LabelIdentifier 的 StringValue。
  2. 令 newLabelSet 为 labelSet 与 « label » 的列表连接。
  3. 返回以 newLabelSet 为参数对 LabelledItem 执行 ContainsUndefinedBreakTarget 的结果。
LabelledItem : FunctionDeclaration
  1. 返回 false。
TryStatement : try Block Catch
  1. 令 hasUndefinedLabels 为以 labelSet 为参数对 Block 执行 ContainsUndefinedBreakTarget 的结果。
  2. 如果 hasUndefinedLabels 是 true,则返回 true。
  3. 返回以 labelSet 为参数对 Catch 执行 ContainsUndefinedBreakTarget 的结果。
TryStatement : try Block Finally
  1. 令 hasUndefinedLabels 为以 labelSet 为参数对 Block 执行 ContainsUndefinedBreakTarget 的结果。
  2. 如果 hasUndefinedLabels 是 true,则返回 true。
  3. 返回以 labelSet 为参数对 Finally 执行 ContainsUndefinedBreakTarget 的结果。
TryStatement : try Block Catch Finally
  1. 如果以 labelSet 为参数对 Block 执行 ContainsUndefinedBreakTarget 的结果是 true,则返回 true。
  2. 如果以 labelSet 为参数对 Catch 执行 ContainsUndefinedBreakTarget 的结果是 true,则返回 true。
  3. 返回以 labelSet 为参数对 Finally 执行 ContainsUndefinedBreakTarget 的结果。
Catch : catch ( CatchParameter ) Block
  1. 返回以 labelSet 为参数对 Block 执行 ContainsUndefinedBreakTarget 的结果。
FunctionStatementList : [empty]
  1. 返回 false。
ClassStaticBlockStatementList : [empty]
  1. 返回 false。
ModuleItemList : ModuleItemList ModuleItem
  1. 令 hasUndefinedLabels 为以 labelSet 为参数对 ModuleItemList 执行 ContainsUndefinedBreakTarget 的结果。
  2. 如果 hasUndefinedLabels 是 true,则返回 true。
  3. 返回以 labelSet 为参数对 ModuleItem 执行 ContainsUndefinedBreakTarget 的结果。
ModuleItem : ImportDeclaration ExportDeclaration
  1. 返回 false。

8.3.3 Static Semantics: ContainsUndefinedContinueTarget

语法制导操作 ContainsUndefinedContinueTarget,接收参数 iterationSet (列表 (元素:String)) 和 labelSet (列表 (元素:String));返回值:Boolean。 它按以下产生式分别定义:

Statement : VariableStatement EmptyStatement ExpressionStatement BreakStatement ReturnStatement ThrowStatement DebuggerStatement Block : { } StatementListItem : Declaration
  1. 返回 false。
Statement : BlockStatement
  1. 返回以 iterationSet 和 « » 为参数对 BlockStatement 执行 ContainsUndefinedContinueTarget 的结果。
BreakableStatement : IterationStatement
  1. 令 newIterationSet 为 iterationSet 和 labelSet 的列表连接。
  2. 返回以 newIterationSet 和 « » 为参数对 IterationStatement 执行 ContainsUndefinedContinueTarget 的结果。
StatementList : StatementList StatementListItem
  1. 令 hasUndefinedLabels 为以 iterationSet 和 « » 为参数对 StatementList 执行 ContainsUndefinedContinueTarget 的结果。
  2. 如果 hasUndefinedLabels 是 true,则返回 true。
  3. 返回以 iterationSet 和 « » 为参数对 StatementListItem 执行 ContainsUndefinedContinueTarget 的结果。
IfStatement : if ( Expression ) Statement else Statement
  1. 令 hasUndefinedLabels 为以 iterationSet 和 « » 为参数对第一个 Statement 执行 ContainsUndefinedContinueTarget 的结果。
  2. 如果 hasUndefinedLabels 是 true,则返回 true。
  3. 返回以 iterationSet 和 « » 为参数对第二个 Statement 执行 ContainsUndefinedContinueTarget 的结果。
IfStatement : if ( Expression ) Statement
  1. 返回以 iterationSet 和 « » 为参数对 Statement 执行 ContainsUndefinedContinueTarget 的结果。
DoWhileStatement : do Statement while ( Expression ) ;
  1. 返回以 iterationSet 和 « » 为参数对 Statement 执行 ContainsUndefinedContinueTarget 的结果。
WhileStatement : while ( Expression ) Statement
  1. 返回以 iterationSet 和 « » 为参数对 Statement 执行 ContainsUndefinedContinueTarget 的结果。
ForStatement : for ( Expressionopt ; Expressionopt ; Expressionopt ) Statement for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement for ( LexicalDeclaration Expressionopt ; Expressionopt ) Statement
  1. 返回以 iterationSet 和 « » 为参数对 Statement 执行 ContainsUndefinedContinueTarget 的结果。
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 和 « » 为参数对 Statement 执行 ContainsUndefinedContinueTarget 的结果。
注

本节由附录 B.3.5 扩展。

ContinueStatement : continue ;
  1. 返回 false。
ContinueStatement : continue LabelIdentifier ;
  1. 如果 iterationSet 包含 LabelIdentifier 的 StringValue,则返回 false。
  2. 返回 true。
WithStatement : with ( Expression ) Statement
  1. 返回以 iterationSet 和 « » 为参数对 Statement 执行 ContainsUndefinedContinueTarget 的结果。
SwitchStatement : switch ( Expression ) CaseBlock
  1. 返回以 iterationSet 和 « » 为参数对 CaseBlock 执行 ContainsUndefinedContinueTarget 的结果。
CaseBlock : { }
  1. 返回 false。
CaseBlock : { CaseClausesopt DefaultClause CaseClausesopt }
  1. 如果存在第一个 CaseClauses,则
    1. 如果以 iterationSet 和 « » 为参数对第一个 CaseClauses 执行 ContainsUndefinedContinueTarget 的结果是 true,则返回 true。
  2. 如果以 iterationSet 和 « » 为参数对 DefaultClause 执行 ContainsUndefinedContinueTarget 的结果是 true,则返回 true。
  3. 如果不存在第二个 CaseClauses,则返回 false。
  4. 返回以 iterationSet 和 « » 为参数对第二个 CaseClauses 执行 ContainsUndefinedContinueTarget 的结果。
CaseClauses : CaseClauses CaseClause
  1. 令 hasUndefinedLabels 为以 iterationSet 和 « » 为参数对 CaseClauses 执行 ContainsUndefinedContinueTarget 的结果。
  2. 如果 hasUndefinedLabels 是 true,则返回 true。
  3. 返回以 iterationSet 和 « » 为参数对 CaseClause 执行 ContainsUndefinedContinueTarget 的结果。
CaseClause : case Expression : StatementListopt
  1. 如果存在 StatementList,则返回以 iterationSet 和 « » 为参数对 StatementList 执行 ContainsUndefinedContinueTarget 的结果。
  2. 返回 false。
DefaultClause : default : StatementListopt
  1. 如果存在 StatementList,则返回以 iterationSet 和 « » 为参数对 StatementList 执行 ContainsUndefinedContinueTarget 的结果。
  2. 返回 false。
LabelledStatement : LabelIdentifier : LabelledItem
  1. 令 label 为 LabelIdentifier 的 StringValue。
  2. 令 newLabelSet 为 labelSet 与 « label » 的列表连接。
  3. 返回以 iterationSet 和 newLabelSet 为参数对 LabelledItem 执行 ContainsUndefinedContinueTarget 的结果。
LabelledItem : FunctionDeclaration
  1. 返回 false。
TryStatement : try Block Catch
  1. 令 hasUndefinedLabels 为以 iterationSet 和 « » 为参数对 Block 执行 ContainsUndefinedContinueTarget 的结果。
  2. 如果 hasUndefinedLabels 是 true,则返回 true。
  3. 返回以 iterationSet 和 « » 为参数对 Catch 执行 ContainsUndefinedContinueTarget 的结果。
TryStatement : try Block Finally
  1. 令 hasUndefinedLabels 为以 iterationSet 和 « » 为参数对 Block 执行 ContainsUndefinedContinueTarget 的结果。
  2. 如果 hasUndefinedLabels 是 true,则返回 true。
  3. 返回以 iterationSet 和 « » 为参数对 Finally 执行 ContainsUndefinedContinueTarget 的结果。
TryStatement : try Block Catch Finally
  1. 如果以 iterationSet 和 « » 为参数对 Block 执行 ContainsUndefinedContinueTarget 的结果是 true,则返回 true。
  2. 如果以 iterationSet 和 « » 为参数对 Catch 执行 ContainsUndefinedContinueTarget 的结果是 true,则返回 true。
  3. 返回以 iterationSet 和 « » 为参数对 Finally 执行 ContainsUndefinedContinueTarget 的结果。
Catch : catch ( CatchParameter ) Block
  1. 返回以 iterationSet 和 « » 为参数对 Block 执行 ContainsUndefinedContinueTarget 的结果。
FunctionStatementList : [empty]
  1. 返回 false。
ClassStaticBlockStatementList : [empty]
  1. 返回 false。
ModuleItemList : ModuleItemList ModuleItem
  1. 令 hasUndefinedLabels 为以 iterationSet 和 « » 为参数对 ModuleItemList 执行 ContainsUndefinedContinueTarget 的结果。
  2. 如果 hasUndefinedLabels 是 true,则返回 true。
  3. 返回以 iterationSet 和 « » 为参数对 ModuleItem 执行 ContainsUndefinedContinueTarget 的结果。
ModuleItem : ImportDeclaration ExportDeclaration
  1. 返回 false。

8.4 函数名称推断

8.4.1 Static Semantics: HasName

语法制导操作 HasName,接收无参数;返回值:Boolean。 它按以下产生式分别定义:

PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList
  1. 令 expr 为 CoverParenthesizedExpressionAndArrowParameterList 所覆盖的 ParenthesizedExpression。
  2. 如果 expr 的 IsFunctionDefinition 是 false,则返回 false。
  3. 返回 expr 的 HasName。
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

语法制导操作 IsFunctionDefinition,接收无参数;返回值:Boolean。 它按以下产生式分别定义:

PrimaryExpression : CoverParenthesizedExpressionAndArrowParameterList
  1. 令 expr 为 CoverParenthesizedExpressionAndArrowParameterList 所覆盖的 ParenthesizedExpression。
  2. 返回 expr 的 IsFunctionDefinition。
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 CoverAwaitExpressionAndAwaitUsingDeclarationHead 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 )

抽象操作 IsAnonymousFunctionDefinition,接收参数 expr ((an AssignmentExpression Parse Node、an Initializer Parse Node 或 an Expression Parse Node));返回值:Boolean。 它确定其参数是否为不绑定名称的函数定义。 调用时执行以下步骤:

  1. 如果 expr 的 IsFunctionDefinition 是 false,则返回 false。
  2. 令 hasName 为 expr 的 HasName。
  3. 如果 hasName 是 true,则返回 false。
  4. 返回 true。

8.4.4 Static Semantics: IsIdentifierRef

语法制导操作 IsIdentifierRef,接收无参数;返回值:Boolean。 它按以下产生式分别定义:

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

语法制导操作 NamedEvaluation,接收参数 name ((属性键 或 私有名称));返回值:(正常完成 (值:函数对象) 或 突兀完成)。 它按以下产生式分别定义:

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. 令 sourceText 为 ClassExpression 所匹配的源文本。
  2. 返回 ? 以 undefined、name 和 sourceText 为参数对 ClassTail 执行 ClassDefinitionEvaluation 的结果。

8.5 Contains

8.5.1 Static Semantics: Contains

语法制导操作 Contains,接收参数 symbol (语法符号);返回值:Boolean。

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

  1. 对此 Parse Node 的每个子节点 child,执行
    1. 如果 child 是 symbol 的实例,则返回 true。
    2. 如果 child 是某个非终结符的实例,则
      1. 令 contained 为 child Contains symbol 的结果。
      2. 如果 contained 是 true,则返回 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。
注 1

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

ClassTail : ClassHeritageopt { ClassBody }
  1. 如果 symbol 是 ClassBody,则返回 true。
  2. 如果 symbol 是 ClassHeritage,则
    1. 如果存在 ClassHeritage,则返回 true。
    2. 返回 false。
  3. 如果存在 ClassHeritage,则
    1. 如果 ClassHeritage Contains symbol 是 true,则返回 true。
  4. 返回以 symbol 为参数对 ClassBody 执行 ComputedPropertyContains 的结果。
注 2

依赖子结构的静态语义规则通常不会检查类主体内部,但 PropertyName 除外。

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

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

ArrowFunction : ArrowParameters => ConciseBody
  1. 如果 symbol 不是 NewTarget、SuperProperty、SuperCall、super 或 this 之一,则返回 false。
  2. 如果 ArrowParameters Contains symbol 是 true,则返回 true。
  3. 返回 ConciseBody Contains symbol。
ArrowParameters : CoverParenthesizedExpressionAndArrowParameterList
  1. 令 formals 为 CoverParenthesizedExpressionAndArrowParameterList 所覆盖的 ArrowFormalParameters。
  2. 返回 formals Contains symbol。
AsyncArrowFunction : async AsyncArrowBindingIdentifier => AsyncConciseBody
  1. 如果 symbol 不是 NewTarget、SuperProperty、SuperCall、super 或 this 之一,则返回 false。
  2. 返回 AsyncConciseBody Contains symbol。
AsyncArrowFunction : CoverCallExpressionAndAsyncArrowHead => AsyncConciseBody
  1. 如果 symbol 不是 NewTarget、SuperProperty、SuperCall、super 或 this 之一,则返回 false。
  2. 令 head 为 CoverCallExpressionAndAsyncArrowHead 所覆盖的 AsyncArrowHead。
  3. 如果 head Contains symbol 是 true,则返回 true。
  4. 返回 AsyncConciseBody Contains symbol。
注 4

Contains 用于检测 ArrowFunction 或 AsyncArrowFunction 中对 new.target、this 和 super 的使用。

PropertyDefinition : MethodDefinition
  1. 如果 symbol 是 MethodDefinition,则返回 true。
  2. 返回以 symbol 为参数对 MethodDefinition 执行 ComputedPropertyContains 的结果。
LiteralPropertyName : IdentifierName
  1. 返回 false。
MemberExpression : MemberExpression . IdentifierName
  1. 如果 MemberExpression Contains symbol 是 true,则返回 true。
  2. 返回 false。
SuperProperty : super . IdentifierName
  1. 如果 symbol 是 ReservedWord super,则返回 true。
  2. 返回 false。
CallExpression : CallExpression . IdentifierName
  1. 如果 CallExpression Contains symbol 是 true,则返回 true。
  2. 返回 false。
OptionalChain : ?. IdentifierName
  1. 返回 false。
OptionalChain : OptionalChain . IdentifierName
  1. 如果 OptionalChain Contains symbol 是 true,则返回 true。
  2. 返回 false。

8.5.2 Static Semantics: ComputedPropertyContains

语法制导操作 ComputedPropertyContains,接收参数 symbol (语法符号);返回值:Boolean。 它按以下产生式分别定义:

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. 如果 inList 是 true,则返回 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

语法制导操作 InstantiateFunctionObject,接收参数 envRecord (Environment 记录) 和 privateEnv ((PrivateEnvironment 记录 或 null));返回值:ECMAScript 函数对象。 它按以下产生式分别定义:

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

8.6.2 Runtime Semantics: BindingInitialization

语法制导操作 BindingInitialization,接收参数 value (ECMAScript 语言值) 和 envRecord ((Environment 记录 或 undefined));返回值:(正常完成 (值:unused) 或 突兀完成)。

注

为 envRecord 传递 undefined 表示应使用 PutValue 操作来赋予初始化值。对于 var 语句和某些非严格函数的形式参数列表就是这种情况(参见 10.2.11)。在这些情况下,词法绑定会在对其初始化器求值之前被提升并预先初始化。

它按以下产生式分别定义:

BindingIdentifier : Identifier
  1. 令 name 为 Identifier 的 StringValue。
  2. 返回 ? InitializeBoundName(name, value, envRecord)。
BindingIdentifier : yield
  1. 返回 ? InitializeBoundName("yield", value, envRecord)。
BindingIdentifier : await
  1. 返回 ? InitializeBoundName("await", value, envRecord)。
BindingPattern : ObjectBindingPattern
  1. 执行 ? RequireObjectCoercible(value)。
  2. 返回 ? 以 value 和 envRecord 为参数对 ObjectBindingPattern 执行 BindingInitialization 的结果。
BindingPattern : ArrayBindingPattern
  1. 令 iteratorRecord 为 ? GetIterator(value, sync)。
  2. 令 result 为 Completion(以 iteratorRecord 和 envRecord 为参数对 ArrayBindingPattern 执行 IteratorBindingInitialization 的结果)。
  3. 如果 iteratorRecord.[[Done]] 是 false,则返回 ? IteratorClose(iteratorRecord, result)。
  4. 返回 ? result。
ObjectBindingPattern : { }
  1. 返回 unused。
ObjectBindingPattern : { BindingPropertyList ,opt }
  1. 执行 ? 以 value 和 envRecord 为参数对 BindingPropertyList 执行 PropertyBindingInitialization。
  2. 返回 unused。
ObjectBindingPattern : { BindingRestProperty }
  1. 令 excludedNames 为新的空 List。
  2. 返回 ? 以 value、envRecord 和 excludedNames 为参数对 BindingRestProperty 执行 RestBindingInitialization 的结果。
ObjectBindingPattern : { BindingPropertyList , BindingRestProperty }
  1. 令 excludedNames 为 ? 以 value 和 envRecord 为参数对 BindingPropertyList 执行 PropertyBindingInitialization 的结果。
  2. 返回 ? 以 value、envRecord 和 excludedNames 为参数对 BindingRestProperty 执行 RestBindingInitialization 的结果。

8.6.2.1 InitializeBoundName ( name, value, envRecord )

抽象操作 InitializeBoundName,接收参数 name (String)、value (ECMAScript 语言值) 和 envRecord ((Environment 记录 或 undefined));返回值:(正常完成 (值:unused) 或 突兀完成)。 调用时执行以下步骤:

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

8.6.3 Runtime Semantics: IteratorBindingInitialization

语法制导操作 IteratorBindingInitialization,接收参数 iteratorRecord (Iterator 记录) 和 envRecord ((Environment 记录 或 undefined));返回值:(正常完成 (值:unused) 或 突兀完成)。

注

当为 envRecord 传递 undefined 时,表示应使用 PutValue 操作来赋予初始化值。非严格函数的形式参数列表就是这种情况。在这种情况下,会预先初始化形式参数绑定,以处理存在多个同名参数的可能性。

它按以下产生式分别定义:

ArrayBindingPattern : [ ]
  1. 返回 unused。
ArrayBindingPattern : [ Elision ]
  1. 返回 ? 以 iteratorRecord 为参数对 Elision 执行 IteratorDestructuringAssignmentEvaluation 的结果。
ArrayBindingPattern : [ Elisionopt BindingRestElement ]
  1. 如果存在 Elision,则
    1. 执行 ? 以 iteratorRecord 为参数对 Elision 执行 IteratorDestructuringAssignmentEvaluation。
  2. 返回 ? 以 iteratorRecord 和 envRecord 为参数对 BindingRestElement 执行 IteratorBindingInitialization 的结果。
ArrayBindingPattern : [ BindingElementList , Elision ]
  1. 执行 ? 以 iteratorRecord 和 envRecord 为参数对 BindingElementList 执行 IteratorBindingInitialization。
  2. 返回 ? 以 iteratorRecord 为参数对 Elision 执行 IteratorDestructuringAssignmentEvaluation 的结果。
ArrayBindingPattern : [ BindingElementList , Elisionopt BindingRestElement ]
  1. 执行 ? 以 iteratorRecord 和 envRecord 为参数对 BindingElementList 执行 IteratorBindingInitialization。
  2. 如果存在 Elision,则
    1. 执行 ? 以 iteratorRecord 为参数对 Elision 执行 IteratorDestructuringAssignmentEvaluation。
  3. 返回 ? 以 iteratorRecord 和 envRecord 为参数对 BindingRestElement 执行 IteratorBindingInitialization 的结果。
BindingElementList : BindingElementList , BindingElisionElement
  1. 执行 ? 以 iteratorRecord 和 envRecord 为参数对 BindingElementList 执行 IteratorBindingInitialization。
  2. 返回 ? 以 iteratorRecord 和 envRecord 为参数对 BindingElisionElement 执行 IteratorBindingInitialization 的结果。
BindingElisionElement : Elision BindingElement
  1. 执行 ? 以 iteratorRecord 为参数对 Elision 执行 IteratorDestructuringAssignmentEvaluation。
  2. 返回 ? 以 iteratorRecord 和 envRecord 为参数对 BindingElement 执行 IteratorBindingInitialization 的结果。
SingleNameBinding : BindingIdentifier Initializeropt
  1. 令 name 为 BindingIdentifier 的 StringValue。
  2. 令 lhs 为 ? ResolveBinding(name, envRecord)。
  3. 令 value 为 undefined。
  4. 如果 iteratorRecord.[[Done]] 是 false,则
    1. 令 next 为 ? IteratorStepValue(iteratorRecord)。
    2. 如果 next 不是 done,则
      1. 将 value 设置为 next。
  5. 如果存在 Initializer 且 value 是 undefined,则
    1. 如果 IsAnonymousFunctionDefinition(Initializer) 是 true,则
      1. 将 value 设置为 ? 以 name 为参数对 Initializer 执行 NamedEvaluation 的结果。
    2. 否则,
      1. 令 defaultValue 为 ? Initializer 的 Evaluation。
      2. 将 value 设置为 ? GetValue(defaultValue)。
  6. 如果 envRecord 是 undefined,则返回 ? PutValue(lhs, value)。
  7. 返回 ? InitializeReferencedBinding(lhs, value)。
BindingElement : BindingPattern Initializeropt
  1. 令 value 为 undefined。
  2. 如果 iteratorRecord.[[Done]] 是 false,则
    1. 令 next 为 ? IteratorStepValue(iteratorRecord)。
    2. 如果 next 不是 done,则
      1. 将 value 设置为 next。
  3. 如果存在 Initializer 且 value 是 undefined,则
    1. 令 defaultValue 为 ? Initializer 的 Evaluation。
    2. 将 value 设置为 ? GetValue(defaultValue)。
  4. 返回 ? 以 value 和 envRecord 为参数对 BindingPattern 执行 BindingInitialization 的结果。
BindingRestElement : ... BindingIdentifier
  1. 令 lhs 为 ? ResolveBinding(BindingIdentifier 的 StringValue, envRecord)。
  2. 令 array 为 ! ArrayCreate(0)。
  3. 令 n 为 0。
  4. 重复执行,
    1. 令 next 为 done。
    2. 如果 iteratorRecord.[[Done]] 是 false,则
      1. 将 next 设置为 ? IteratorStepValue(iteratorRecord)。
    3. 如果 next 是 done,则
      1. 如果 envRecord 是 undefined,则返回 ? 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. 令 next 为 done。
    2. 如果 iteratorRecord.[[Done]] 是 false,则
      1. 将 next 设置为 ? IteratorStepValue(iteratorRecord)。
    3. 如果 next 是 done,则
      1. 返回 ? 以 array 和 envRecord 为参数对 BindingPattern 执行 BindingInitialization 的结果。
    4. 执行 ! CreateDataPropertyOrThrow(array, ! ToString(𝔽(n)), next)。
    5. 将 n 设置为 n + 1。
FormalParameters : [empty]
  1. 返回 unused。
FormalParameters : FormalParameterList , FunctionRestParameter
  1. 执行 ? 以 iteratorRecord 和 envRecord 为参数对 FormalParameterList 执行 IteratorBindingInitialization。
  2. 返回 ? 以 iteratorRecord 和 envRecord 为参数对 FunctionRestParameter 执行 IteratorBindingInitialization 的结果。
FormalParameterList : FormalParameterList , FormalParameter
  1. 执行 ? 以 iteratorRecord 和 envRecord 为参数对 FormalParameterList 执行 IteratorBindingInitialization。
  2. 返回 ? 以 iteratorRecord 和 envRecord 为参数对 FormalParameter 执行 IteratorBindingInitialization 的结果。
ArrowParameters : BindingIdentifier
  1. 令 value 为 undefined。
  2. 断言:iteratorRecord.[[Done]] 是 false。
  3. 令 next 为 ? IteratorStepValue(iteratorRecord)。
  4. 如果 next 不是 done,则
    1. 将 value 设置为 next。
  5. 返回 ? 以 value 和 envRecord 为参数对 BindingIdentifier 执行 BindingInitialization 的结果。
ArrowParameters : CoverParenthesizedExpressionAndArrowParameterList
  1. 令 formals 为 CoverParenthesizedExpressionAndArrowParameterList 所覆盖的 ArrowFormalParameters。
  2. 返回 ? 以 iteratorRecord 和 envRecord 为参数对 formals 执行 IteratorBindingInitialization 的结果。
AsyncArrowBindingIdentifier : BindingIdentifier
  1. 令 value 为 undefined。
  2. 断言:iteratorRecord.[[Done]] 是 false。
  3. 令 next 为 ? IteratorStepValue(iteratorRecord)。
  4. 如果 next 不是 done,则
    1. 将 value 设置为 next。
  5. 返回 ? 以 value 和 envRecord 为参数对 BindingIdentifier 执行 BindingInitialization 的结果。

8.6.4 Static Semantics: AssignmentTargetType

语法制导操作 AssignmentTargetType,接收无参数;返回值:(simple、web-compat 或 invalid)。 它按以下产生式分别定义:

IdentifierReference : Identifier
  1. 如果 IsStrict(this IdentifierReference) 是 true,并且 Identifier 的 StringValue 是 "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. 返回 expr 的 AssignmentTargetType。
CallExpression : CoverCallExpressionAndAsyncArrowHead CallExpression Arguments
  1. Normative Optional
    如果宿主是 Web 浏览器或以其他方式支持 函数调用赋值目标的运行时错误,并且 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 CoverAwaitExpressionAndAwaitUsingDeclarationHead 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

语法制导操作 PropName,接收无参数;返回值:(String 或 empty)。 它按以下产生式分别定义:

PropertyDefinition : IdentifierReference
  1. 返回 IdentifierReference 的 StringValue。
PropertyDefinition : ... AssignmentExpression
  1. 返回 empty。
PropertyDefinition : PropertyName : AssignmentExpression
  1. 返回 PropertyName 的 PropName。
LiteralPropertyName : IdentifierName AttributeKey : IdentifierName
  1. 返回 IdentifierName 的 StringValue。
LiteralPropertyName : StringLiteral AttributeKey : StringLiteral
  1. 返回 StringLiteral 的 SV。
LiteralPropertyName : NumericLiteral
  1. 令 number 为 NumericLiteral 的 NumericValue。
  2. 返回 ! ToString(number)。
ComputedPropertyName : [ AssignmentExpression ]
  1. 返回 empty。
MethodDefinition : ClassElementName ( UniqueFormalParameters ) { FunctionBody } get ClassElementName ( ) { FunctionBody } set ClassElementName ( PropertySetParameterList ) { FunctionBody }
  1. 返回 ClassElementName 的 PropName。
GeneratorMethod : * ClassElementName ( UniqueFormalParameters ) { GeneratorBody }
  1. 返回 ClassElementName 的 PropName。
AsyncGeneratorMethod : async * ClassElementName ( UniqueFormalParameters ) { AsyncGeneratorBody }
  1. 返回 ClassElementName 的 PropName。
ClassElement : ClassStaticBlock
  1. 返回 empty。
ClassElement : ;
  1. 返回 empty。
AsyncMethod : async ClassElementName ( UniqueFormalParameters ) { AsyncFunctionBody }
  1. 返回 ClassElementName 的 PropName。
FieldDefinition : ClassElementName Initializeropt
  1. 返回 ClassElementName 的 PropName。
ClassElementName : PrivateIdentifier
  1. 返回 empty。

8.6.6 Static Semantics: ContainsUsing

语法制导操作 ContainsUsing,接收无参数;返回值:Boolean。 它按以下产生式分别定义:

StatementList : StatementList StatementListItem
  1. 如果派生的 StatementList 的 ContainsUsing 是 true,则返回 true。
  2. 如果 StatementListItem 的 ContainsUsing 是 true,则返回 true。
  3. 返回 false。
StatementListItem : Statement
  1. 返回 false。
StatementListItem : Declaration
  1. 如果 Declaration 的 IsUsingDeclaration 是 true,则返回 true。
  2. 如果 Declaration 的 IsAwaitUsingDeclaration 是 true,则返回 true。
  3. 返回 false。