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

Side by Side Diff: src/modules.cc

Issue 934323004: Teach ModuleDescriptor about basic local exports (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Handled review comments, added message tests 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 unified diff | Download patch
OLDNEW
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 // ---------------------------------------------------------------------------
15 // Addition.
16 14
17 void ModuleDescriptor::Add(const AstRawString* name, Zone* zone, bool* ok) { 15 void ModuleDescriptor::AddLocalExport(const AstRawString* export_name,
18 void* key = const_cast<AstRawString*>(name); 16 const AstRawString* local_name,
17 Zone* zone, bool* ok) {
18 void* key = const_cast<AstRawString*>(export_name);
19 19
20 ZoneHashMap** map = &exports_;
21 ZoneAllocationPolicy allocator(zone); 20 ZoneAllocationPolicy allocator(zone);
22 21
23 if (*map == nullptr) { 22 if (exports_ == nullptr) {
24 *map = new (zone->New(sizeof(ZoneHashMap))) 23 exports_ = new (zone->New(sizeof(ZoneHashMap)))
25 ZoneHashMap(ZoneHashMap::PointersMatch, 24 ZoneHashMap(ZoneHashMap::PointersMatch,
26 ZoneHashMap::kDefaultHashMapCapacity, allocator); 25 ZoneHashMap::kDefaultHashMapCapacity, allocator);
27 } 26 }
28 27
29 ZoneHashMap::Entry* p = 28 ZoneHashMap::Entry* p =
30 (*map)->Lookup(key, name->hash(), !IsFrozen(), allocator); 29 exports_->Lookup(key, export_name->hash(), !IsFrozen(), allocator);
31 if (p == nullptr || p->value != nullptr) { 30 if (p == nullptr || p->value != nullptr) {
32 *ok = false; 31 *ok = false;
33 } 32 }
34 33
35 p->value = key; 34 p->value = const_cast<AstRawString*>(local_name);
36 } 35 }
37 } 36 }
38 } // namespace v8::internal 37 } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/modules.h ('k') | src/parser.h » ('j') | test/message/export-duplicate.out » ('J')

Powered by Google App Engine
This is Rietveld 408576698