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

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

Issue 2664083002: [ignition] desugar async functions/generators/modules in BytecodeGenerator
Patch Set: get rid of lambdas, for better or worse.. Created 3 years, 10 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/ast/ast.h" 10 #include "src/ast/ast.h"
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 asm_function_ = false; 291 asm_function_ = false;
292 force_eager_compilation_ = false; 292 force_eager_compilation_ = false;
293 has_arguments_parameter_ = false; 293 has_arguments_parameter_ = false;
294 scope_uses_super_property_ = false; 294 scope_uses_super_property_ = false;
295 has_rest_ = false; 295 has_rest_ = false;
296 receiver_ = nullptr; 296 receiver_ = nullptr;
297 new_target_ = nullptr; 297 new_target_ = nullptr;
298 function_ = nullptr; 298 function_ = nullptr;
299 arguments_ = nullptr; 299 arguments_ = nullptr;
300 this_function_ = nullptr; 300 this_function_ = nullptr;
301 generator_object_ = nullptr;
302 promise_ = nullptr;
301 should_eager_compile_ = false; 303 should_eager_compile_ = false;
302 was_lazily_parsed_ = false; 304 was_lazily_parsed_ = false;
303 #ifdef DEBUG 305 #ifdef DEBUG
304 DeclarationScope* outer_declaration_scope = 306 DeclarationScope* outer_declaration_scope =
305 outer_scope_ ? outer_scope_->GetDeclarationScope() : nullptr; 307 outer_scope_ ? outer_scope_->GetDeclarationScope() : nullptr;
306 is_being_lazily_parsed_ = 308 is_being_lazily_parsed_ =
307 outer_declaration_scope ? outer_declaration_scope->is_being_lazily_parsed_ 309 outer_declaration_scope ? outer_declaration_scope->is_being_lazily_parsed_
308 : false; 310 : false;
309 #endif 311 #endif
310 } 312 }
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 function_ = 698 function_ =
697 new (zone()) Variable(this, name, CONST, kind, kCreatedInitialized); 699 new (zone()) Variable(this, name, CONST, kind, kCreatedInitialized);
698 if (calls_sloppy_eval()) { 700 if (calls_sloppy_eval()) {
699 NonLocal(name, DYNAMIC); 701 NonLocal(name, DYNAMIC);
700 } else { 702 } else {
701 variables_.Add(zone(), function_); 703 variables_.Add(zone(), function_);
702 } 704 }
703 return function_; 705 return function_;
704 } 706 }
705 707
708 Variable* DeclarationScope::DeclareGeneratorObjectVar(
709 const AstRawString* name) {
710 DCHECK(is_function_scope() || is_module_scope());
711 DCHECK_NULL(generator_object_);
712 generator_object_ = NewTemporary(name);
713 return generator_object_;
714 }
715
716 Variable* DeclarationScope::DeclarePromiseVar(const AstRawString* name) {
717 DCHECK(is_function_scope());
718 DCHECK_NULL(promise_);
719 promise_ = NewTemporary(name);
720 return promise_;
721 }
722
706 bool Scope::HasBeenRemoved() const { 723 bool Scope::HasBeenRemoved() const {
707 if (sibling() == this) { 724 if (sibling() == this) {
708 DCHECK_NULL(inner_scope_); 725 DCHECK_NULL(inner_scope_);
709 DCHECK(is_block_scope()); 726 DCHECK(is_block_scope());
710 return true; 727 return true;
711 } 728 }
712 return false; 729 return false;
713 } 730 }
714 731
715 Scope* Scope::GetUnremovedScope() { 732 Scope* Scope::GetUnremovedScope() {
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after
1350 } 1367 }
1351 1368
1352 Scope* Scope::GetOuterScopeWithContext() { 1369 Scope* Scope::GetOuterScopeWithContext() {
1353 Scope* scope = outer_scope_; 1370 Scope* scope = outer_scope_;
1354 while (scope && !scope->NeedsContext()) { 1371 while (scope && !scope->NeedsContext()) {
1355 scope = scope->outer_scope(); 1372 scope = scope->outer_scope();
1356 } 1373 }
1357 return scope; 1374 return scope;
1358 } 1375 }
1359 1376
1377 bool Scope::HasLazilyParsedInnerFunctionScope() const {
1378 for (Scope* scope = inner_scope_; scope; scope = scope->sibling_) {
1379 if (scope->is_function_scope()) {
1380 DCHECK(scope->is_declaration_scope_);
1381 if (static_cast<DeclarationScope*>(scope)->was_lazily_parsed()) {
1382 return true;
1383 }
1384 if (scope->HasLazilyParsedInnerFunctionScope()) return true;
1385 }
1386 }
1387 return false;
1388 }
1389
1360 Handle<StringSet> DeclarationScope::CollectNonLocals( 1390 Handle<StringSet> DeclarationScope::CollectNonLocals(
1361 ParseInfo* info, Handle<StringSet> non_locals) { 1391 ParseInfo* info, Handle<StringSet> non_locals) {
1362 VariableProxy* free_variables = FetchFreeVariables(this, info); 1392 VariableProxy* free_variables = FetchFreeVariables(this, info);
1363 for (VariableProxy* proxy = free_variables; proxy != nullptr; 1393 for (VariableProxy* proxy = free_variables; proxy != nullptr;
1364 proxy = proxy->next_unresolved()) { 1394 proxy = proxy->next_unresolved()) {
1365 non_locals = StringSet::Add(non_locals, proxy->name()); 1395 non_locals = StringSet::Add(non_locals, proxy->name());
1366 } 1396 }
1367 return non_locals; 1397 return non_locals;
1368 } 1398 }
1369 1399
(...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after
2232 Variable* function = 2262 Variable* function =
2233 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; 2263 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr;
2234 bool is_function_var_in_context = 2264 bool is_function_var_in_context =
2235 function != nullptr && function->IsContextSlot(); 2265 function != nullptr && function->IsContextSlot();
2236 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - 2266 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS -
2237 (is_function_var_in_context ? 1 : 0); 2267 (is_function_var_in_context ? 1 : 0);
2238 } 2268 }
2239 2269
2240 } // namespace internal 2270 } // namespace internal
2241 } // namespace v8 2271 } // namespace v8
OLDNEW
« no previous file with comments | « src/ast/scopes.h ('k') | src/bailout-reason.h » ('j') | src/interpreter/bytecode-generator.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698