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

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

Issue 2273013002: [modules] Split exports into regular and special, store regular ones in a multimap. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
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
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 1581 matching lines...) Expand 10 before | Expand all | Expand 10 after
1592 if (new_target_ != nullptr && !MustAllocate(new_target_)) { 1592 if (new_target_ != nullptr && !MustAllocate(new_target_)) {
1593 new_target_ = nullptr; 1593 new_target_ = nullptr;
1594 } 1594 }
1595 1595
1596 if (this_function_ != nullptr && !MustAllocate(this_function_)) { 1596 if (this_function_ != nullptr && !MustAllocate(this_function_)) {
1597 this_function_ = nullptr; 1597 this_function_ = nullptr;
1598 } 1598 }
1599 } 1599 }
1600 1600
1601 void ModuleScope::AllocateModuleVariables() { 1601 void ModuleScope::AllocateModuleVariables() {
1602 for (auto it = module()->regular_imports().begin(); 1602 for (const auto& it : module()->regular_imports()) {
1603 it != module()->regular_imports().end(); ++it) { 1603 Variable* var = LookupLocal(it.first);
1604 Variable* var = LookupLocal(it->second->local_name);
1605 // TODO(neis): Use a meaningful index. 1604 // TODO(neis): Use a meaningful index.
1606 var->AllocateTo(VariableLocation::MODULE, 42); 1605 var->AllocateTo(VariableLocation::MODULE, 42);
1607 } 1606 }
1608 1607
1609 for (auto entry : module()->exports()) { 1608 for (const auto& it : module()->regular_exports()) {
1610 if (entry->local_name == nullptr) continue; 1609 Variable* var = LookupLocal(it.first);
1611 Variable* var = LookupLocal(entry->local_name); 1610 var->AllocateTo(VariableLocation::MODULE, 0);
1612 var->AllocateTo(VariableLocation::MODULE, 42);
1613 } 1611 }
1614 } 1612 }
1615 1613
1616 void Scope::AllocateVariablesRecursively() { 1614 void Scope::AllocateVariablesRecursively() {
1617 DCHECK(!already_resolved_); 1615 DCHECK(!already_resolved_);
1618 DCHECK_EQ(0, num_stack_slots_); 1616 DCHECK_EQ(0, num_stack_slots_);
1619 1617
1620 // Allocate variables for inner scopes. 1618 // Allocate variables for inner scopes.
1621 for (Scope* scope = inner_scope_; scope != nullptr; scope = scope->sibling_) { 1619 for (Scope* scope = inner_scope_; scope != nullptr; scope = scope->sibling_) {
1622 scope->AllocateVariablesRecursively(); 1620 scope->AllocateVariablesRecursively();
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1673 function != nullptr && function->IsContextSlot(); 1671 function != nullptr && function->IsContextSlot();
1674 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - num_global_slots() - 1672 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - num_global_slots() -
1675 (is_function_var_in_context ? 1 : 0); 1673 (is_function_var_in_context ? 1 : 0);
1676 } 1674 }
1677 1675
1678 1676
1679 int Scope::ContextGlobalCount() const { return num_global_slots(); } 1677 int Scope::ContextGlobalCount() const { return num_global_slots(); }
1680 1678
1681 } // namespace internal 1679 } // namespace internal
1682 } // namespace v8 1680 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698