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

Unified Diff: src/ast/modules.h

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 | « no previous file | src/ast/modules.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ast/modules.h
diff --git a/src/ast/modules.h b/src/ast/modules.h
index 4c63df9dfad2569125bb34b3fa309c0f03f0430b..5f63fce26955249ef7303f6b1e037ade1efa29d7 100644
--- a/src/ast/modules.h
+++ b/src/ast/modules.h
@@ -63,9 +63,9 @@ class ModuleDescriptor : public ZoneObject {
Zone* zone);
// Check if module is well-formed and report error if not.
+ // Also canonicalize indirect exports.
bool Validate(DeclarationScope* module_scope,
- PendingCompilationErrorHandler* error_handler,
- Zone* zone) const;
+ PendingCompilationErrorHandler* error_handler, Zone* zone);
struct ModuleEntry : public ZoneObject {
const Scanner::Location location;
@@ -82,7 +82,7 @@ class ModuleDescriptor : public ZoneObject {
module_request(nullptr) {}
};
- const ZoneList<const ModuleEntry*>& exports() const { return exports_; }
+ const ZoneList<ModuleEntry*>& exports() const { return exports_; }
// Empty imports and namespace imports.
const ZoneList<const ModuleEntry*>& special_imports() const {
@@ -96,9 +96,27 @@ class ModuleDescriptor : public ZoneObject {
}
private:
- ZoneList<const ModuleEntry*> exports_;
+ ZoneList<ModuleEntry*> exports_;
ZoneList<const ModuleEntry*> special_imports_;
ZoneMap<const AstRawString*, const ModuleEntry*> regular_imports_;
+
+ // Find any implicitly indirect exports and make them explicit.
+ //
+ // An explicitly indirect export is an export entry arising from an export
+ // statement of the following form:
+ // export {a as c} from "X";
+ // An implicitly indirect export corresponds to
+ // export {b as c};
+ // in the presence of an import statement of the form
+ // import {a as b} from "X";
+ // This function finds such implicitly indirect export entries and rewrites
+ // them by filling in the import name and module request, as well as nulling
+ // out the local name. Effectively, it turns
+ // import {a as b} from "X"; export {b as c};
+ // into:
+ // import {a as b} from "X"; export {a as c} from "X";
+ // (The import entry is never deleted.)
+ void MakeIndirectExportsExplicit();
};
} // namespace internal
« no previous file with comments | « no previous file | src/ast/modules.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698