OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "src/v8.h" |
| 6 |
| 7 #include "src/modules.h" |
| 8 |
| 9 #include "src/ast-value-factory.h" |
| 10 |
| 11 namespace v8 { |
| 12 namespace internal { |
| 13 |
| 14 // --------------------------------------------------------------------------- |
| 15 // Addition. |
| 16 |
| 17 void ModuleDescriptor::Add(const AstRawString* name, Zone* zone, bool* ok) { |
| 18 void* key = const_cast<AstRawString*>(name); |
| 19 |
| 20 ZoneHashMap** map = &exports_; |
| 21 ZoneAllocationPolicy allocator(zone); |
| 22 |
| 23 if (*map == nullptr) { |
| 24 *map = new (zone->New(sizeof(ZoneHashMap))) |
| 25 ZoneHashMap(ZoneHashMap::PointersMatch, |
| 26 ZoneHashMap::kDefaultHashMapCapacity, allocator); |
| 27 } |
| 28 |
| 29 ZoneHashMap::Entry* p = |
| 30 (*map)->Lookup(key, name->hash(), !IsFrozen(), allocator); |
| 31 if (p == nullptr || p->value != nullptr) { |
| 32 *ok = false; |
| 33 } |
| 34 |
| 35 p->value = key; |
| 36 } |
| 37 } |
| 38 } // namespace v8::internal |
OLD | NEW |