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

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

Issue 2224333002: [modules] Split imports into regular and special, store regular ones in a map. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 4 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 | « src/ast/modules.cc ('k') | test/cctest/test-parsing.cc » ('j') | 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 1685 matching lines...) Expand 10 before | Expand all | Expand 10 after
1696 if (new_target_ != nullptr && !MustAllocate(new_target_)) { 1696 if (new_target_ != nullptr && !MustAllocate(new_target_)) {
1697 new_target_ = nullptr; 1697 new_target_ = nullptr;
1698 } 1698 }
1699 1699
1700 if (this_function_ != nullptr && !MustAllocate(this_function_)) { 1700 if (this_function_ != nullptr && !MustAllocate(this_function_)) {
1701 this_function_ = nullptr; 1701 this_function_ = nullptr;
1702 } 1702 }
1703 } 1703 }
1704 1704
1705 void DeclarationScope::AllocateModuleVariables() { 1705 void DeclarationScope::AllocateModuleVariables() {
1706 for (auto entry : module()->imports()) { 1706 for (auto it = module()->regular_imports().begin();
1707 if (entry->local_name == nullptr) continue; 1707 it != module()->regular_imports().end(); ++it) {
1708 if (entry->import_name == nullptr) continue; // Namespace import. 1708 Variable* var = LookupLocal(it->second->local_name);
1709 Variable* var = LookupLocal(entry->local_name);
1710 // TODO(neis): Use a meaningful index. 1709 // TODO(neis): Use a meaningful index.
1711 var->AllocateTo(VariableLocation::MODULE, 42); 1710 var->AllocateTo(VariableLocation::MODULE, 42);
1712 } 1711 }
1712
1713 for (auto entry : module()->exports()) { 1713 for (auto entry : module()->exports()) {
1714 if (entry->local_name == nullptr) continue; 1714 if (entry->local_name == nullptr) continue;
1715 Variable* var = LookupLocal(entry->local_name); 1715 Variable* var = LookupLocal(entry->local_name);
1716 var->AllocateTo(VariableLocation::MODULE, 42); 1716 var->AllocateTo(VariableLocation::MODULE, 42);
1717 } 1717 }
1718 } 1718 }
1719 1719
1720 void Scope::AllocateVariablesRecursively(AstValueFactory* ast_value_factory) { 1720 void Scope::AllocateVariablesRecursively(AstValueFactory* ast_value_factory) {
1721 if (!already_resolved()) { 1721 if (!already_resolved()) {
1722 num_stack_slots_ = 0; 1722 num_stack_slots_ = 0;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1780 function != NULL && function->proxy()->var()->IsContextSlot(); 1780 function != NULL && function->proxy()->var()->IsContextSlot();
1781 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - num_global_slots() - 1781 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - num_global_slots() -
1782 (is_function_var_in_context ? 1 : 0); 1782 (is_function_var_in_context ? 1 : 0);
1783 } 1783 }
1784 1784
1785 1785
1786 int Scope::ContextGlobalCount() const { return num_global_slots(); } 1786 int Scope::ContextGlobalCount() const { return num_global_slots(); }
1787 1787
1788 } // namespace internal 1788 } // namespace internal
1789 } // namespace v8 1789 } // namespace v8
OLDNEW
« no previous file with comments | « src/ast/modules.cc ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698