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

Unified Diff: src/ast/scopes.cc

Issue 2458653002: [modules] Move MODULE variable back to Scopes, before resolution (Closed)
Patch Set: Addressed comments 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 | « src/ast/scopes.h ('k') | src/parsing/parser.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 ea5357dda2d6d28c9cb1e4163fdce7906bc88aec..e83d816af777a45a4b5968ba78e21aaa57cea160 100644
--- a/src/ast/scopes.cc
+++ b/src/ast/scopes.cc
@@ -1080,6 +1080,10 @@ Declaration* Scope::CheckLexDeclarationsConflictingWith(
}
void DeclarationScope::AllocateVariables(ParseInfo* info, AnalyzeMode mode) {
+ // Module variables must be allocated before variable resolution
+ // to ensure that AccessNeedsHoleCheck() can detect import variables.
+ if (is_module_scope()) AsModuleScope()->AllocateModuleVariables();
+
ResolveVariablesRecursively(info);
AllocateVariablesRecursively();
@@ -1918,7 +1922,12 @@ void DeclarationScope::AllocateLocals() {
}
}
-void ModuleScope::AllocateModuleExports() {
+void ModuleScope::AllocateModuleVariables() {
+ for (const auto& it : module()->regular_imports()) {
+ Variable* var = LookupLocal(it.first);
+ var->AllocateTo(VariableLocation::MODULE, Variable::kModuleImportIndex);
+ }
+
for (const auto& it : module()->regular_exports()) {
Variable* var = LookupLocal(it.first);
var->AllocateTo(VariableLocation::MODULE, Variable::kModuleExportIndex);
@@ -1944,9 +1953,7 @@ void Scope::AllocateVariablesRecursively() {
// Allocate variables for this scope.
// Parameters must be allocated first, if any.
if (is_declaration_scope()) {
- if (is_module_scope()) {
- AsModuleScope()->AllocateModuleExports();
- } else if (is_function_scope()) {
+ if (is_function_scope()) {
AsDeclarationScope()->AllocateParameterLocals();
}
AsDeclarationScope()->AllocateReceiver();
« no previous file with comments | « src/ast/scopes.h ('k') | src/parsing/parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698