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

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

Issue 2340903002: Revert of [modules] Make duplicate export error deterministic. (Closed)
Patch Set: Created 4 years, 3 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') | test/message/export-duplicate.js » ('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 {
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 special_exports_.Add(entry, zone); 129 special_exports_.Add(entry, zone);
130 it = regular_exports_.erase(it); 130 it = regular_exports_.erase(it);
131 } else { 131 } else {
132 it++; 132 it++;
133 } 133 }
134 } 134 }
135 } 135 }
136 136
137 const ModuleDescriptor::Entry* ModuleDescriptor::FindDuplicateExport( 137 const ModuleDescriptor::Entry* ModuleDescriptor::FindDuplicateExport(
138 Zone* zone) const { 138 Zone* zone) const {
139 const ModuleDescriptor::Entry* candidate = nullptr;
140 ZoneSet<const AstRawString*> export_names(zone); 139 ZoneSet<const AstRawString*> export_names(zone);
141 for (const auto& it : regular_exports_) { 140 for (const auto& it : regular_exports_) {
142 const Entry* entry = it.second; 141 const Entry* entry = it.second;
143 DCHECK_NOT_NULL(entry->export_name); 142 DCHECK_NOT_NULL(entry->export_name);
144 DCHECK(entry->location.IsValid()); 143 if (!export_names.insert(entry->export_name).second) return entry;
145 bool is_duplicate = !export_names.insert(entry->export_name).second;
146 if (is_duplicate &&
147 (candidate == nullptr ||
148 entry->location.beg_pos > candidate->location.beg_pos)) {
149 candidate = entry;
150 }
151 } 144 }
152 for (auto entry : special_exports_) { 145 for (auto entry : special_exports_) {
153 if (entry->export_name == nullptr) continue; // Star export. 146 if (entry->export_name == nullptr) continue; // Star export.
154 DCHECK(entry->location.IsValid()); 147 if (!export_names.insert(entry->export_name).second) return entry;
155 bool is_duplicate = !export_names.insert(entry->export_name).second;
156 if (is_duplicate &&
157 (candidate == nullptr ||
158 entry->location.beg_pos > candidate->location.beg_pos)) {
159 candidate = entry;
160 }
161 } 148 }
162 return candidate; 149 return nullptr;
163 } 150 }
164 151
165 bool ModuleDescriptor::Validate(ModuleScope* module_scope, 152 bool ModuleDescriptor::Validate(ModuleScope* module_scope,
166 PendingCompilationErrorHandler* error_handler, 153 PendingCompilationErrorHandler* error_handler,
167 Zone* zone) { 154 Zone* zone) {
168 DCHECK_EQ(this, module_scope->module()); 155 DCHECK_EQ(this, module_scope->module());
169 DCHECK_NOT_NULL(error_handler); 156 DCHECK_NOT_NULL(error_handler);
170 157
171 // Report error iff there are duplicate exports. 158 // Report error iff there are duplicate exports.
172 { 159 {
(...skipping 17 matching lines...) Expand all
190 return false; 177 return false;
191 } 178 }
192 } 179 }
193 180
194 MakeIndirectExportsExplicit(zone); 181 MakeIndirectExportsExplicit(zone);
195 return true; 182 return true;
196 } 183 }
197 184
198 } // namespace internal 185 } // namespace internal
199 } // namespace v8 186 } // namespace v8
OLDNEW
« no previous file with comments | « src/ast/modules.h ('k') | test/message/export-duplicate.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698