Chromium Code Reviews| Index: src/ast/scopes.cc |
| diff --git a/src/ast/scopes.cc b/src/ast/scopes.cc |
| index ea5357dda2d6d28c9cb1e4163fdce7906bc88aec..f3cb4cf30cab1025deec4eeed6c3e9748c17b90e 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 export variables must be allocated before variable resolution |
|
neis
2016/10/27 12:06:04
s/export //, or am I missing something?
Maybe als
adamk
2016/10/27 12:10:01
Done and done.
|
| + // to ensure the hole check elimination code 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(); |