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

Side by Side Diff: src/scopes.cc

Issue 1300103005: [parser] disallow language mode directive in body of function with non-simple parameters (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: flag implications don't work in test suite? Created 5 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/scopes.h ('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/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 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 468
469 Variable* Scope::DeclareParameter( 469 Variable* Scope::DeclareParameter(
470 const AstRawString* name, VariableMode mode, 470 const AstRawString* name, VariableMode mode,
471 bool is_optional, bool is_rest, bool* is_duplicate) { 471 bool is_optional, bool is_rest, bool* is_duplicate) {
472 DCHECK(!already_resolved()); 472 DCHECK(!already_resolved());
473 DCHECK(is_function_scope()); 473 DCHECK(is_function_scope());
474 DCHECK(!is_optional || !is_rest); 474 DCHECK(!is_optional || !is_rest);
475 Variable* var; 475 Variable* var;
476 if (mode == TEMPORARY) { 476 if (mode == TEMPORARY) {
477 var = NewTemporary(name); 477 var = NewTemporary(name);
478 has_simple_parameters_ = false;
479 } else { 478 } else {
480 var = variables_.Declare(this, name, mode, Variable::NORMAL, 479 var = variables_.Declare(this, name, mode, Variable::NORMAL,
481 kCreatedInitialized); 480 kCreatedInitialized);
482 // TODO(wingo): Avoid O(n^2) check. 481 // TODO(wingo): Avoid O(n^2) check.
483 *is_duplicate = IsDeclaredParameter(name); 482 *is_duplicate = IsDeclaredParameter(name);
484 } 483 }
485 if (!is_optional && !is_rest && arity_ == params_.length()) { 484 if (!is_optional && !is_rest && arity_ == params_.length()) {
486 ++arity_; 485 ++arity_;
487 } 486 }
488 if (is_rest) { 487 if (is_rest) {
489 DCHECK_NULL(rest_parameter_); 488 DCHECK_NULL(rest_parameter_);
490 rest_parameter_ = var; 489 rest_parameter_ = var;
491 rest_index_ = num_parameters(); 490 rest_index_ = num_parameters();
492 has_simple_parameters_ = false;
493 } 491 }
494 params_.Add(var, zone()); 492 params_.Add(var, zone());
495 return var; 493 return var;
496 } 494 }
497 495
498 496
499 Variable* Scope::DeclareLocal(const AstRawString* name, VariableMode mode, 497 Variable* Scope::DeclareLocal(const AstRawString* name, VariableMode mode,
500 InitializationFlag init_flag, Variable::Kind kind, 498 InitializationFlag init_flag, Variable::Kind kind,
501 MaybeAssignedFlag maybe_assigned_flag, 499 MaybeAssignedFlag maybe_assigned_flag,
502 int declaration_group_start) { 500 int declaration_group_start) {
(...skipping 1119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1622 function_ != NULL && function_->proxy()->var()->IsContextSlot(); 1620 function_ != NULL && function_->proxy()->var()->IsContextSlot();
1623 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - num_global_slots() - 1621 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - num_global_slots() -
1624 (is_function_var_in_context ? 1 : 0); 1622 (is_function_var_in_context ? 1 : 0);
1625 } 1623 }
1626 1624
1627 1625
1628 int Scope::ContextGlobalCount() const { return num_global_slots(); } 1626 int Scope::ContextGlobalCount() const { return num_global_slots(); }
1629 1627
1630 } // namespace internal 1628 } // namespace internal
1631 } // namespace v8 1629 } // namespace v8
OLDNEW
« no previous file with comments | « src/scopes.h ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698