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

Unified Diff: src/ast/modules.cc

Issue 2223893004: [modules] Detect all indirect exports and represent them as such. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@modules-imports
Patch Set: Move call into Validate Created 4 years, 4 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 | « src/ast/modules.h ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ast/modules.cc
diff --git a/src/ast/modules.cc b/src/ast/modules.cc
index 3a1f2e4b7b57a3c7a4d3055ee7d7e9ff2777a90e..a5ef69e1bbfdb6a45a86d14680ffcb3b336b26b1 100644
--- a/src/ast/modules.cc
+++ b/src/ast/modules.cc
@@ -80,9 +80,26 @@ void ModuleDescriptor::AddStarExport(
exports_.Add(entry, zone);
}
+void ModuleDescriptor::MakeIndirectExportsExplicit() {
+ for (auto entry : exports_) {
+ if (entry->export_name == nullptr) continue;
+ if (entry->import_name != nullptr) continue;
+ DCHECK_NOT_NULL(entry->local_name);
+ auto it = regular_imports_.find(entry->local_name);
+ if (it != regular_imports_.end()) {
+ // Found an indirect export.
+ DCHECK_NOT_NULL(it->second->module_request);
+ DCHECK_NOT_NULL(it->second->import_name);
+ entry->import_name = it->second->import_name;
+ entry->module_request = it->second->module_request;
+ entry->local_name = nullptr;
+ }
+ }
+}
+
bool ModuleDescriptor::Validate(DeclarationScope* module_scope,
PendingCompilationErrorHandler* error_handler,
- Zone* zone) const {
+ Zone* zone) {
DCHECK(module_scope->is_module_scope());
DCHECK_EQ(this, module_scope->module());
DCHECK_NOT_NULL(error_handler);
@@ -120,6 +137,7 @@ bool ModuleDescriptor::Validate(DeclarationScope* module_scope,
}
}
+ MakeIndirectExportsExplicit();
return true;
}
« no previous file with comments | « src/ast/modules.h ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698