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

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

Issue 2223893004: [modules] Detect all indirect exports and represent them as such. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@modules-imports
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
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 {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 73
74 74
75 void ModuleDescriptor::AddStarExport( 75 void ModuleDescriptor::AddStarExport(
76 const AstRawString* module_request, Scanner::Location loc, Zone* zone) { 76 const AstRawString* module_request, Scanner::Location loc, Zone* zone) {
77 DCHECK_NOT_NULL(module_request); 77 DCHECK_NOT_NULL(module_request);
78 ModuleEntry* entry = new (zone) ModuleEntry(loc); 78 ModuleEntry* entry = new (zone) ModuleEntry(loc);
79 entry->module_request = module_request; 79 entry->module_request = module_request;
80 exports_.Add(entry, zone); 80 exports_.Add(entry, zone);
81 } 81 }
82 82
83 void ModuleDescriptor::MakeIndirectExportsExplicit() {
84 for (auto entry : exports_) {
85 if (entry->export_name == nullptr) continue;
86 if (entry->import_name != nullptr) continue;
87 DCHECK_NOT_NULL(entry->local_name);
88 auto it = regular_imports_.find(entry->local_name);
89 if (it != regular_imports_.end()) {
90 // Found an indirect export.
91 DCHECK_NOT_NULL(it->second->module_request);
92 DCHECK_NOT_NULL(it->second->import_name);
93 entry->import_name = it->second->import_name;
94 entry->module_request = it->second->module_request;
95 entry->local_name = nullptr;
96 }
97 }
98 }
99
83 bool ModuleDescriptor::Validate(DeclarationScope* module_scope, 100 bool ModuleDescriptor::Validate(DeclarationScope* module_scope,
84 PendingCompilationErrorHandler* error_handler, 101 PendingCompilationErrorHandler* error_handler,
85 Zone* zone) const { 102 Zone* zone) const {
86 DCHECK(module_scope->is_module_scope()); 103 DCHECK(module_scope->is_module_scope());
87 DCHECK_EQ(this, module_scope->module()); 104 DCHECK_EQ(this, module_scope->module());
88 DCHECK_NOT_NULL(error_handler); 105 DCHECK_NOT_NULL(error_handler);
89 106
90 // Report error iff there are duplicate exports. 107 // Report error iff there are duplicate exports.
91 { 108 {
92 ZoneAllocationPolicy allocator(zone); 109 ZoneAllocationPolicy allocator(zone);
(...skipping 25 matching lines...) Expand all
118 MessageTemplate::kModuleExportUndefined, entry->local_name); 135 MessageTemplate::kModuleExportUndefined, entry->local_name);
119 return false; 136 return false;
120 } 137 }
121 } 138 }
122 139
123 return true; 140 return true;
124 } 141 }
125 142
126 } // namespace internal 143 } // namespace internal
127 } // namespace v8 144 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698