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

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

Issue 1564343002: Fix for temporaries in parameter initializers (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 11 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 "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/ast/scopeinfo.h" 8 #include "src/ast/scopeinfo.h"
9 #include "src/bootstrapper.h" 9 #include "src/bootstrapper.h"
10 #include "src/messages.h" 10 #include "src/messages.h"
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 568
569 569
570 Variable* Scope::NewTemporary(const AstRawString* name) { 570 Variable* Scope::NewTemporary(const AstRawString* name) {
571 DCHECK(!already_resolved()); 571 DCHECK(!already_resolved());
572 Scope* scope = this->ClosureScope(); 572 Scope* scope = this->ClosureScope();
573 Variable* var = new(zone()) Variable(scope, 573 Variable* var = new(zone()) Variable(scope,
574 name, 574 name,
575 TEMPORARY, 575 TEMPORARY,
576 Variable::NORMAL, 576 Variable::NORMAL,
577 kCreatedInitialized); 577 kCreatedInitialized);
578 scope->temps_.Add(var, zone()); 578 scope->AddTemporary(var);
579 return var; 579 return var;
580 } 580 }
581 581
582 582
583 bool Scope::RemoveTemporary(Variable* var) {
584 // Most likely (always?) any temporary variable we want to remove
585 // was just added before, so we search backwards.
586 for (int i = temps_.length(); i-- > 0;) {
587 if (temps_[i] == var) {
588 temps_.Remove(i);
589 return true;
590 }
591 }
592 return false;
593 }
594
595
583 void Scope::AddDeclaration(Declaration* declaration) { 596 void Scope::AddDeclaration(Declaration* declaration) {
584 decls_.Add(declaration, zone()); 597 decls_.Add(declaration, zone());
585 } 598 }
586 599
587 600
588 void Scope::SetIllegalRedeclaration(Expression* expression) { 601 void Scope::SetIllegalRedeclaration(Expression* expression) {
589 // Record only the first illegal redeclaration. 602 // Record only the first illegal redeclaration.
590 if (!HasIllegalRedeclaration()) { 603 if (!HasIllegalRedeclaration()) {
591 illegal_redecl_ = expression; 604 illegal_redecl_ = expression;
592 } 605 }
(...skipping 1083 matching lines...) Expand 10 before | Expand all | Expand 10 after
1676 function_ != NULL && function_->proxy()->var()->IsContextSlot(); 1689 function_ != NULL && function_->proxy()->var()->IsContextSlot();
1677 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - num_global_slots() - 1690 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - num_global_slots() -
1678 (is_function_var_in_context ? 1 : 0); 1691 (is_function_var_in_context ? 1 : 0);
1679 } 1692 }
1680 1693
1681 1694
1682 int Scope::ContextGlobalCount() const { return num_global_slots(); } 1695 int Scope::ContextGlobalCount() const { return num_global_slots(); }
1683 1696
1684 } // namespace internal 1697 } // namespace internal
1685 } // namespace v8 1698 } // 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