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/ast/ast.h" | 10 #include "src/ast/ast.h" |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 ModuleScope::ModuleScope(Isolate* isolate, Handle<ScopeInfo> scope_info, | 160 ModuleScope::ModuleScope(Isolate* isolate, Handle<ScopeInfo> scope_info, |
161 AstValueFactory* avfactory) | 161 AstValueFactory* avfactory) |
162 : DeclarationScope(avfactory->zone(), MODULE_SCOPE, scope_info) { | 162 : DeclarationScope(avfactory->zone(), MODULE_SCOPE, scope_info) { |
163 Zone* zone = avfactory->zone(); | 163 Zone* zone = avfactory->zone(); |
164 ModuleInfo* module_info = scope_info->ModuleDescriptorInfo(); | 164 ModuleInfo* module_info = scope_info->ModuleDescriptorInfo(); |
165 | 165 |
166 set_language_mode(STRICT); | 166 set_language_mode(STRICT); |
167 module_descriptor_ = new (zone) ModuleDescriptor(zone); | 167 module_descriptor_ = new (zone) ModuleDescriptor(zone); |
168 | 168 |
169 // Deserialize special exports. | 169 // Deserialize special exports. |
170 Handle<FixedArray> special_exports = handle(module_info->special_exports()); | 170 Handle<FixedArray> special_exports(module_info->special_exports(), isolate); |
171 for (int i = 0, n = special_exports->length(); i < n; ++i) { | 171 for (int i = 0, n = special_exports->length(); i < n; ++i) { |
172 Handle<ModuleInfoEntry> serialized_entry( | 172 Handle<ModuleInfoEntry> serialized_entry( |
173 ModuleInfoEntry::cast(special_exports->get(i)), isolate); | 173 ModuleInfoEntry::cast(special_exports->get(i)), isolate); |
174 module_descriptor_->AddSpecialExport( | 174 module_descriptor_->AddSpecialExport( |
175 ModuleDescriptor::Entry::Deserialize(isolate, avfactory, | 175 ModuleDescriptor::Entry::Deserialize(isolate, avfactory, |
176 serialized_entry), | 176 serialized_entry), |
177 avfactory->zone()); | 177 avfactory->zone()); |
178 } | 178 } |
179 | 179 |
180 // Deserialize regular exports. | 180 // Deserialize regular exports. |
181 Handle<FixedArray> regular_exports = handle(module_info->regular_exports()); | 181 Handle<FixedArray> regular_exports(module_info->regular_exports(), isolate); |
182 for (int i = 0, n = regular_exports->length(); i < n; ++i) { | 182 module_descriptor_->DeserializeRegularExports(isolate, avfactory, |
183 Handle<ModuleInfoEntry> serialized_entry( | 183 regular_exports); |
184 ModuleInfoEntry::cast(regular_exports->get(i)), isolate); | |
185 module_descriptor_->AddRegularExport(ModuleDescriptor::Entry::Deserialize( | |
186 isolate, avfactory, serialized_entry)); | |
187 } | |
188 | 184 |
189 // Deserialize special imports. | 185 // Deserialize special imports. |
190 Handle<FixedArray> special_imports = handle(module_info->special_imports()); | 186 Handle<FixedArray> special_imports(module_info->special_imports(), isolate); |
191 for (int i = 0, n = special_imports->length(); i < n; ++i) { | 187 for (int i = 0, n = special_imports->length(); i < n; ++i) { |
192 Handle<ModuleInfoEntry> serialized_entry( | 188 Handle<ModuleInfoEntry> serialized_entry( |
193 ModuleInfoEntry::cast(special_imports->get(i)), isolate); | 189 ModuleInfoEntry::cast(special_imports->get(i)), isolate); |
194 module_descriptor_->AddSpecialImport( | 190 module_descriptor_->AddSpecialImport( |
195 ModuleDescriptor::Entry::Deserialize(isolate, avfactory, | 191 ModuleDescriptor::Entry::Deserialize(isolate, avfactory, |
196 serialized_entry), | 192 serialized_entry), |
197 avfactory->zone()); | 193 avfactory->zone()); |
198 } | 194 } |
199 | 195 |
200 // Deserialize regular imports. | 196 // Deserialize regular imports. |
201 Handle<FixedArray> regular_imports = handle(module_info->regular_imports()); | 197 Handle<FixedArray> regular_imports(module_info->regular_imports(), isolate); |
202 for (int i = 0, n = regular_imports->length(); i < n; ++i) { | 198 for (int i = 0, n = regular_imports->length(); i < n; ++i) { |
203 Handle<ModuleInfoEntry> serialized_entry( | 199 Handle<ModuleInfoEntry> serialized_entry( |
204 ModuleInfoEntry::cast(regular_imports->get(i)), isolate); | 200 ModuleInfoEntry::cast(regular_imports->get(i)), isolate); |
205 module_descriptor_->AddRegularImport(ModuleDescriptor::Entry::Deserialize( | 201 module_descriptor_->AddRegularImport(ModuleDescriptor::Entry::Deserialize( |
206 isolate, avfactory, serialized_entry)); | 202 isolate, avfactory, serialized_entry)); |
207 } | 203 } |
208 } | 204 } |
209 | 205 |
210 Scope::Scope(Zone* zone, ScopeType scope_type, Handle<ScopeInfo> scope_info) | 206 Scope::Scope(Zone* zone, ScopeType scope_type, Handle<ScopeInfo> scope_info) |
211 : zone_(zone), | 207 : zone_(zone), |
(...skipping 1633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1845 Variable* function = | 1841 Variable* function = |
1846 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; | 1842 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; |
1847 bool is_function_var_in_context = | 1843 bool is_function_var_in_context = |
1848 function != nullptr && function->IsContextSlot(); | 1844 function != nullptr && function->IsContextSlot(); |
1849 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - | 1845 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - |
1850 (is_function_var_in_context ? 1 : 0); | 1846 (is_function_var_in_context ? 1 : 0); |
1851 } | 1847 } |
1852 | 1848 |
1853 } // namespace internal | 1849 } // namespace internal |
1854 } // namespace v8 | 1850 } // namespace v8 |
OLD | NEW |