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

Unified Diff: src/ast/scopes.cc

Issue 2460233003: [modules] Assign cell indices at validation time. (Closed)
Patch Set: Rebase 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/ast/scopeinfo.cc ('k') | src/ast/variables.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ast/scopes.cc
diff --git a/src/ast/scopes.cc b/src/ast/scopes.cc
index 6e366b014c234d983e58a811a0ae652a3ee5e277..ec43392b0f596be64ea0e8dc1a26efdf3902816c 100644
--- a/src/ast/scopes.cc
+++ b/src/ast/scopes.cc
@@ -779,20 +779,29 @@ Variable* Scope::LookupInScopeInfo(const AstRawString* name) {
// There should be no local slot with the given name.
DCHECK_LT(scope_info_->StackSlotIndex(*name_handle), 0);
+ bool found = false;
+
+ VariableLocation location;
+ int index;
VariableMode mode;
InitializationFlag init_flag;
MaybeAssignedFlag maybe_assigned_flag;
- VariableLocation location = VariableLocation::CONTEXT;
- int index = ScopeInfo::ContextSlotIndex(scope_info_, name_handle, &mode,
- &init_flag, &maybe_assigned_flag);
- if (index < 0 && scope_type() == MODULE_SCOPE) {
+ {
+ location = VariableLocation::CONTEXT;
+ index = ScopeInfo::ContextSlotIndex(scope_info_, name_handle, &mode,
+ &init_flag, &maybe_assigned_flag);
+ found = index >= 0;
+ }
+
+ if (!found && scope_type() == MODULE_SCOPE) {
location = VariableLocation::MODULE;
index = scope_info_->ModuleIndex(name_handle, &mode, &init_flag,
&maybe_assigned_flag);
+ found = index != 0;
}
- if (index < 0) {
+ if (!found) {
index = scope_info_->FunctionContextSlotIndex(*name_handle);
if (index < 0) return nullptr; // Nowhere found.
Variable* var = AsDeclarationScope()->DeclareFunctionVar(name);
@@ -1936,12 +1945,14 @@ void DeclarationScope::AllocateLocals() {
void ModuleScope::AllocateModuleVariables() {
for (const auto& it : module()->regular_imports()) {
Variable* var = LookupLocal(it.first);
- var->AllocateTo(VariableLocation::MODULE, Variable::kModuleImportIndex);
+ var->AllocateTo(VariableLocation::MODULE, it.second->cell_index);
+ DCHECK(!var->IsExport());
}
for (const auto& it : module()->regular_exports()) {
Variable* var = LookupLocal(it.first);
- var->AllocateTo(VariableLocation::MODULE, Variable::kModuleExportIndex);
+ var->AllocateTo(VariableLocation::MODULE, it.second->cell_index);
+ DCHECK(var->IsExport());
}
}
« no previous file with comments | « src/ast/scopeinfo.cc ('k') | src/ast/variables.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698