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

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

Issue 2328283002: Revert of [modules] Basic support of exports (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 | « src/ast/scopes.h ('k') | src/ast/variables.h » ('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/ast/ast.h" 10 #include "src/ast/ast.h"
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 : DeclarationScope(avfactory->zone(), MODULE_SCOPE, scope_info) { 164 : DeclarationScope(avfactory->zone(), MODULE_SCOPE, scope_info) {
165 Zone* zone = avfactory->zone(); 165 Zone* zone = avfactory->zone();
166 ModuleInfo* module_info = scope_info->ModuleDescriptorInfo(); 166 ModuleInfo* module_info = scope_info->ModuleDescriptorInfo();
167 167
168 set_language_mode(STRICT); 168 set_language_mode(STRICT);
169 module_descriptor_ = new (zone) ModuleDescriptor(zone); 169 module_descriptor_ = new (zone) ModuleDescriptor(zone);
170 170
171 // Deserialize special exports. 171 // Deserialize special exports.
172 Handle<FixedArray> special_exports = handle(module_info->special_exports()); 172 Handle<FixedArray> special_exports = handle(module_info->special_exports());
173 for (int i = 0, n = special_exports->length(); i < n; ++i) { 173 for (int i = 0, n = special_exports->length(); i < n; ++i) {
174 Handle<ModuleInfoEntry> serialized_entry( 174 Handle<FixedArray> serialized_entry(
175 ModuleInfoEntry::cast(special_exports->get(i)), isolate); 175 FixedArray::cast(special_exports->get(i)), isolate);
176 module_descriptor_->AddSpecialExport( 176 module_descriptor_->AddSpecialExport(
177 ModuleDescriptor::Entry::Deserialize(isolate, avfactory, 177 ModuleDescriptor::Entry::Deserialize(isolate, avfactory,
178 serialized_entry), 178 serialized_entry),
179 avfactory->zone()); 179 avfactory->zone());
180 } 180 }
181 181
182 // Deserialize regular exports. 182 // Deserialize regular exports.
183 Handle<FixedArray> regular_exports = handle(module_info->regular_exports()); 183 Handle<FixedArray> regular_exports = handle(module_info->regular_exports());
184 for (int i = 0, n = regular_exports->length(); i < n; ++i) { 184 for (int i = 0, n = regular_exports->length(); i < n; ++i) {
185 Handle<ModuleInfoEntry> serialized_entry( 185 Handle<FixedArray> serialized_entry(
186 ModuleInfoEntry::cast(regular_exports->get(i)), isolate); 186 FixedArray::cast(regular_exports->get(i)), isolate);
187 module_descriptor_->AddRegularExport(ModuleDescriptor::Entry::Deserialize( 187 module_descriptor_->AddRegularExport(ModuleDescriptor::Entry::Deserialize(
188 isolate, avfactory, serialized_entry)); 188 isolate, avfactory, serialized_entry));
189 } 189 }
190 } 190 }
191 191
192 Scope::Scope(Zone* zone, ScopeType scope_type, Handle<ScopeInfo> scope_info) 192 Scope::Scope(Zone* zone, ScopeType scope_type, Handle<ScopeInfo> scope_info)
193 : zone_(zone), 193 : zone_(zone),
194 outer_scope_(nullptr), 194 outer_scope_(nullptr),
195 variables_(zone), 195 variables_(zone),
196 locals_(0, zone), 196 locals_(0, zone),
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after
822 Variable* var = scope->LookupLocal(name); 822 Variable* var = scope->LookupLocal(name);
823 if (var != NULL) return var; 823 if (var != NULL) return var;
824 } 824 }
825 return NULL; 825 return NULL;
826 } 826 }
827 827
828 Variable* DeclarationScope::DeclareParameter( 828 Variable* DeclarationScope::DeclareParameter(
829 const AstRawString* name, VariableMode mode, bool is_optional, bool is_rest, 829 const AstRawString* name, VariableMode mode, bool is_optional, bool is_rest,
830 bool* is_duplicate, AstValueFactory* ast_value_factory) { 830 bool* is_duplicate, AstValueFactory* ast_value_factory) {
831 DCHECK(!already_resolved_); 831 DCHECK(!already_resolved_);
832 DCHECK(is_function_scope() || is_module_scope()); 832 DCHECK(is_function_scope());
833 DCHECK(!has_rest_); 833 DCHECK(!has_rest_);
834 DCHECK(!is_optional || !is_rest); 834 DCHECK(!is_optional || !is_rest);
835 Variable* var; 835 Variable* var;
836 if (mode == TEMPORARY) { 836 if (mode == TEMPORARY) {
837 var = NewTemporary(name); 837 var = NewTemporary(name);
838 } else { 838 } else {
839 var = 839 var =
840 Declare(zone(), this, name, mode, NORMAL_VARIABLE, kCreatedInitialized); 840 Declare(zone(), this, name, mode, NORMAL_VARIABLE, kCreatedInitialized);
841 // TODO(wingo): Avoid O(n^2) check. 841 // TODO(wingo): Avoid O(n^2) check.
842 *is_duplicate = IsDeclaredParameter(name); 842 *is_duplicate = IsDeclaredParameter(name);
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
1157 } 1157 }
1158 1158
1159 DeclarationScope* Scope::GetClosureScope() { 1159 DeclarationScope* Scope::GetClosureScope() {
1160 Scope* scope = this; 1160 Scope* scope = this;
1161 while (!scope->is_declaration_scope() || scope->is_block_scope()) { 1161 while (!scope->is_declaration_scope() || scope->is_block_scope()) {
1162 scope = scope->outer_scope(); 1162 scope = scope->outer_scope();
1163 } 1163 }
1164 return scope->AsDeclarationScope(); 1164 return scope->AsDeclarationScope();
1165 } 1165 }
1166 1166
1167 ModuleScope* Scope::GetModuleScope() {
1168 Scope* scope = this;
1169 DCHECK(!scope->is_script_scope());
1170 while (!scope->is_module_scope()) {
1171 scope = scope->outer_scope();
1172 DCHECK_NOT_NULL(scope);
1173 }
1174 return scope->AsModuleScope();
1175 }
1176
1177 DeclarationScope* Scope::GetReceiverScope() { 1167 DeclarationScope* Scope::GetReceiverScope() {
1178 Scope* scope = this; 1168 Scope* scope = this;
1179 while (!scope->is_script_scope() && 1169 while (!scope->is_script_scope() &&
1180 (!scope->is_function_scope() || 1170 (!scope->is_function_scope() ||
1181 scope->AsDeclarationScope()->is_arrow_scope())) { 1171 scope->AsDeclarationScope()->is_arrow_scope())) {
1182 scope = scope->outer_scope(); 1172 scope = scope->outer_scope();
1183 } 1173 }
1184 return scope->AsDeclarationScope(); 1174 return scope->AsDeclarationScope();
1185 } 1175 }
1186 1176
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after
1855 Variable* function = 1845 Variable* function =
1856 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; 1846 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr;
1857 bool is_function_var_in_context = 1847 bool is_function_var_in_context =
1858 function != nullptr && function->IsContextSlot(); 1848 function != nullptr && function->IsContextSlot();
1859 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - 1849 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS -
1860 (is_function_var_in_context ? 1 : 0); 1850 (is_function_var_in_context ? 1 : 0);
1861 } 1851 }
1862 1852
1863 } // namespace internal 1853 } // namespace internal
1864 } // namespace v8 1854 } // namespace v8
OLDNEW
« no previous file with comments | « src/ast/scopes.h ('k') | src/ast/variables.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698