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

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

Issue 2302783002: [modules] Basic support of exports (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
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/bootstrapper.h" 9 #include "src/bootstrapper.h"
10 10
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 } 412 }
413 413
414 414
415 String* ScopeInfo::FunctionName() { 415 String* ScopeInfo::FunctionName() {
416 DCHECK(HasFunctionName()); 416 DCHECK(HasFunctionName());
417 return String::cast(get(FunctionNameEntryIndex())); 417 return String::cast(get(FunctionNameEntryIndex()));
418 } 418 }
419 419
420 ModuleInfo* ScopeInfo::ModuleDescriptorInfo() { 420 ModuleInfo* ScopeInfo::ModuleDescriptorInfo() {
421 DCHECK(scope_type() == MODULE_SCOPE); 421 DCHECK(scope_type() == MODULE_SCOPE);
422 return static_cast<ModuleInfo*>(get(ModuleInfoEntryIndex())); 422 return ModuleInfo::cast(get(ModuleInfoEntryIndex()));
423 } 423 }
424 424
425 String* ScopeInfo::ParameterName(int var) { 425 String* ScopeInfo::ParameterName(int var) {
426 DCHECK_LE(0, var); 426 DCHECK_LE(0, var);
427 DCHECK_LT(var, ParameterCount()); 427 DCHECK_LT(var, ParameterCount());
428 int info_index = ParameterEntriesIndex() + var; 428 int info_index = ParameterEntriesIndex() + var;
429 return String::cast(get(info_index)); 429 return String::cast(get(info_index));
430 } 430 }
431 431
432 432
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 if (length() > 0) { 711 if (length() > 0) {
712 PrintList("parameters", 0, ParameterEntriesIndex(), 712 PrintList("parameters", 0, ParameterEntriesIndex(),
713 ParameterEntriesIndex() + ParameterCount(), this); 713 ParameterEntriesIndex() + ParameterCount(), this);
714 PrintList("stack slots", 0, StackLocalEntriesIndex(), 714 PrintList("stack slots", 0, StackLocalEntriesIndex(),
715 StackLocalEntriesIndex() + StackLocalCount(), this); 715 StackLocalEntriesIndex() + StackLocalCount(), this);
716 PrintList("context slots", Context::MIN_CONTEXT_SLOTS, 716 PrintList("context slots", Context::MIN_CONTEXT_SLOTS,
717 ContextLocalNameEntriesIndex(), 717 ContextLocalNameEntriesIndex(),
718 ContextLocalNameEntriesIndex() + ContextLocalCount(), this); 718 ContextLocalNameEntriesIndex() + ContextLocalCount(), this);
719 } 719 }
720 720
721 // XXX never called for module scopes
722
721 PrintF("}\n"); 723 PrintF("}\n");
722 } 724 }
723 #endif // DEBUG 725 #endif // DEBUG
724 726
727 Handle<ModuleInfoEntry> ModuleInfoEntry::New(Isolate* isolate,
728 Handle<Object> export_name,
729 Handle<Object> local_name,
730 Handle<Object> import_name,
731 Handle<Object> module_request) {
732 Handle<ModuleInfoEntry> result = isolate->factory()->NewModuleInfoEntry();
733 result->set(kExportNameIndex, *export_name);
734 result->set(kLocalNameIndex, *local_name);
735 result->set(kImportNameIndex, *import_name);
736 result->set(kModuleRequestIndex, *module_request);
737 return result;
738 }
739
725 Handle<ModuleInfo> ModuleInfo::New(Isolate* isolate, ModuleDescriptor* descr) { 740 Handle<ModuleInfo> ModuleInfo::New(Isolate* isolate, ModuleDescriptor* descr) {
726 // Serialize special exports. 741 // Serialize special exports.
727 Handle<FixedArray> special_exports = 742 Handle<FixedArray> special_exports =
728 isolate->factory()->NewFixedArray(descr->special_exports().length()); 743 isolate->factory()->NewFixedArray(descr->special_exports().length());
729 { 744 {
730 int i = 0; 745 int i = 0;
731 for (auto entry : descr->special_exports()) { 746 for (auto entry : descr->special_exports()) {
732 special_exports->set(i++, *entry->Serialize(isolate)); 747 special_exports->set(i++, *entry->Serialize(isolate));
733 } 748 }
734 } 749 }
735 750
736 // Serialize regular exports. 751 // Serialize regular exports.
737 Handle<FixedArray> regular_exports = isolate->factory()->NewFixedArray( 752 Handle<FixedArray> regular_exports = isolate->factory()->NewFixedArray(
738 static_cast<int>(descr->regular_exports().size())); 753 static_cast<int>(descr->regular_exports().size()));
739 { 754 {
740 int i = 0; 755 int i = 0;
741 for (const auto& it : descr->regular_exports()) { 756 for (const auto& it : descr->regular_exports()) {
742 regular_exports->set(i++, *it.second->Serialize(isolate)); 757 regular_exports->set(i++, *it.second->Serialize(isolate));
743 } 758 }
744 } 759 }
745 760
746 Handle<ModuleInfo> result = isolate->factory()->NewModuleInfo(); 761 Handle<ModuleInfo> result = isolate->factory()->NewModuleInfo();
747 result->set(kSpecialExportsIndex, *special_exports); 762 result->set(kSpecialExportsIndex, *special_exports);
748 result->set(kRegularExportsIndex, *regular_exports); 763 result->set(kRegularExportsIndex, *regular_exports);
749 return result; 764 return result;
750 } 765 }
751 766
752 } // namespace internal 767 } // namespace internal
753 } // namespace v8 768 } // namespace v8
OLDNEW
« no previous file with comments | « src/ast/modules.cc ('k') | src/ast/scopes.h » ('j') | src/contexts.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698