5 #ifndef V8_AST_MODULES_H_ 6 #define V8_AST_MODULES_H_ 8 #include "src/parsing/scanner.h" 9 #include "src/zone/zone-containers.h" 17 class ModuleInfoEntry;
18 class PendingCompilationErrorHandler;
23 : module_requests_(zone),
24 special_exports_(zone),
25 namespace_imports_(zone),
26 regular_exports_(zone),
27 regular_imports_(zone) {}
104 export_name(
nullptr),
106 import_name(
nullptr),
118 enum CellIndexKind { kInvalid, kExport, kImport };
119 static CellIndexKind GetCellIndexKind(
int cell_index);
124 ModuleRequest(
int index,
int position) : index(index), position(position) {}
141 const ModuleRequestMap& module_requests()
const {
return module_requests_; }
145 return namespace_imports_;
149 const RegularImportMap& regular_imports()
const {
return regular_imports_; }
152 const ZoneVector<const Entry*>& special_exports()
const {
153 return special_exports_;
158 const RegularExportMap& regular_exports()
const {
return regular_exports_; }
160 void AddRegularExport(Entry* entry) {
161 DCHECK_NOT_NULL(entry->export_name);
162 DCHECK_NOT_NULL(entry->local_name);
163 DCHECK_NULL(entry->import_name);
164 DCHECK_LT(entry->module_request, 0);
165 regular_exports_.insert(std::make_pair(entry->local_name, entry));
168 void AddSpecialExport(
const Entry* entry, Zone* zone) {
169 DCHECK_NULL(entry->local_name);
170 DCHECK_LE(0, entry->module_request);
171 special_exports_.push_back(entry);
174 void AddRegularImport(Entry* entry) {
175 DCHECK_NOT_NULL(entry->import_name);
176 DCHECK_NOT_NULL(entry->local_name);
177 DCHECK_NULL(entry->export_name);
178 DCHECK_LE(0, entry->module_request);
179 regular_imports_.insert(std::make_pair(entry->local_name, entry));
184 void AddNamespaceImport(
const Entry* entry, Zone* zone) {
185 DCHECK_NULL(entry->import_name);
186 DCHECK_NULL(entry->export_name);
187 DCHECK_NOT_NULL(entry->local_name);
188 DCHECK_LE(0, entry->module_request);
189 namespace_imports_.push_back(entry);
192 Handle<FixedArray> SerializeRegularExports(Isolate* isolate,
194 void DeserializeRegularExports(Isolate* isolate, AstValueFactory* avfactory,
195 Handle<ModuleInfo> module_info);
198 ModuleRequestMap module_requests_;
199 ZoneVector<const Entry*> special_exports_;
200 ZoneVector<const Entry*> namespace_imports_;
201 RegularExportMap regular_exports_;
202 RegularImportMap regular_imports_;
206 const Entry* FindDuplicateExport(Zone* zone)
const;
224 void MakeIndirectExportsExplicit(Zone* zone);
229 void AssignCellIndices();
231 int AddModuleRequest(
const AstRawString* specifier,
232 Scanner::Location specifier_loc) {
233 DCHECK_NOT_NULL(specifier);
234 int module_requests_count =
static_cast<int>(module_requests_.size());
235 auto it = module_requests_
236 .insert(std::make_pair(specifier,
237 ModuleRequest(module_requests_count,
238 specifier_loc.beg_pos)))
240 return it->second.index;
247 #endif // V8_AST_MODULES_H_