OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 "src/ast/scopes.h" | 5 #include "src/ast/scopes.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "src/accessors.h" | 9 #include "src/accessors.h" |
10 #include "src/ast/ast.h" | 10 #include "src/ast/ast.h" |
(...skipping 1865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1876 for (Scope* scope = inner_scope_; scope != nullptr; | 1876 for (Scope* scope = inner_scope_; scope != nullptr; |
1877 scope = scope->sibling_) { | 1877 scope = scope->sibling_) { |
1878 scope->ResolveVariablesRecursively(info); | 1878 scope->ResolveVariablesRecursively(info); |
1879 } | 1879 } |
1880 } | 1880 } |
1881 } | 1881 } |
1882 | 1882 |
1883 VariableProxy* Scope::FetchFreeVariables(DeclarationScope* max_outer_scope, | 1883 VariableProxy* Scope::FetchFreeVariables(DeclarationScope* max_outer_scope, |
1884 ParseInfo* info, | 1884 ParseInfo* info, |
1885 VariableProxy* stack) { | 1885 VariableProxy* stack) { |
| 1886 // Module variables must be allocated before variable resolution |
| 1887 // to ensure that AccessNeedsHoleCheck() can detect import variables. |
| 1888 if (info != nullptr && is_module_scope()) { |
| 1889 AsModuleScope()->AllocateModuleVariables(); |
| 1890 } |
1886 // Lazy parsed declaration scopes are already partially analyzed. If there are | 1891 // Lazy parsed declaration scopes are already partially analyzed. If there are |
1887 // unresolved references remaining, they just need to be resolved in outer | 1892 // unresolved references remaining, they just need to be resolved in outer |
1888 // scopes. | 1893 // scopes. |
1889 Scope* lookup = | 1894 Scope* lookup = |
1890 is_declaration_scope() && AsDeclarationScope()->was_lazily_parsed() | 1895 is_declaration_scope() && AsDeclarationScope()->was_lazily_parsed() |
1891 ? outer_scope() | 1896 ? outer_scope() |
1892 : this; | 1897 : this; |
1893 for (VariableProxy *proxy = unresolved_, *next = nullptr; proxy != nullptr; | 1898 for (VariableProxy *proxy = unresolved_, *next = nullptr; proxy != nullptr; |
1894 proxy = next) { | 1899 proxy = next) { |
1895 next = proxy->next_unresolved(); | 1900 next = proxy->next_unresolved(); |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2207 Variable* function = | 2212 Variable* function = |
2208 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; | 2213 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; |
2209 bool is_function_var_in_context = | 2214 bool is_function_var_in_context = |
2210 function != nullptr && function->IsContextSlot(); | 2215 function != nullptr && function->IsContextSlot(); |
2211 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - | 2216 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - |
2212 (is_function_var_in_context ? 1 : 0); | 2217 (is_function_var_in_context ? 1 : 0); |
2213 } | 2218 } |
2214 | 2219 |
2215 } // namespace internal | 2220 } // namespace internal |
2216 } // namespace v8 | 2221 } // namespace v8 |
OLD | NEW |