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 |