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

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

Issue 2353403003: [modules] Support exporting a local variable under multiple export names. (Closed)
Patch Set: Comments 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.cc ('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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 <stdlib.h> 5 #include <stdlib.h>
6 6
7 #include "src/ast/context-slot-cache.h" 7 #include "src/ast/context-slot-cache.h"
8 #include "src/ast/scopes.h" 8 #include "src/ast/scopes.h"
9 #include "src/ast/variables.h" 9 #include "src/ast/variables.h"
10 #include "src/bootstrapper.h" 10 #include "src/bootstrapper.h"
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 265
266 // If present, add the outer scope info. 266 // If present, add the outer scope info.
267 DCHECK(index == scope_info->OuterScopeInfoIndex()); 267 DCHECK(index == scope_info->OuterScopeInfoIndex());
268 if (has_outer_scope_info) { 268 if (has_outer_scope_info) {
269 scope_info->set(index++, *outer_scope.ToHandleChecked()); 269 scope_info->set(index++, *outer_scope.ToHandleChecked());
270 } 270 }
271 271
272 // Module-specific information (only for module scopes). 272 // Module-specific information (only for module scopes).
273 if (scope->is_module_scope()) { 273 if (scope->is_module_scope()) {
274 Handle<ModuleInfo> module_info = 274 Handle<ModuleInfo> module_info =
275 ModuleInfo::New(isolate, scope->AsModuleScope()->module()); 275 ModuleInfo::New(isolate, zone, scope->AsModuleScope()->module());
276 DCHECK_EQ(index, scope_info->ModuleInfoIndex()); 276 DCHECK_EQ(index, scope_info->ModuleInfoIndex());
277 scope_info->set(index++, *module_info); 277 scope_info->set(index++, *module_info);
278 DCHECK_EQ(index, scope_info->ModuleVariableCountIndex()); 278 DCHECK_EQ(index, scope_info->ModuleVariableCountIndex());
279 scope_info->set(index++, Smi::FromInt(module_vars_count)); 279 scope_info->set(index++, Smi::FromInt(module_vars_count));
280 DCHECK_EQ(index, scope_info->ModuleVariablesIndex()); 280 DCHECK_EQ(index, scope_info->ModuleVariablesIndex());
281 // The variable entries themselves have already been written above. 281 // The variable entries themselves have already been written above.
282 index += kModuleVariableEntryLength * module_vars_count; 282 index += kModuleVariableEntryLength * module_vars_count;
283 } 283 }
284 284
285 DCHECK_EQ(index, scope_info->length()); 285 DCHECK_EQ(index, scope_info->length());
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 Handle<Object> import_name, 845 Handle<Object> import_name,
846 Handle<Object> module_request) { 846 Handle<Object> module_request) {
847 Handle<ModuleInfoEntry> result = isolate->factory()->NewModuleInfoEntry(); 847 Handle<ModuleInfoEntry> result = isolate->factory()->NewModuleInfoEntry();
848 result->set(kExportNameIndex, *export_name); 848 result->set(kExportNameIndex, *export_name);
849 result->set(kLocalNameIndex, *local_name); 849 result->set(kLocalNameIndex, *local_name);
850 result->set(kImportNameIndex, *import_name); 850 result->set(kImportNameIndex, *import_name);
851 result->set(kModuleRequestIndex, *module_request); 851 result->set(kModuleRequestIndex, *module_request);
852 return result; 852 return result;
853 } 853 }
854 854
855 Handle<ModuleInfo> ModuleInfo::New(Isolate* isolate, ModuleDescriptor* descr) { 855 Handle<ModuleInfo> ModuleInfo::New(Isolate* isolate, Zone* zone,
856 ModuleDescriptor* descr) {
856 // Serialize module requests. 857 // Serialize module requests.
857 Handle<FixedArray> module_requests = isolate->factory()->NewFixedArray( 858 Handle<FixedArray> module_requests = isolate->factory()->NewFixedArray(
858 static_cast<int>(descr->module_requests().size())); 859 static_cast<int>(descr->module_requests().size()));
859 for (const auto& elem : descr->module_requests()) { 860 for (const auto& elem : descr->module_requests()) {
860 module_requests->set(elem.second, *elem.first->string()); 861 module_requests->set(elem.second, *elem.first->string());
861 } 862 }
862 863
863 // Serialize special exports. 864 // Serialize special exports.
864 Handle<FixedArray> special_exports = 865 Handle<FixedArray> special_exports =
865 isolate->factory()->NewFixedArray(descr->special_exports().length()); 866 isolate->factory()->NewFixedArray(descr->special_exports().length());
866 { 867 {
867 int i = 0; 868 int i = 0;
868 for (auto entry : descr->special_exports()) { 869 for (auto entry : descr->special_exports()) {
869 special_exports->set(i++, *entry->Serialize(isolate)); 870 special_exports->set(i++, *entry->Serialize(isolate));
870 } 871 }
871 } 872 }
872 873
873 // Serialize special imports. 874 // Serialize special imports.
874 Handle<FixedArray> special_imports = 875 Handle<FixedArray> special_imports =
875 isolate->factory()->NewFixedArray(descr->special_imports().length()); 876 isolate->factory()->NewFixedArray(descr->special_imports().length());
876 { 877 {
877 int i = 0; 878 int i = 0;
878 for (auto entry : descr->special_imports()) { 879 for (auto entry : descr->special_imports()) {
879 special_imports->set(i++, *entry->Serialize(isolate)); 880 special_imports->set(i++, *entry->Serialize(isolate));
880 } 881 }
881 } 882 }
882 883
883 // Serialize regular exports. 884 // Serialize regular exports.
884 Handle<FixedArray> regular_exports = isolate->factory()->NewFixedArray( 885 Handle<FixedArray> regular_exports =
885 static_cast<int>(descr->regular_exports().size())); 886 descr->SerializeRegularExports(isolate, zone);
886 {
887 int i = 0;
888 for (const auto& elem : descr->regular_exports()) {
889 regular_exports->set(i++, *elem.second->Serialize(isolate));
890 }
891 }
892 887
893 // Serialize regular imports. 888 // Serialize regular imports.
894 Handle<FixedArray> regular_imports = isolate->factory()->NewFixedArray( 889 Handle<FixedArray> regular_imports = isolate->factory()->NewFixedArray(
895 static_cast<int>(descr->regular_imports().size())); 890 static_cast<int>(descr->regular_imports().size()));
896 { 891 {
897 int i = 0; 892 int i = 0;
898 for (const auto& elem : descr->regular_imports()) { 893 for (const auto& elem : descr->regular_imports()) {
899 regular_imports->set(i++, *elem.second->Serialize(isolate)); 894 regular_imports->set(i++, *elem.second->Serialize(isolate));
900 } 895 }
901 } 896 }
902 897
903 Handle<ModuleInfo> result = isolate->factory()->NewModuleInfo(); 898 Handle<ModuleInfo> result = isolate->factory()->NewModuleInfo();
904 result->set(kModuleRequestsIndex, *module_requests); 899 result->set(kModuleRequestsIndex, *module_requests);
905 result->set(kSpecialExportsIndex, *special_exports); 900 result->set(kSpecialExportsIndex, *special_exports);
906 result->set(kRegularExportsIndex, *regular_exports); 901 result->set(kRegularExportsIndex, *regular_exports);
907 result->set(kSpecialImportsIndex, *special_imports); 902 result->set(kSpecialImportsIndex, *special_imports);
908 result->set(kRegularImportsIndex, *regular_imports); 903 result->set(kRegularImportsIndex, *regular_imports);
909 return result; 904 return result;
910 } 905 }
911 906
912 } // namespace internal 907 } // namespace internal
913 } // namespace v8 908 } // namespace v8
OLDNEW
« no previous file with comments | « src/ast/modules.cc ('k') | src/ast/scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698