OLD | NEW |
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 Loading... |
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 ModuleInfo::cast(get(ModuleInfoIndex())); | 520 return static_cast<ModuleInfo*>(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 Loading... |
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. | |
815 } | 814 } |
816 | 815 |
817 PrintF("}\n"); | 816 PrintF("}\n"); |
818 } | 817 } |
819 #endif // DEBUG | 818 #endif // DEBUG |
820 | 819 |
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 | |
834 Handle<ModuleInfo> ModuleInfo::New(Isolate* isolate, ModuleDescriptor* descr) { | 820 Handle<ModuleInfo> ModuleInfo::New(Isolate* isolate, ModuleDescriptor* descr) { |
835 // Serialize special exports. | 821 // Serialize special exports. |
836 Handle<FixedArray> special_exports = | 822 Handle<FixedArray> special_exports = |
837 isolate->factory()->NewFixedArray(descr->special_exports().length()); | 823 isolate->factory()->NewFixedArray(descr->special_exports().length()); |
838 { | 824 { |
839 int i = 0; | 825 int i = 0; |
840 for (auto entry : descr->special_exports()) { | 826 for (auto entry : descr->special_exports()) { |
841 special_exports->set(i++, *entry->Serialize(isolate)); | 827 special_exports->set(i++, *entry->Serialize(isolate)); |
842 } | 828 } |
843 } | 829 } |
844 | 830 |
845 // Serialize regular exports. | 831 // Serialize regular exports. |
846 Handle<FixedArray> regular_exports = isolate->factory()->NewFixedArray( | 832 Handle<FixedArray> regular_exports = isolate->factory()->NewFixedArray( |
847 static_cast<int>(descr->regular_exports().size())); | 833 static_cast<int>(descr->regular_exports().size())); |
848 { | 834 { |
849 int i = 0; | 835 int i = 0; |
850 for (const auto& it : descr->regular_exports()) { | 836 for (const auto& it : descr->regular_exports()) { |
851 regular_exports->set(i++, *it.second->Serialize(isolate)); | 837 regular_exports->set(i++, *it.second->Serialize(isolate)); |
852 } | 838 } |
853 } | 839 } |
854 | 840 |
855 Handle<ModuleInfo> result = isolate->factory()->NewModuleInfo(); | 841 Handle<ModuleInfo> result = isolate->factory()->NewModuleInfo(); |
856 result->set(kSpecialExportsIndex, *special_exports); | 842 result->set(kSpecialExportsIndex, *special_exports); |
857 result->set(kRegularExportsIndex, *regular_exports); | 843 result->set(kRegularExportsIndex, *regular_exports); |
858 return result; | 844 return result; |
859 } | 845 } |
860 | 846 |
861 } // namespace internal | 847 } // namespace internal |
862 } // namespace v8 | 848 } // namespace v8 |
OLD | NEW |