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 1685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 Loading... |
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 |
OLD | NEW |