| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/modules.h" | 7 #include "src/modules.h" |
| 8 | 8 |
| 9 #include "src/ast-value-factory.h" | 9 #include "src/ast-value-factory.h" |
| 10 | 10 |
| 11 namespace v8 { | 11 namespace v8 { |
| 12 namespace internal { | 12 namespace internal { |
| 13 | 13 |
| 14 | 14 |
| 15 void ModuleDescriptor::AddLocalExport(const AstRawString* export_name, | 15 void ModuleDescriptor::AddLocalExport(const AstRawString* export_name, |
| 16 const AstRawString* local_name, | 16 const AstRawString* local_name, |
| 17 Zone* zone, bool* ok) { | 17 Zone* zone, bool* ok) { |
| 18 void* key = const_cast<AstRawString*>(export_name); | 18 void* key = const_cast<AstRawString*>(export_name); |
| 19 | 19 |
| 20 ZoneAllocationPolicy allocator(zone); | 20 ZoneAllocationPolicy allocator(zone); |
| 21 | 21 |
| 22 if (exports_ == nullptr) { | 22 if (exports_ == nullptr) { |
| 23 exports_ = new (zone->New(sizeof(ZoneHashMap))) ZoneHashMap( | 23 exports_ = new (zone->New(sizeof(ZoneHashMap))) |
| 24 AstRawString::Compare, ZoneHashMap::kDefaultHashMapCapacity, allocator); | 24 ZoneHashMap(ZoneHashMap::PointersMatch, |
| 25 ZoneHashMap::kDefaultHashMapCapacity, allocator); |
| 25 } | 26 } |
| 26 | 27 |
| 27 ZoneHashMap::Entry* p = | 28 ZoneHashMap::Entry* p = |
| 28 exports_->Lookup(key, export_name->hash(), !IsFrozen(), allocator); | 29 exports_->Lookup(key, export_name->hash(), !IsFrozen(), allocator); |
| 29 if (p == nullptr || p->value != nullptr) { | 30 if (p == nullptr || p->value != nullptr) { |
| 30 *ok = false; | 31 *ok = false; |
| 31 } | 32 } |
| 32 | 33 |
| 33 p->value = const_cast<AstRawString*>(local_name); | 34 p->value = const_cast<AstRawString*>(local_name); |
| 34 } | 35 } |
| 35 | 36 |
| 36 | 37 |
| 37 const AstRawString* ModuleDescriptor::LookupLocalExport( | 38 const AstRawString* ModuleDescriptor::LookupLocalExport( |
| 38 const AstRawString* export_name, Zone* zone) { | 39 const AstRawString* export_name, Zone* zone) { |
| 39 if (exports_ == nullptr) return nullptr; | 40 if (exports_ == nullptr) return nullptr; |
| 40 ZoneAllocationPolicy allocator(zone); | 41 ZoneAllocationPolicy allocator(zone); |
| 41 ZoneHashMap::Entry* entry = | 42 ZoneHashMap::Entry* entry = |
| 42 exports_->Lookup(const_cast<AstRawString*>(export_name), | 43 exports_->Lookup(const_cast<AstRawString*>(export_name), |
| 43 export_name->hash(), false, allocator); | 44 export_name->hash(), false, allocator); |
| 44 if (entry == nullptr) return nullptr; | 45 if (entry == nullptr) return nullptr; |
| 45 DCHECK_NOT_NULL(entry->value); | 46 DCHECK_NOT_NULL(entry->value); |
| 46 return static_cast<const AstRawString*>(entry->value); | 47 return static_cast<const AstRawString*>(entry->value); |
| 47 } | 48 } |
| 48 } | 49 } |
| 49 } // namespace v8::internal | 50 } // namespace v8::internal |
| OLD | NEW |