Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

重学js —— modules:Exports #94

Open
lizhongzhen11 opened this issue Mar 25, 2020 · 0 comments
Open

重学js —— modules:Exports #94

lizhongzhen11 opened this issue Mar 25, 2020 · 0 comments
Labels
js基础 Good for newcomers 重学js 重学js系列 规范+MDN

Comments

@lizhongzhen11
Copy link
Owner

modules:Exports

ExportedBindings

ExportDeclaration :

  export ExportFromClause FromClause

  1. 返回一个新的空 List

ExportDeclaration : export NamedExports

  1. 返回 NamedExportsExportedBindings

ExportDeclaration : export VariableStatement

  1. 返回 VariableStatementBoundNames

ExportDeclaration : export Declaration

  1. 返回 DeclarationBoundNames

ExportDeclaration : export default HoistableDeclaration

ExportDeclaration : export default ClassDeclaration

ExportDeclaration : export default AssignmentExpression

  1. 返回 ExportDeclarationBoundNames

NamedExports : { }

  1. 返回一个新的空 List

ExportsList : ExportsList , ExportSpecifier

  1. 定义 namesExportsList ExportedBindings
  2. ExportSpecifier ExportedBindings 加入到 names
  3. 返回 names

ExportSpecifier : IdentifierName

  1. 返回一个包含 IdentifierName 字符串值的 List

ExportSpecifier : IdentifierName as IdentifierName

  1. 返回一条包含第一个 IdentifierName 字符串值的 List

ExportedNames

ExportDeclaration : export ExportFromClause FromClause

  1. 返回 ExportFromClauseExportedNames

ExportFromClause : *

  1. 返回一个新的空 List

ExportFromClause : * as IdentifierName

  1. 返回一个包含 IdentifierName 字符串值的 List

ExportFromClause : NamedExports

  1. 返回 NamedExportsExportedNames

ExportDeclaration : export VariableStatement

  1. 返回 VariableStatementBoundNames

ExportDeclaration : export Declaration

  1. 返回 DeclarationBoundNames

ExportDeclaration : export default HoistableDeclaration

ExportDeclaration : export default ClassDeclaration

ExportDeclaration : export default AssignmentExpression

  1. 返回 « "default" »

NamedExports : { }

  1. 返回一个新的空 List

ExportsList : ExportsList , ExportSpecifier

  1. 定义 namesExportsListExportedNames
  2. ExportSpecifierExportedNames 中元素加入到 names
  3. 返回 names

ExportSpecifier : IdentifierName

  1. 返回一个包含 IdentifierName 字符串值的 List

ExportSpecifier : IdentifierName as IdentifierName

  1. 返回一条包含 第二IdentifierName 字符串值的 List

ExportEntries

ExportDeclaration : export ExportFromClause FromClause

  1. 定义 moduleFromClauseModuleRequests 的唯一元素
  2. 返回 ExportFromClauseExportEntriesForModule,参数为 module

ExportDeclaration : export NamedExports

  1. 返回 NamedExportsExportEntriesForModule,参数为 null

ExportDeclaration : export VariableStatement

  1. 定义 entries 为一个新的空 List
  2. 定义 namesVariableStatementBoundNames
  3. 遍历 names 中的 name
    1. ExportEntry Record { [[ModuleRequest]]: null, [[ImportName]]: null, [[LocalName]]: name, [[ExportName]]: name } 添加到 entries
  4. 返回 entries

ExportDeclaration : export Declaration

  1. 定义 entries 为一个新的空 List
  2. 定义 namesDeclarationBoundNames
  3. 遍历 names 中的 name
    1. ExportEntry Record { [[ModuleRequest]]: null, [[ImportName]]: null, [[LocalName]]: name, [[ExportName]]: name } 添加到 entries
  4. 返回 entries

ExportDeclaration : export default HoistableDeclaration

  1. 定义 namesHoistableDeclarationBoundNames
  2. 定义 localNamenames 的唯一元素
  3. 返回一个包含 ExportEntry Record { [[ModuleRequest]]: null, [[ImportName]]: null, [[LocalName]]: localName, [[ExportName]]: "default" } 的 List

ExportDeclaration : export default ClassDeclaration

  1. 定义 namesClassDeclarationBoundNames
  2. 定义 localNamenames 的唯一元素
  3. 返回一个包含 ExportEntry Record { [[ModuleRequest]]: null, [[ImportName]]: null, [[LocalName]]: localName, [[ExportName]]: "default" } 的 List

ExportDeclaration : export default AssignmentExpression

  1. 定义 entryExportEntry Record { [[ModuleRequest]]: null, [[ImportName]]: null, [[LocalName]]: "*default*", [[ExportName]]: "default" }
  2. 返回一个包含 entryList

ModuleRequests

ExportDeclaration : export ExportFromClause FromClause

  1. 返回 FromClauseModuleRequests

ExportDeclaration :

  export NamedExports;

  export VariableStatement

  export Declaration

  export default HoistableDeclaration

  export default ClassDeclaration

  export default AssignmentExpression;

  1. 返回一个新的空 List

求值

ExportDeclaration :

  export ExportFromClause FromClause

  export NamedExports

// 很多,举例
export *
export * as all
// ...
  1. 返回 NormalCompletion(empty)

ExportDeclaration : export VariableStatement

export var name;
  1. 返回 VariableStatement 求值 结果

ExportDeclaration : export Declaration

// 很多,这里举例
export let name
  1. 返回 Declaration 求值结果

ExportDeclaration : export default HoistableDeclaration

// 很多,这里举例
export default function fn(){}
  1. 返回 HoistableDeclaration 求值结果

ExportDeclaration : export default ClassDeclaration

export default class T{}
  1. 定义 valueClassDeclaration? BindingClassDeclarationEvaluation
  2. 定义 classNameClassDeclarationBoundNames 的唯一元素
  3. 如果 className"*default*",
    1. 定义 env运行时执行上下文词法环境
    2. 执行 ? InitializeBoundName("*default*", value, env)
  4. 返回 NormalCompletion(empty)

ExportDeclaration : export default AssignmentExpression

// 很多,举例
export default num = 1;
  1. 如果 AssignmentExpression 是匿名函数,
    1. 定义 valueAssignmentExpression 的 NamedEvaluation,参数为 "default"
  2. 否则,
    1. 定义 rhsAssignmentExpression 求值 结果
    2. 定义 value? GetValue(rhs)
  3. 定义 env运行时执行上下文词法环境
  4. 执行 ? InitializeBoundName("*default*", value, env)
  5. 返回 NormalCompletion(empty)
@lizhongzhen11 lizhongzhen11 added js基础 Good for newcomers 重学js 重学js系列 规范+MDN labels Mar 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
js基础 Good for newcomers 重学js 重学js系列 规范+MDN
Projects
None yet
Development

No branches or pull requests

1 participant