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

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

Issue 2449883002: Revert of [modules] Add partial support for debug-scopes. (Closed)
Patch Set: Created 4 years, 1 month 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 | « no previous file | src/contexts.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 629 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 DCHECK_EQ(scope_type(), MODULE_SCOPE); 640 DCHECK_EQ(scope_type(), MODULE_SCOPE);
641 DCHECK(name->IsInternalizedString()); 641 DCHECK(name->IsInternalizedString());
642 DCHECK_NOT_NULL(mode); 642 DCHECK_NOT_NULL(mode);
643 DCHECK_NOT_NULL(init_flag); 643 DCHECK_NOT_NULL(init_flag);
644 DCHECK_NOT_NULL(maybe_assigned_flag); 644 DCHECK_NOT_NULL(maybe_assigned_flag);
645 645
646 int module_vars_count = Smi::cast(get(ModuleVariableCountIndex()))->value(); 646 int module_vars_count = Smi::cast(get(ModuleVariableCountIndex()))->value();
647 int entry = ModuleVariablesIndex(); 647 int entry = ModuleVariablesIndex();
648 for (int i = 0; i < module_vars_count; ++i) { 648 for (int i = 0; i < module_vars_count; ++i) {
649 if (*name == get(entry + kModuleVariableNameOffset)) { 649 if (*name == get(entry + kModuleVariableNameOffset)) {
650 int index; 650 int index = Smi::cast(get(entry + kModuleVariableIndexOffset))->value();
651 ModuleVariable(i, nullptr, &index, mode, init_flag, maybe_assigned_flag); 651 int properties =
652 Smi::cast(get(entry + kModuleVariablePropertiesOffset))->value();
653 *mode = VariableModeField::decode(properties);
654 *init_flag = InitFlagField::decode(properties);
655 *maybe_assigned_flag = MaybeAssignedFlagField::decode(properties);
652 return index; 656 return index;
653 } 657 }
654 entry += kModuleVariableEntryLength; 658 entry += kModuleVariableEntryLength;
655 } 659 }
656 660
657 return -1; 661 return -1;
658 } 662 }
659 663
660 int ScopeInfo::ContextSlotIndex(Handle<ScopeInfo> scope_info, 664 int ScopeInfo::ContextSlotIndex(Handle<ScopeInfo> scope_info,
661 Handle<String> name, VariableMode* mode, 665 Handle<String> name, VariableMode* mode,
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 } 787 }
784 788
785 int ScopeInfo::ModuleInfoIndex() { 789 int ScopeInfo::ModuleInfoIndex() {
786 return OuterScopeInfoIndex() + (HasOuterScopeInfo() ? 1 : 0); 790 return OuterScopeInfoIndex() + (HasOuterScopeInfo() ? 1 : 0);
787 } 791 }
788 792
789 int ScopeInfo::ModuleVariableCountIndex() { return ModuleInfoIndex() + 1; } 793 int ScopeInfo::ModuleVariableCountIndex() { return ModuleInfoIndex() + 1; }
790 794
791 int ScopeInfo::ModuleVariablesIndex() { return ModuleVariableCountIndex() + 1; } 795 int ScopeInfo::ModuleVariablesIndex() { return ModuleVariableCountIndex() + 1; }
792 796
793 void ScopeInfo::ModuleVariable(int i, String** name, int* index,
794 VariableMode* mode,
795 InitializationFlag* init_flag,
796 MaybeAssignedFlag* maybe_assigned_flag) {
797 DCHECK_LE(0, i);
798 DCHECK_LT(i, Smi::cast(get(ModuleVariableCountIndex()))->value());
799
800 int entry = ModuleVariablesIndex() + i * kModuleVariableEntryLength;
801 int properties =
802 Smi::cast(get(entry + kModuleVariablePropertiesOffset))->value();
803
804 if (name != nullptr) {
805 *name = String::cast(get(entry + kModuleVariableNameOffset));
806 }
807 if (index != nullptr) {
808 *index = Smi::cast(get(entry + kModuleVariableIndexOffset))->value();
809 }
810 if (mode != nullptr) {
811 *mode = VariableModeField::decode(properties);
812 }
813 if (init_flag != nullptr) {
814 *init_flag = InitFlagField::decode(properties);
815 }
816 if (maybe_assigned_flag != nullptr) {
817 *maybe_assigned_flag = MaybeAssignedFlagField::decode(properties);
818 }
819 }
820
821 #ifdef DEBUG 797 #ifdef DEBUG
822 798
823 static void PrintList(const char* list_name, 799 static void PrintList(const char* list_name,
824 int nof_internal_slots, 800 int nof_internal_slots,
825 int start, 801 int start,
826 int end, 802 int end,
827 ScopeInfo* scope_info) { 803 ScopeInfo* scope_info) {
828 if (start < end) { 804 if (start < end) {
829 PrintF("\n // %s\n", list_name); 805 PrintF("\n // %s\n", list_name);
830 if (nof_internal_slots > 0) { 806 if (nof_internal_slots > 0) {
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
921 897
922 Handle<ModuleInfo> result = isolate->factory()->NewModuleInfo(); 898 Handle<ModuleInfo> result = isolate->factory()->NewModuleInfo();
923 result->set(kModuleRequestsIndex, *module_requests); 899 result->set(kModuleRequestsIndex, *module_requests);
924 result->set(kSpecialExportsIndex, *special_exports); 900 result->set(kSpecialExportsIndex, *special_exports);
925 result->set(kRegularExportsIndex, *regular_exports); 901 result->set(kRegularExportsIndex, *regular_exports);
926 result->set(kNamespaceImportsIndex, *namespace_imports); 902 result->set(kNamespaceImportsIndex, *namespace_imports);
927 result->set(kRegularImportsIndex, *regular_imports); 903 result->set(kRegularImportsIndex, *regular_imports);
928 return result; 904 return result;
929 } 905 }
930 906
931 Handle<ModuleInfoEntry> ModuleInfo::LookupRegularImport(
932 Handle<ModuleInfo> info, Handle<String> local_name) {
933 Isolate* isolate = info->GetIsolate();
934 Handle<FixedArray> regular_imports(info->regular_imports(), isolate);
935 for (int i = 0, n = regular_imports->length(); i < n; ++i) {
936 Handle<ModuleInfoEntry> entry(
937 ModuleInfoEntry::cast(regular_imports->get(i)), isolate);
938 if (String::cast(entry->local_name())->Equals(*local_name)) {
939 return entry;
940 }
941 }
942 UNREACHABLE();
943 return Handle<ModuleInfoEntry>();
944 }
945
946 } // namespace internal 907 } // namespace internal
947 } // namespace v8 908 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/contexts.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698