| OLD | NEW |
| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 | 81 |
| 82 } // namespace | 82 } // namespace |
| 83 | 83 |
| 84 Handle<ModuleInfoEntry> ModuleDescriptor::Entry::Serialize( | 84 Handle<ModuleInfoEntry> ModuleDescriptor::Entry::Serialize( |
| 85 Isolate* isolate) const { | 85 Isolate* isolate) const { |
| 86 CHECK(Smi::IsValid(module_request)); // TODO(neis): Check earlier? | 86 CHECK(Smi::IsValid(module_request)); // TODO(neis): Check earlier? |
| 87 return ModuleInfoEntry::New( | 87 return ModuleInfoEntry::New( |
| 88 isolate, ToStringOrUndefined(isolate, export_name), | 88 isolate, ToStringOrUndefined(isolate, export_name), |
| 89 ToStringOrUndefined(isolate, local_name), | 89 ToStringOrUndefined(isolate, local_name), |
| 90 ToStringOrUndefined(isolate, import_name), | 90 ToStringOrUndefined(isolate, import_name), |
| 91 Handle<Object>(Smi::FromInt(module_request), isolate)); | 91 Handle<Object>(Smi::FromInt(module_request), isolate), location.beg_pos, |
| 92 location.end_pos); |
| 92 } | 93 } |
| 93 | 94 |
| 94 ModuleDescriptor::Entry* ModuleDescriptor::Entry::Deserialize( | 95 ModuleDescriptor::Entry* ModuleDescriptor::Entry::Deserialize( |
| 95 Isolate* isolate, AstValueFactory* avfactory, | 96 Isolate* isolate, AstValueFactory* avfactory, |
| 96 Handle<ModuleInfoEntry> entry) { | 97 Handle<ModuleInfoEntry> entry) { |
| 97 Entry* result = new (avfactory->zone()) Entry(Scanner::Location::invalid()); | 98 Entry* result = new (avfactory->zone()) Entry(Scanner::Location::invalid()); |
| 98 result->export_name = FromStringOrUndefined( | 99 result->export_name = FromStringOrUndefined( |
| 99 isolate, avfactory, handle(entry->export_name(), isolate)); | 100 isolate, avfactory, handle(entry->export_name(), isolate)); |
| 100 result->local_name = FromStringOrUndefined( | 101 result->local_name = FromStringOrUndefined( |
| 101 isolate, avfactory, handle(entry->local_name(), isolate)); | 102 isolate, avfactory, handle(entry->local_name(), isolate)); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 // Found an indirect export. Patch export entry and move it from regular | 178 // Found an indirect export. Patch export entry and move it from regular |
| 178 // to special. | 179 // to special. |
| 179 DCHECK_NULL(entry->import_name); | 180 DCHECK_NULL(entry->import_name); |
| 180 DCHECK_LT(entry->module_request, 0); | 181 DCHECK_LT(entry->module_request, 0); |
| 181 DCHECK_NOT_NULL(import->second->import_name); | 182 DCHECK_NOT_NULL(import->second->import_name); |
| 182 DCHECK_LE(0, import->second->module_request); | 183 DCHECK_LE(0, import->second->module_request); |
| 183 DCHECK_LT(import->second->module_request, | 184 DCHECK_LT(import->second->module_request, |
| 184 static_cast<int>(module_requests_.size())); | 185 static_cast<int>(module_requests_.size())); |
| 185 entry->import_name = import->second->import_name; | 186 entry->import_name = import->second->import_name; |
| 186 entry->module_request = import->second->module_request; | 187 entry->module_request = import->second->module_request; |
| 188 // Hack: When the indirect export cannot be resolved, we want the error |
| 189 // message to point at the import statement, not at the export statement. |
| 190 // Therefore we overwrite [entry]'s location here. Note that Validate() |
| 191 // has already checked for duplicate exports, so it's guaranteed that we |
| 192 // won't need to report any error pointing at the (now lost) export |
| 193 // location. |
| 194 entry->location = import->second->location; |
| 187 entry->local_name = nullptr; | 195 entry->local_name = nullptr; |
| 188 AddSpecialExport(entry, zone); | 196 AddSpecialExport(entry, zone); |
| 189 it = regular_exports_.erase(it); | 197 it = regular_exports_.erase(it); |
| 190 } else { | 198 } else { |
| 191 it++; | 199 it++; |
| 192 } | 200 } |
| 193 } | 201 } |
| 194 } | 202 } |
| 195 | 203 |
| 196 namespace { | 204 namespace { |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 return false; | 265 return false; |
| 258 } | 266 } |
| 259 } | 267 } |
| 260 | 268 |
| 261 MakeIndirectExportsExplicit(zone); | 269 MakeIndirectExportsExplicit(zone); |
| 262 return true; | 270 return true; |
| 263 } | 271 } |
| 264 | 272 |
| 265 } // namespace internal | 273 } // namespace internal |
| 266 } // namespace v8 | 274 } // namespace v8 |
| OLD | NEW |