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

Unified Diff: src/ast/scopeinfo.cc

Issue 2445683002: [modules] Add partial support for debug-scopes. (Closed)
Patch Set: Fix handle bug. Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/contexts.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ast/scopeinfo.cc
diff --git a/src/ast/scopeinfo.cc b/src/ast/scopeinfo.cc
index 5d0212c750b5916c1d95de1da83f9692a9f47643..5b90b8553797065523eb9941008b0cfd0abdd042 100644
--- a/src/ast/scopeinfo.cc
+++ b/src/ast/scopeinfo.cc
@@ -647,12 +647,8 @@ int ScopeInfo::ModuleIndex(Handle<String> name, VariableMode* mode,
int entry = ModuleVariablesIndex();
for (int i = 0; i < module_vars_count; ++i) {
if (*name == get(entry + kModuleVariableNameOffset)) {
- int index = Smi::cast(get(entry + kModuleVariableIndexOffset))->value();
- int properties =
- Smi::cast(get(entry + kModuleVariablePropertiesOffset))->value();
- *mode = VariableModeField::decode(properties);
- *init_flag = InitFlagField::decode(properties);
- *maybe_assigned_flag = MaybeAssignedFlagField::decode(properties);
+ int index;
+ ModuleVariable(i, nullptr, &index, mode, init_flag, maybe_assigned_flag);
return index;
}
entry += kModuleVariableEntryLength;
@@ -794,6 +790,34 @@ int ScopeInfo::ModuleVariableCountIndex() { return ModuleInfoIndex() + 1; }
int ScopeInfo::ModuleVariablesIndex() { return ModuleVariableCountIndex() + 1; }
+void ScopeInfo::ModuleVariable(int i, String** name, int* index,
+ VariableMode* mode,
+ InitializationFlag* init_flag,
+ MaybeAssignedFlag* maybe_assigned_flag) {
+ DCHECK_LE(0, i);
+ DCHECK_LT(i, Smi::cast(get(ModuleVariableCountIndex()))->value());
+
+ int entry = ModuleVariablesIndex() + i * kModuleVariableEntryLength;
+ int properties =
+ Smi::cast(get(entry + kModuleVariablePropertiesOffset))->value();
+
+ if (name != nullptr) {
+ *name = String::cast(get(entry + kModuleVariableNameOffset));
+ }
+ if (index != nullptr) {
+ *index = Smi::cast(get(entry + kModuleVariableIndexOffset))->value();
+ }
+ if (mode != nullptr) {
+ *mode = VariableModeField::decode(properties);
+ }
+ if (init_flag != nullptr) {
+ *init_flag = InitFlagField::decode(properties);
+ }
+ if (maybe_assigned_flag != nullptr) {
+ *maybe_assigned_flag = MaybeAssignedFlagField::decode(properties);
+ }
+}
+
#ifdef DEBUG
static void PrintList(const char* list_name,
@@ -867,7 +891,8 @@ Handle<ModuleInfo> ModuleInfo::New(Isolate* isolate, Zone* zone,
{
int i = 0;
for (auto entry : descr->special_exports()) {
- special_exports->set(i++, *entry->Serialize(isolate));
+ Handle<ModuleInfoEntry> serialized_entry = entry->Serialize(isolate);
+ special_exports->set(i++, *serialized_entry);
}
}
@@ -877,7 +902,8 @@ Handle<ModuleInfo> ModuleInfo::New(Isolate* isolate, Zone* zone,
{
int i = 0;
for (auto entry : descr->namespace_imports()) {
- namespace_imports->set(i++, *entry->Serialize(isolate));
+ Handle<ModuleInfoEntry> serialized_entry = entry->Serialize(isolate);
+ namespace_imports->set(i++, *serialized_entry);
}
}
@@ -891,7 +917,9 @@ Handle<ModuleInfo> ModuleInfo::New(Isolate* isolate, Zone* zone,
{
int i = 0;
for (const auto& elem : descr->regular_imports()) {
- regular_imports->set(i++, *elem.second->Serialize(isolate));
+ Handle<ModuleInfoEntry> serialized_entry =
+ elem.second->Serialize(isolate);
+ regular_imports->set(i++, *serialized_entry);
}
}
@@ -904,5 +932,20 @@ Handle<ModuleInfo> ModuleInfo::New(Isolate* isolate, Zone* zone,
return result;
}
+Handle<ModuleInfoEntry> ModuleInfo::LookupRegularImport(
+ Handle<ModuleInfo> info, Handle<String> local_name) {
+ Isolate* isolate = info->GetIsolate();
+ Handle<FixedArray> regular_imports(info->regular_imports(), isolate);
+ for (int i = 0, n = regular_imports->length(); i < n; ++i) {
+ Handle<ModuleInfoEntry> entry(
+ ModuleInfoEntry::cast(regular_imports->get(i)), isolate);
+ if (String::cast(entry->local_name())->Equals(*local_name)) {
+ return entry;
+ }
+ }
+ UNREACHABLE();
+ return Handle<ModuleInfoEntry>();
+}
+
} // namespace internal
} // namespace v8
« 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