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

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: minor test cleanup Created 5 years, 4 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/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 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 } 465 }
466 466
467 467
468 Variable* Scope::DeclareParameter(const AstRawString* name, VariableMode mode, 468 Variable* Scope::DeclareParameter(const AstRawString* name, VariableMode mode,
469 bool is_rest, bool* is_duplicate) { 469 bool is_rest, bool* is_duplicate) {
470 DCHECK(!already_resolved()); 470 DCHECK(!already_resolved());
471 DCHECK(is_function_scope()); 471 DCHECK(is_function_scope());
472 Variable* var; 472 Variable* var;
473 if (mode == TEMPORARY) { 473 if (mode == TEMPORARY) {
474 var = NewTemporary(name); 474 var = NewTemporary(name);
475 has_simple_parameters_ = false;
476 } else { 475 } else {
477 var = variables_.Declare(this, name, mode, Variable::NORMAL, 476 var = variables_.Declare(this, name, mode, Variable::NORMAL,
478 kCreatedInitialized); 477 kCreatedInitialized);
479 // TODO(wingo): Avoid O(n^2) check. 478 // TODO(wingo): Avoid O(n^2) check.
480 *is_duplicate = IsDeclaredParameter(name); 479 *is_duplicate = IsDeclaredParameter(name);
481 } 480 }
482 if (is_rest) { 481 if (is_rest) {
483 DCHECK_NULL(rest_parameter_); 482 DCHECK_NULL(rest_parameter_);
484 rest_parameter_ = var; 483 rest_parameter_ = var;
485 rest_index_ = num_parameters(); 484 rest_index_ = num_parameters();
486 has_simple_parameters_ = false;
487 } 485 }
488 params_.Add(var, zone()); 486 params_.Add(var, zone());
489 return var; 487 return var;
490 } 488 }
491 489
492 490
493 Variable* Scope::DeclareLocal(const AstRawString* name, VariableMode mode, 491 Variable* Scope::DeclareLocal(const AstRawString* name, VariableMode mode,
494 InitializationFlag init_flag, Variable::Kind kind, 492 InitializationFlag init_flag, Variable::Kind kind,
495 MaybeAssignedFlag maybe_assigned_flag, 493 MaybeAssignedFlag maybe_assigned_flag,
496 int declaration_group_start) { 494 int declaration_group_start) {
(...skipping 1119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1616 function_ != NULL && function_->proxy()->var()->IsContextSlot(); 1614 function_ != NULL && function_->proxy()->var()->IsContextSlot();
1617 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - num_global_slots() - 1615 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - num_global_slots() -
1618 (is_function_var_in_context ? 1 : 0); 1616 (is_function_var_in_context ? 1 : 0);
1619 } 1617 }
1620 1618
1621 1619
1622 int Scope::ContextGlobalCount() const { return num_global_slots(); } 1620 int Scope::ContextGlobalCount() const { return num_global_slots(); }
1623 1621
1624 } // namespace internal 1622 } // namespace internal
1625 } // namespace v8 1623 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698