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

Unified Diff: src/modules.cc

Issue 960793003: Allow lookup of module exports by export name. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 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/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/modules.cc
diff --git a/src/modules.cc b/src/modules.cc
index 5fab34dcbd30c43adc2ba20e4f61ec11d805b43f..267c398c472c74ac035c7880fa04d9773762a5dd 100644
--- a/src/modules.cc
+++ b/src/modules.cc
@@ -20,9 +20,8 @@ void ModuleDescriptor::AddLocalExport(const AstRawString* export_name,
ZoneAllocationPolicy allocator(zone);
if (exports_ == nullptr) {
- exports_ = new (zone->New(sizeof(ZoneHashMap)))
- ZoneHashMap(ZoneHashMap::PointersMatch,
- ZoneHashMap::kDefaultHashMapCapacity, allocator);
+ exports_ = new (zone->New(sizeof(ZoneHashMap))) ZoneHashMap(
+ AstRawString::Compare, ZoneHashMap::kDefaultHashMapCapacity, allocator);
}
ZoneHashMap::Entry* p =
@@ -33,5 +32,18 @@ void ModuleDescriptor::AddLocalExport(const AstRawString* export_name,
p->value = const_cast<AstRawString*>(local_name);
}
+
+
+const AstRawString* ModuleDescriptor::LookupLocalExport(
+ const AstRawString* export_name, Zone* zone) {
+ if (exports_ == nullptr) return nullptr;
+ ZoneAllocationPolicy allocator(zone);
+ ZoneHashMap::Entry* entry =
+ exports_->Lookup(const_cast<AstRawString*>(export_name),
+ export_name->hash(), false, allocator);
+ if (entry == nullptr) return nullptr;
+ DCHECK_NOT_NULL(entry->value);
+ return static_cast<const AstRawString*>(entry->value);
+}
}
} // namespace v8::internal
« no previous file with comments | « src/modules.h ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698