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

Unified Diff: src/ast/modules.h

Issue 2460233003: [modules] Assign cell indices at validation time. (Closed)
Patch Set: Rebase Created 4 years, 1 month 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 dcb5132bd59fa5a1d6eb9ab372429389de6aaef4..37a82224c20dc1fada95f4c455ec495ef97ec259 100644
--- a/src/ast/modules.h
+++ b/src/ast/modules.h
@@ -77,19 +77,28 @@ class ModuleDescriptor : public ZoneObject {
const AstRawString* export_name;
const AstRawString* local_name;
const AstRawString* import_name;
+
// The module_request value records the order in which modules are
// requested. It also functions as an index into the ModuleInfo's array of
// module specifiers and into the Module's array of requested modules. A
// negative value means no module request.
int module_request;
+ // Import/export entries that are associated with a MODULE-allocated
+ // variable use the cell_index value to encode the location of their cell.
+ // Negative values are used for imports and positive values for exports.
+ // For entries that are not associated with a MODULE-allocated variable,
+ // cell_index is 0.
+ int cell_index;
+
// TODO(neis): Remove local_name component?
explicit Entry(Scanner::Location loc)
: location(loc),
export_name(nullptr),
local_name(nullptr),
import_name(nullptr),
- module_request(-1) {}
+ module_request(-1),
+ cell_index(0) {}
// (De-)serialization support.
// Note that the location value is not preserved as it's only needed by the
@@ -110,7 +119,7 @@ class ModuleDescriptor : public ZoneObject {
}
// All the remaining imports, indexed by local name.
- const ZoneMap<const AstRawString*, const Entry*>& regular_imports() const {
+ const ZoneMap<const AstRawString*, Entry*>& regular_imports() const {
return regular_imports_;
}
@@ -139,7 +148,7 @@ class ModuleDescriptor : public ZoneObject {
special_exports_.Add(entry, zone);
}
- void AddRegularImport(const Entry* entry) {
+ void AddRegularImport(Entry* entry) {
DCHECK_NOT_NULL(entry->import_name);
DCHECK_NOT_NULL(entry->local_name);
DCHECK_NULL(entry->export_name);
@@ -168,7 +177,7 @@ class ModuleDescriptor : public ZoneObject {
ZoneList<const Entry*> special_exports_;
ZoneList<const Entry*> namespace_imports_;
ZoneMultimap<const AstRawString*, Entry*> regular_exports_;
- ZoneMap<const AstRawString*, const Entry*> regular_imports_;
+ ZoneMap<const AstRawString*, Entry*> regular_imports_;
// If there are multiple export entries with the same export name, return the
// last of them (in source order). Otherwise return nullptr.
@@ -192,6 +201,11 @@ class ModuleDescriptor : public ZoneObject {
// (The import entry is never deleted.)
void MakeIndirectExportsExplicit(Zone* zone);
+ // Assign a cell_index of -1,-2,... to regular imports.
+ // Assign a cell_index of +1,+2,... to regular (local) exports.
+ // Assign a cell_index of 0 to anything else.
+ void AssignCellIndices();
+
int AddModuleRequest(const AstRawString* specifier) {
DCHECK_NOT_NULL(specifier);
auto it = module_requests_
« 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