Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(124)

Unified Diff: src/api.cc

Issue 2353403003: [modules] Support exporting a local variable under multiple export names. (Closed)
Patch Set: Comments Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/ast/modules.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index 713ae93fabd85f071605011e6809d792cf1b299b..1407b2792bc899d3615d80a6f4175e6bdddb25a4 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -1949,19 +1949,13 @@ bool Module::Instantiate(Local<Context> v8_context,
self->requested_modules()->set(i, *Utils::OpenHandle(*import));
}
- // TODO(neis): This will create multiple cells for the same local variable if
- // exported under multiple names, which is wrong but cannot be observed at the
- // moment. This will be fixed by doing the full-fledged linking here once we
- // get there.
+ // Set up local exports.
i::Handle<i::FixedArray> regular_exports = i::handle(
shared->scope_info()->ModuleDescriptorInfo()->regular_exports(), isolate);
- for (int i = 0, length = regular_exports->length(); i < length; ++i) {
- i::Handle<i::ModuleInfoEntry> entry =
- i::handle(i::ModuleInfoEntry::cast(regular_exports->get(i)), isolate);
- DCHECK(entry->import_name()->IsUndefined(isolate));
- i::Handle<i::String> export_name =
- handle(i::String::cast(entry->export_name()), isolate);
- i::Module::CreateExport(self, export_name);
+ for (int i = 0, n = regular_exports->length(); i < n; i += 2) {
+ i::Handle<i::FixedArray> export_names(
+ i::FixedArray::cast(regular_exports->get(i + 1)), isolate);
+ i::Module::CreateExport(self, export_names);
}
return true;
@@ -2124,8 +2118,7 @@ MaybeLocal<Module> ScriptCompiler::CompileModule(Isolate* isolate,
if (!maybe.ToLocal(&unbound)) return MaybeLocal<Module>();
i::Handle<i::SharedFunctionInfo> shared = Utils::OpenHandle(*unbound);
- i::Handle<i::Module> module = i_isolate->factory()->NewModule(shared);
- return ToApiHandle<Module>(module);
+ return ToApiHandle<Module>(i_isolate->factory()->NewModule(shared));
}
« no previous file with comments | « no previous file | src/ast/modules.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698