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

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

Issue 2473993002: [modules] Make handling of module info's regular exports more robust. (Closed)
Patch Set: cast size_t 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 | « src/ast/modules.cc ('k') | src/ast/scopes.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 920 matching lines...) Expand 10 before | Expand all | Expand 10 after
931 931
932 Handle<ModuleInfo> result = isolate->factory()->NewModuleInfo(); 932 Handle<ModuleInfo> result = isolate->factory()->NewModuleInfo();
933 result->set(kModuleRequestsIndex, *module_requests); 933 result->set(kModuleRequestsIndex, *module_requests);
934 result->set(kSpecialExportsIndex, *special_exports); 934 result->set(kSpecialExportsIndex, *special_exports);
935 result->set(kRegularExportsIndex, *regular_exports); 935 result->set(kRegularExportsIndex, *regular_exports);
936 result->set(kNamespaceImportsIndex, *namespace_imports); 936 result->set(kNamespaceImportsIndex, *namespace_imports);
937 result->set(kRegularImportsIndex, *regular_imports); 937 result->set(kRegularImportsIndex, *regular_imports);
938 return result; 938 return result;
939 } 939 }
940 940
941 int ModuleInfo::RegularExportCount() const {
942 DCHECK_EQ(regular_exports()->length() % kRegularExportLength, 0);
943 return regular_exports()->length() / kRegularExportLength;
944 }
945
946 String* ModuleInfo::RegularExportLocalName(int i) const {
947 return String::cast(regular_exports()->get(i * kRegularExportLength +
948 kRegularExportLocalNameOffset));
949 }
950
951 int ModuleInfo::RegularExportCellIndex(int i) const {
952 return Smi::cast(regular_exports()->get(i * kRegularExportLength +
953 kRegularExportCellIndexOffset))
954 ->value();
955 }
956
957 FixedArray* ModuleInfo::RegularExportExportNames(int i) const {
958 return FixedArray::cast(regular_exports()->get(
959 i * kRegularExportLength + kRegularExportExportNamesOffset));
960 }
961
941 Handle<ModuleInfoEntry> ModuleInfo::LookupRegularImport( 962 Handle<ModuleInfoEntry> ModuleInfo::LookupRegularImport(
942 Handle<ModuleInfo> info, Handle<String> local_name) { 963 Handle<ModuleInfo> info, Handle<String> local_name) {
943 Isolate* isolate = info->GetIsolate(); 964 Isolate* isolate = info->GetIsolate();
944 Handle<FixedArray> regular_imports(info->regular_imports(), isolate); 965 Handle<FixedArray> regular_imports(info->regular_imports(), isolate);
945 for (int i = 0, n = regular_imports->length(); i < n; ++i) { 966 for (int i = 0, n = regular_imports->length(); i < n; ++i) {
946 Handle<ModuleInfoEntry> entry( 967 Handle<ModuleInfoEntry> entry(
947 ModuleInfoEntry::cast(regular_imports->get(i)), isolate); 968 ModuleInfoEntry::cast(regular_imports->get(i)), isolate);
948 if (String::cast(entry->local_name())->Equals(*local_name)) { 969 if (String::cast(entry->local_name())->Equals(*local_name)) {
949 return entry; 970 return entry;
950 } 971 }
951 } 972 }
952 UNREACHABLE(); 973 UNREACHABLE();
953 return Handle<ModuleInfoEntry>(); 974 return Handle<ModuleInfoEntry>();
954 } 975 }
955 976
956 } // namespace internal 977 } // namespace internal
957 } // namespace v8 978 } // namespace v8
OLDNEW
« no previous file with comments | « src/ast/modules.cc ('k') | src/ast/scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698