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

Side by Side Diff: src/scopes.cc

Issue 1473243006: Reland shipping of --harmony-destructuring-bind (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years 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/flag-definitions.h ('k') | test/mozilla/mozilla.status » ('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/scopes.h" 5 #include "src/scopes.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/bootstrapper.h" 8 #include "src/bootstrapper.h"
9 #include "src/messages.h" 9 #include "src/messages.h"
10 #include "src/parser.h" 10 #include "src/parser.h"
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 Expression* Scope::GetIllegalRedeclaration() { 603 Expression* Scope::GetIllegalRedeclaration() {
604 DCHECK(HasIllegalRedeclaration()); 604 DCHECK(HasIllegalRedeclaration());
605 return illegal_redecl_; 605 return illegal_redecl_;
606 } 606 }
607 607
608 608
609 Declaration* Scope::CheckConflictingVarDeclarations() { 609 Declaration* Scope::CheckConflictingVarDeclarations() {
610 int length = decls_.length(); 610 int length = decls_.length();
611 for (int i = 0; i < length; i++) { 611 for (int i = 0; i < length; i++) {
612 Declaration* decl = decls_[i]; 612 Declaration* decl = decls_[i];
613 if (decl->mode() != VAR && !is_block_scope()) continue; 613 // We don't create a separate scope to hold the function name of a function
614 // expression, so we have to make sure not to consider it when checking for
615 // conflicts (since it's conceptually "outside" the declaration scope).
616 if (is_function_scope() && decl == function()) continue;
617 if (IsLexicalVariableMode(decl->mode()) && !is_block_scope()) continue;
614 const AstRawString* name = decl->proxy()->raw_name(); 618 const AstRawString* name = decl->proxy()->raw_name();
615 619
616 // Iterate through all scopes until and including the declaration scope. 620 // Iterate through all scopes until and including the declaration scope.
617 Scope* previous = NULL; 621 Scope* previous = NULL;
618 Scope* current = decl->scope(); 622 Scope* current = decl->scope();
619 // Lexical vs lexical conflicts within the same scope have already been 623 // Lexical vs lexical conflicts within the same scope have already been
620 // captured in Parser::Declare. The only conflicts we still need to check 624 // captured in Parser::Declare. The only conflicts we still need to check
621 // are lexical vs VAR, or any declarations within a declaration block scope 625 // are lexical vs VAR, or any declarations within a declaration block scope
622 // vs lexical declarations in its surrounding (function) scope. 626 // vs lexical declarations in its surrounding (function) scope.
623 if (decl->mode() != VAR) current = current->outer_scope_; 627 if (IsLexicalVariableMode(decl->mode())) current = current->outer_scope_;
624 do { 628 do {
625 // There is a conflict if there exists a non-VAR binding. 629 // There is a conflict if there exists a non-VAR binding.
626 Variable* other_var = current->variables_.Lookup(name); 630 Variable* other_var = current->variables_.Lookup(name);
627 if (other_var != NULL && other_var->mode() != VAR) { 631 if (other_var != NULL && IsLexicalVariableMode(other_var->mode())) {
628 return decl; 632 return decl;
629 } 633 }
630 previous = current; 634 previous = current;
631 current = current->outer_scope_; 635 current = current->outer_scope_;
632 } while (!previous->is_declaration_scope()); 636 } while (!previous->is_declaration_scope());
633 } 637 }
634 return NULL; 638 return NULL;
635 } 639 }
636 640
637 641
(...skipping 1023 matching lines...) Expand 10 before | Expand all | Expand 10 after
1661 function_ != NULL && function_->proxy()->var()->IsContextSlot(); 1665 function_ != NULL && function_->proxy()->var()->IsContextSlot();
1662 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - num_global_slots() - 1666 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - num_global_slots() -
1663 (is_function_var_in_context ? 1 : 0); 1667 (is_function_var_in_context ? 1 : 0);
1664 } 1668 }
1665 1669
1666 1670
1667 int Scope::ContextGlobalCount() const { return num_global_slots(); } 1671 int Scope::ContextGlobalCount() const { return num_global_slots(); }
1668 1672
1669 } // namespace internal 1673 } // namespace internal
1670 } // namespace v8 1674 } // namespace v8
OLDNEW
« no previous file with comments | « src/flag-definitions.h ('k') | test/mozilla/mozilla.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698