mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-22 07:07:30 +09:00
Bug 1341411 - Support circular module dependencies through export* per ES2017
This commit is contained in:
parent
832b047eea
commit
39a2b217b7
7 changed files with 26 additions and 19 deletions
|
|
@ -65,12 +65,12 @@ function ModuleGetExportedNames(exportStarSet = [])
|
||||||
return exportedNames;
|
return exportedNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 15.2.1.16.3 ResolveExport(exportName, resolveSet, exportStarSet)
|
// 15.2.1.16.3 ResolveExport(exportName, resolveSet)
|
||||||
function ModuleResolveExport(exportName, resolveSet = [], exportStarSet = [])
|
function ModuleResolveExport(exportName, resolveSet = [])
|
||||||
{
|
{
|
||||||
if (!IsObject(this) || !IsModule(this)) {
|
if (!IsObject(this) || !IsModule(this)) {
|
||||||
return callFunction(CallModuleMethodIfWrapped, this, exportName, resolveSet,
|
return callFunction(CallModuleMethodIfWrapped, this, exportName, resolveSet,
|
||||||
exportStarSet, "ModuleResolveExport");
|
"ModuleResolveExport");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 1
|
// Step 1
|
||||||
|
|
@ -101,37 +101,28 @@ function ModuleResolveExport(exportName, resolveSet = [], exportStarSet = [])
|
||||||
if (exportName === e.exportName) {
|
if (exportName === e.exportName) {
|
||||||
let importedModule = CallModuleResolveHook(module, e.moduleRequest,
|
let importedModule = CallModuleResolveHook(module, e.moduleRequest,
|
||||||
MODULE_STATE_INSTANTIATED);
|
MODULE_STATE_INSTANTIATED);
|
||||||
let indirectResolution = callFunction(importedModule.resolveExport, importedModule,
|
return callFunction(importedModule.resolveExport, importedModule, e.importName,
|
||||||
e.importName, resolveSet, exportStarSet);
|
resolveSet);
|
||||||
if (indirectResolution !== null)
|
|
||||||
return indirectResolution;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 6
|
// Step 6
|
||||||
if (exportName === "default") {
|
if (exportName === "default") {
|
||||||
// A default export cannot be provided by an export *.
|
// A default export cannot be provided by an export *.
|
||||||
ThrowSyntaxError(JSMSG_BAD_DEFAULT_EXPORT);
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 7
|
// Step 7
|
||||||
if (callFunction(ArrayIncludes, exportStarSet, module))
|
|
||||||
return null;
|
|
||||||
|
|
||||||
// Step 8
|
|
||||||
_DefineDataProperty(exportStarSet, exportStarSet.length, module);
|
|
||||||
|
|
||||||
// Step 9
|
|
||||||
let starResolution = null;
|
let starResolution = null;
|
||||||
|
|
||||||
// Step 10
|
// Step 8
|
||||||
let starExportEntries = module.starExportEntries;
|
let starExportEntries = module.starExportEntries;
|
||||||
for (let i = 0; i < starExportEntries.length; i++) {
|
for (let i = 0; i < starExportEntries.length; i++) {
|
||||||
let e = starExportEntries[i];
|
let e = starExportEntries[i];
|
||||||
let importedModule = CallModuleResolveHook(module, e.moduleRequest,
|
let importedModule = CallModuleResolveHook(module, e.moduleRequest,
|
||||||
MODULE_STATE_INSTANTIATED);
|
MODULE_STATE_INSTANTIATED);
|
||||||
let resolution = callFunction(importedModule.resolveExport, importedModule,
|
let resolution = callFunction(importedModule.resolveExport, importedModule,
|
||||||
exportName, resolveSet, exportStarSet);
|
exportName, resolveSet);
|
||||||
if (resolution === "ambiguous")
|
if (resolution === "ambiguous")
|
||||||
return resolution;
|
return resolution;
|
||||||
|
|
||||||
|
|
@ -148,6 +139,7 @@ function ModuleResolveExport(exportName, resolveSet = [], exportStarSet = [])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Step 9
|
||||||
return starResolution;
|
return starResolution;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -279,7 +271,7 @@ function ModuleDeclarationInstantiation()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 16.iv
|
// Step 17.a.iii
|
||||||
InstantiateModuleFunctionDeclarations(module);
|
InstantiateModuleFunctionDeclarations(module);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
RecordInstantationFailure(module);
|
RecordInstantationFailure(module);
|
||||||
|
|
|
||||||
|
|
@ -994,7 +994,7 @@ GlobalObject::initModuleProto(JSContext* cx, Handle<GlobalObject*> global)
|
||||||
|
|
||||||
static const JSFunctionSpec protoFunctions[] = {
|
static const JSFunctionSpec protoFunctions[] = {
|
||||||
JS_SELF_HOSTED_FN("getExportedNames", "ModuleGetExportedNames", 1, 0),
|
JS_SELF_HOSTED_FN("getExportedNames", "ModuleGetExportedNames", 1, 0),
|
||||||
JS_SELF_HOSTED_FN("resolveExport", "ModuleResolveExport", 3, 0),
|
JS_SELF_HOSTED_FN("resolveExport", "ModuleResolveExport", 2, 0),
|
||||||
JS_SELF_HOSTED_FN("declarationInstantiation", "ModuleDeclarationInstantiation", 0, 0),
|
JS_SELF_HOSTED_FN("declarationInstantiation", "ModuleDeclarationInstantiation", 0, 0),
|
||||||
JS_SELF_HOSTED_FN("evaluation", "ModuleEvaluation", 0, 0),
|
JS_SELF_HOSTED_FN("evaluation", "ModuleEvaluation", 0, 0),
|
||||||
JS_FS_END
|
JS_FS_END
|
||||||
|
|
|
||||||
1
js/src/jit-test/modules/empty.js
Normal file
1
js/src/jit-test/modules/empty.js
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
// Intentionally empty.
|
||||||
1
js/src/jit-test/modules/export-star-circular-1.js
Normal file
1
js/src/jit-test/modules/export-star-circular-1.js
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
export* from "export-star-circular-2.js";
|
||||||
3
js/src/jit-test/modules/export-star-circular-2.js
Normal file
3
js/src/jit-test/modules/export-star-circular-2.js
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
export {y as x} from "export-star-circular-1.js";
|
||||||
|
|
||||||
|
export var y = "pass";
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
// |jit-test| module; error:SyntaxError
|
||||||
|
|
||||||
|
export { a } from "empty.js";
|
||||||
|
export* from "module1.js";
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
// |jit-test| module
|
||||||
|
|
||||||
|
import { x, y } from "export-star-circular-1.js";
|
||||||
|
|
||||||
|
assertEq(x, "pass");
|
||||||
|
assertEq(y, "pass");
|
||||||
Loading…
Add table
Add a link
Reference in a new issue