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

Side by Side Diff: src/ast/scopes.cc

Issue 2289293006: [modules] Ignore the surrounding script scope. (Closed)
Patch Set: Created 4 years, 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698