| 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/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
| (...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 DeclarationScope* scope = info->literal()->scope(); | 454 DeclarationScope* scope = info->literal()->scope(); |
| 455 | 455 |
| 456 // We are compiling one of three cases: | 456 // We are compiling one of three cases: |
| 457 // 1) top-level code, | 457 // 1) top-level code, |
| 458 // 2) a function/eval/module on the top-level | 458 // 2) a function/eval/module on the top-level |
| 459 // 3) a function/eval in a scope that was already resolved. | 459 // 3) a function/eval in a scope that was already resolved. |
| 460 DCHECK(scope->scope_type() == SCRIPT_SCOPE || | 460 DCHECK(scope->scope_type() == SCRIPT_SCOPE || |
| 461 scope->outer_scope()->scope_type() == SCRIPT_SCOPE || | 461 scope->outer_scope()->scope_type() == SCRIPT_SCOPE || |
| 462 scope->outer_scope()->already_resolved_); | 462 scope->outer_scope()->already_resolved_); |
| 463 | 463 |
| 464 // For modules, we want to start variable allocation at the surrounding script | |
| 465 // scope. | |
| 466 if (scope->is_module_scope()) { | |
| 467 scope = scope->outer_scope()->AsDeclarationScope(); | |
| 468 } | |
| 469 | |
| 470 scope->AllocateVariables(info, mode); | 464 scope->AllocateVariables(info, mode); |
| 471 | 465 |
| 472 #ifdef DEBUG | 466 #ifdef DEBUG |
| 473 if (info->script_is_native() ? FLAG_print_builtin_scopes | 467 if (info->script_is_native() ? FLAG_print_builtin_scopes |
| 474 : FLAG_print_scopes) { | 468 : FLAG_print_scopes) { |
| 475 scope->Print(); | 469 scope->Print(); |
| 476 } | 470 } |
| 477 scope->CheckScopePositions(); | 471 scope->CheckScopePositions(); |
| 478 scope->CheckZones(); | 472 scope->CheckZones(); |
| 479 #endif | 473 #endif |
| (...skipping 1216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1696 Variable* function = | 1690 Variable* function = |
| 1697 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; | 1691 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; |
| 1698 bool is_function_var_in_context = | 1692 bool is_function_var_in_context = |
| 1699 function != nullptr && function->IsContextSlot(); | 1693 function != nullptr && function->IsContextSlot(); |
| 1700 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - | 1694 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - |
| 1701 (is_function_var_in_context ? 1 : 0); | 1695 (is_function_var_in_context ? 1 : 0); |
| 1702 } | 1696 } |
| 1703 | 1697 |
| 1704 } // namespace internal | 1698 } // namespace internal |
| 1705 } // namespace v8 | 1699 } // namespace v8 |
| OLD | NEW |