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

Side by Side Diff: src/ast/modules.cc

Issue 2224333002: [modules] Split imports into regular and special, store regular ones in a map. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 4 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
« no previous file with comments | « src/ast/modules.h ('k') | src/ast/scopes.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/ast/modules.h" 5 #include "src/ast/modules.h"
6 #include "src/ast/ast-value-factory.h" 6 #include "src/ast/ast-value-factory.h"
7 #include "src/ast/scopes.h" 7 #include "src/ast/scopes.h"
8 8
9 namespace v8 { 9 namespace v8 {
10 namespace internal { 10 namespace internal {
11 11
12
13 void ModuleDescriptor::AddImport( 12 void ModuleDescriptor::AddImport(
14 const AstRawString* import_name, const AstRawString* local_name, 13 const AstRawString* import_name, const AstRawString* local_name,
15 const AstRawString* module_request, Scanner::Location loc, Zone* zone) { 14 const AstRawString* module_request, Scanner::Location loc, Zone* zone) {
16 DCHECK_NOT_NULL(import_name); 15 DCHECK_NOT_NULL(import_name);
17 DCHECK_NOT_NULL(local_name); 16 DCHECK_NOT_NULL(local_name);
18 DCHECK_NOT_NULL(module_request); 17 DCHECK_NOT_NULL(module_request);
19 ModuleEntry* entry = new (zone) ModuleEntry(loc); 18 ModuleEntry* entry = new (zone) ModuleEntry(loc);
20 entry->local_name = local_name; 19 entry->local_name = local_name;
21 entry->import_name = import_name; 20 entry->import_name = import_name;
22 entry->module_request = module_request; 21 entry->module_request = module_request;
23 imports_.Add(entry, zone); 22 regular_imports_.insert(std::make_pair(entry->local_name, entry));
23 // We don't care if there's already an entry for this local name, as in that
24 // case we will report an error when declaring the variable.
24 } 25 }
25 26
26 27
27 void ModuleDescriptor::AddStarImport( 28 void ModuleDescriptor::AddStarImport(
28 const AstRawString* local_name, const AstRawString* module_request, 29 const AstRawString* local_name, const AstRawString* module_request,
29 Scanner::Location loc, Zone* zone) { 30 Scanner::Location loc, Zone* zone) {
30 DCHECK_NOT_NULL(local_name); 31 DCHECK_NOT_NULL(local_name);
31 DCHECK_NOT_NULL(module_request); 32 DCHECK_NOT_NULL(module_request);
32 ModuleEntry* entry = new (zone) ModuleEntry(loc); 33 ModuleEntry* entry = new (zone) ModuleEntry(loc);
33 entry->local_name = local_name; 34 entry->local_name = local_name;
34 entry->module_request = module_request; 35 entry->module_request = module_request;
35 imports_.Add(entry, zone); 36 special_imports_.Add(entry, zone);
36 } 37 }
37 38
38 39
39 void ModuleDescriptor::AddEmptyImport( 40 void ModuleDescriptor::AddEmptyImport(
40 const AstRawString* module_request, Scanner::Location loc, Zone* zone) { 41 const AstRawString* module_request, Scanner::Location loc, Zone* zone) {
41 DCHECK_NOT_NULL(module_request); 42 DCHECK_NOT_NULL(module_request);
42 ModuleEntry* entry = new (zone) ModuleEntry(loc); 43 ModuleEntry* entry = new (zone) ModuleEntry(loc);
43 entry->module_request = module_request; 44 entry->module_request = module_request;
44 imports_.Add(entry, zone); 45 special_imports_.Add(entry, zone);
45 } 46 }
46 47
47 48
48 void ModuleDescriptor::AddExport( 49 void ModuleDescriptor::AddExport(
49 const AstRawString* local_name, const AstRawString* export_name, 50 const AstRawString* local_name, const AstRawString* export_name,
50 Scanner::Location loc, Zone* zone) { 51 Scanner::Location loc, Zone* zone) {
51 DCHECK_NOT_NULL(local_name); 52 DCHECK_NOT_NULL(local_name);
52 DCHECK_NOT_NULL(export_name); 53 DCHECK_NOT_NULL(export_name);
53 ModuleEntry* entry = new (zone) ModuleEntry(loc); 54 ModuleEntry* entry = new (zone) ModuleEntry(loc);
54 entry->export_name = export_name; 55 entry->export_name = export_name;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 MessageTemplate::kModuleExportUndefined, entry->local_name); 118 MessageTemplate::kModuleExportUndefined, entry->local_name);
118 return false; 119 return false;
119 } 120 }
120 } 121 }
121 122
122 return true; 123 return true;
123 } 124 }
124 125
125 } // namespace internal 126 } // namespace internal
126 } // namespace v8 127 } // namespace v8
OLDNEW
« no previous file with comments | « src/ast/modules.h ('k') | src/ast/scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698