| 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/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
| 10 | 10 |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 PrintF("{"); | 709 PrintF("{"); |
| 710 | 710 |
| 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 // TODO(neis): Print module stuff if present. |
| 719 } | 720 } |
| 720 | 721 |
| 721 PrintF("}\n"); | 722 PrintF("}\n"); |
| 722 } | 723 } |
| 723 #endif // DEBUG | 724 #endif // DEBUG |
| 724 | 725 |
| 726 Handle<ModuleInfoEntry> ModuleInfoEntry::New(Isolate* isolate, |
| 727 Handle<Object> export_name, |
| 728 Handle<Object> local_name, |
| 729 Handle<Object> import_name, |
| 730 Handle<Object> module_request) { |
| 731 Handle<ModuleInfoEntry> result = isolate->factory()->NewModuleInfoEntry(); |
| 732 result->set(kExportNameIndex, *export_name); |
| 733 result->set(kLocalNameIndex, *local_name); |
| 734 result->set(kImportNameIndex, *import_name); |
| 735 result->set(kModuleRequestIndex, *module_request); |
| 736 return result; |
| 737 } |
| 738 |
| 725 Handle<ModuleInfo> ModuleInfo::New(Isolate* isolate, ModuleDescriptor* descr) { | 739 Handle<ModuleInfo> ModuleInfo::New(Isolate* isolate, ModuleDescriptor* descr) { |
| 726 // Serialize special exports. | 740 // Serialize special exports. |
| 727 Handle<FixedArray> special_exports = | 741 Handle<FixedArray> special_exports = |
| 728 isolate->factory()->NewFixedArray(descr->special_exports().length()); | 742 isolate->factory()->NewFixedArray(descr->special_exports().length()); |
| 729 { | 743 { |
| 730 int i = 0; | 744 int i = 0; |
| 731 for (auto entry : descr->special_exports()) { | 745 for (auto entry : descr->special_exports()) { |
| 732 special_exports->set(i++, *entry->Serialize(isolate)); | 746 special_exports->set(i++, *entry->Serialize(isolate)); |
| 733 } | 747 } |
| 734 } | 748 } |
| 735 | 749 |
| 736 // Serialize regular exports. | 750 // Serialize regular exports. |
| 737 Handle<FixedArray> regular_exports = isolate->factory()->NewFixedArray( | 751 Handle<FixedArray> regular_exports = isolate->factory()->NewFixedArray( |
| 738 static_cast<int>(descr->regular_exports().size())); | 752 static_cast<int>(descr->regular_exports().size())); |
| 739 { | 753 { |
| 740 int i = 0; | 754 int i = 0; |
| 741 for (const auto& it : descr->regular_exports()) { | 755 for (const auto& it : descr->regular_exports()) { |
| 742 regular_exports->set(i++, *it.second->Serialize(isolate)); | 756 regular_exports->set(i++, *it.second->Serialize(isolate)); |
| 743 } | 757 } |
| 744 } | 758 } |
| 745 | 759 |
| 746 Handle<ModuleInfo> result = isolate->factory()->NewModuleInfo(); | 760 Handle<ModuleInfo> result = isolate->factory()->NewModuleInfo(); |
| 747 result->set(kSpecialExportsIndex, *special_exports); | 761 result->set(kSpecialExportsIndex, *special_exports); |
| 748 result->set(kRegularExportsIndex, *regular_exports); | 762 result->set(kRegularExportsIndex, *regular_exports); |
| 749 return result; | 763 return result; |
| 750 } | 764 } |
| 751 | 765 |
| 752 } // namespace internal | 766 } // namespace internal |
| 753 } // namespace v8 | 767 } // namespace v8 |
| OLD | NEW |