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

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

Issue 2302783002: [modules] Basic support of exports (Closed)
Patch Set: Disable module tests for deopt fuzzer. 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.h » ('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 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 return String::cast(get(FunctionNameInfoIndex())); 510 return String::cast(get(FunctionNameInfoIndex()));
511 } 511 }
512 512
513 ScopeInfo* ScopeInfo::OuterScopeInfo() { 513 ScopeInfo* ScopeInfo::OuterScopeInfo() {
514 DCHECK(HasOuterScopeInfo()); 514 DCHECK(HasOuterScopeInfo());
515 return ScopeInfo::cast(get(OuterScopeInfoIndex())); 515 return ScopeInfo::cast(get(OuterScopeInfoIndex()));
516 } 516 }
517 517
518 ModuleInfo* ScopeInfo::ModuleDescriptorInfo() { 518 ModuleInfo* ScopeInfo::ModuleDescriptorInfo() {
519 DCHECK(scope_type() == MODULE_SCOPE); 519 DCHECK(scope_type() == MODULE_SCOPE);
520 return static_cast<ModuleInfo*>(get(ModuleInfoIndex())); 520 return ModuleInfo::cast(get(ModuleInfoIndex()));
521 } 521 }
522 522
523 String* ScopeInfo::ParameterName(int var) { 523 String* ScopeInfo::ParameterName(int var) {
524 DCHECK_LE(0, var); 524 DCHECK_LE(0, var);
525 DCHECK_LT(var, ParameterCount()); 525 DCHECK_LT(var, ParameterCount());
526 int info_index = ParameterNamesIndex() + var; 526 int info_index = ParameterNamesIndex() + var;
527 return String::cast(get(info_index)); 527 return String::cast(get(info_index));
528 } 528 }
529 529
530 530
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
804 PrintF("{"); 804 PrintF("{");
805 805
806 if (length() > 0) { 806 if (length() > 0) {
807 PrintList("parameters", 0, ParameterNamesIndex(), 807 PrintList("parameters", 0, ParameterNamesIndex(),
808 ParameterNamesIndex() + ParameterCount(), this); 808 ParameterNamesIndex() + ParameterCount(), this);
809 PrintList("stack slots", 0, StackLocalNamesIndex(), 809 PrintList("stack slots", 0, StackLocalNamesIndex(),
810 StackLocalNamesIndex() + StackLocalCount(), this); 810 StackLocalNamesIndex() + StackLocalCount(), this);
811 PrintList("context slots", Context::MIN_CONTEXT_SLOTS, 811 PrintList("context slots", Context::MIN_CONTEXT_SLOTS,
812 ContextLocalNamesIndex(), 812 ContextLocalNamesIndex(),
813 ContextLocalNamesIndex() + ContextLocalCount(), this); 813 ContextLocalNamesIndex() + ContextLocalCount(), this);
814 // TODO(neis): Print module stuff if present.
814 } 815 }
815 816
816 PrintF("}\n"); 817 PrintF("}\n");
817 } 818 }
818 #endif // DEBUG 819 #endif // DEBUG
819 820
821 Handle<ModuleInfoEntry> ModuleInfoEntry::New(Isolate* isolate,
822 Handle<Object> export_name,
823 Handle<Object> local_name,
824 Handle<Object> import_name,
825 Handle<Object> module_request) {
826 Handle<ModuleInfoEntry> result = isolate->factory()->NewModuleInfoEntry();
827 result->set(kExportNameIndex, *export_name);
828 result->set(kLocalNameIndex, *local_name);
829 result->set(kImportNameIndex, *import_name);
830 result->set(kModuleRequestIndex, *module_request);
831 return result;
832 }
833
820 Handle<ModuleInfo> ModuleInfo::New(Isolate* isolate, ModuleDescriptor* descr) { 834 Handle<ModuleInfo> ModuleInfo::New(Isolate* isolate, ModuleDescriptor* descr) {
821 // Serialize special exports. 835 // Serialize special exports.
822 Handle<FixedArray> special_exports = 836 Handle<FixedArray> special_exports =
823 isolate->factory()->NewFixedArray(descr->special_exports().length()); 837 isolate->factory()->NewFixedArray(descr->special_exports().length());
824 { 838 {
825 int i = 0; 839 int i = 0;
826 for (auto entry : descr->special_exports()) { 840 for (auto entry : descr->special_exports()) {
827 special_exports->set(i++, *entry->Serialize(isolate)); 841 special_exports->set(i++, *entry->Serialize(isolate));
828 } 842 }
829 } 843 }
830 844
831 // Serialize regular exports. 845 // Serialize regular exports.
832 Handle<FixedArray> regular_exports = isolate->factory()->NewFixedArray( 846 Handle<FixedArray> regular_exports = isolate->factory()->NewFixedArray(
833 static_cast<int>(descr->regular_exports().size())); 847 static_cast<int>(descr->regular_exports().size()));
834 { 848 {
835 int i = 0; 849 int i = 0;
836 for (const auto& it : descr->regular_exports()) { 850 for (const auto& it : descr->regular_exports()) {
837 regular_exports->set(i++, *it.second->Serialize(isolate)); 851 regular_exports->set(i++, *it.second->Serialize(isolate));
838 } 852 }
839 } 853 }
840 854
841 Handle<ModuleInfo> result = isolate->factory()->NewModuleInfo(); 855 Handle<ModuleInfo> result = isolate->factory()->NewModuleInfo();
842 result->set(kSpecialExportsIndex, *special_exports); 856 result->set(kSpecialExportsIndex, *special_exports);
843 result->set(kRegularExportsIndex, *regular_exports); 857 result->set(kRegularExportsIndex, *regular_exports);
844 return result; 858 return result;
845 } 859 }
846 860
847 } // namespace internal 861 } // namespace internal
848 } // namespace v8 862 } // namespace v8
OLDNEW
« no previous file with comments | « src/ast/modules.cc ('k') | src/ast/scopes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698