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

Side by Side Diff: src/scopes.cc

Issue 1195163007: Revert of [destructuring] Implement parameter pattern matching. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 6 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/preparser.cc ('k') | test/cctest/test-parsing.cc » ('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/v8.h" 5 #include "src/v8.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 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 if (var != NULL) return var; 459 if (var != NULL) return var;
460 } 460 }
461 return NULL; 461 return NULL;
462 } 462 }
463 463
464 464
465 Variable* Scope::DeclareParameter(const AstRawString* name, VariableMode mode, 465 Variable* Scope::DeclareParameter(const AstRawString* name, VariableMode mode,
466 bool is_rest, bool* is_duplicate) { 466 bool is_rest, bool* is_duplicate) {
467 DCHECK(!already_resolved()); 467 DCHECK(!already_resolved());
468 DCHECK(is_function_scope()); 468 DCHECK(is_function_scope());
469 469 Variable* var = variables_.Declare(this, name, mode, Variable::NORMAL,
470 Variable* var; 470 kCreatedInitialized);
471 if (!name->IsEmpty()) {
472 var = variables_.Declare(this, name, mode, Variable::NORMAL,
473 kCreatedInitialized);
474 // TODO(wingo): Avoid O(n^2) check.
475 *is_duplicate = IsDeclaredParameter(name);
476 } else {
477 var = new (zone())
478 Variable(this, name, TEMPORARY, Variable::NORMAL, kCreatedInitialized);
479 }
480 if (is_rest) { 471 if (is_rest) {
481 DCHECK_NULL(rest_parameter_); 472 DCHECK_NULL(rest_parameter_);
482 rest_parameter_ = var; 473 rest_parameter_ = var;
483 rest_index_ = num_parameters(); 474 rest_index_ = num_parameters();
484 } 475 }
476 // TODO(wingo): Avoid O(n^2) check.
477 *is_duplicate = IsDeclaredParameter(name);
485 params_.Add(var, zone()); 478 params_.Add(var, zone());
486 return var; 479 return var;
487 } 480 }
488 481
489 482
490 Variable* Scope::DeclareLocal(const AstRawString* name, VariableMode mode, 483 Variable* Scope::DeclareLocal(const AstRawString* name, VariableMode mode,
491 InitializationFlag init_flag, Variable::Kind kind, 484 InitializationFlag init_flag, Variable::Kind kind,
492 MaybeAssignedFlag maybe_assigned_flag, 485 MaybeAssignedFlag maybe_assigned_flag,
493 int declaration_group_start) { 486 int declaration_group_start) {
494 DCHECK(!already_resolved()); 487 DCHECK(!already_resolved());
(...skipping 1079 matching lines...) Expand 10 before | Expand all | Expand 10 after
1574 } 1567 }
1575 1568
1576 1569
1577 int Scope::ContextLocalCount() const { 1570 int Scope::ContextLocalCount() const {
1578 if (num_heap_slots() == 0) return 0; 1571 if (num_heap_slots() == 0) return 0;
1579 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - 1572 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS -
1580 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0); 1573 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0);
1581 } 1574 }
1582 } // namespace internal 1575 } // namespace internal
1583 } // namespace v8 1576 } // namespace v8
OLDNEW
« no previous file with comments | « src/preparser.cc ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698