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

Side by Side Diff: src/scopes.h

Issue 924403002: [parsing]: eval/arguments parameter names are ok in sloppy mode (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: test fix Created 5 years, 10 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.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 #ifndef V8_SCOPES_H_ 5 #ifndef V8_SCOPES_H_
6 #define V8_SCOPES_H_ 6 #define V8_SCOPES_H_
7 7
8 #include "src/ast.h" 8 #include "src/ast.h"
9 #include "src/zone.h" 9 #include "src/zone.h"
10 10
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 // Strict mode support. 460 // Strict mode support.
461 bool IsDeclared(const AstRawString* name) { 461 bool IsDeclared(const AstRawString* name) {
462 // During formal parameter list parsing the scope only contains 462 // During formal parameter list parsing the scope only contains
463 // two variables inserted at initialization: "this" and "arguments". 463 // two variables inserted at initialization: "this" and "arguments".
464 // "this" is an invalid parameter name and "arguments" is invalid parameter 464 // "this" is an invalid parameter name and "arguments" is invalid parameter
465 // name in strict mode. Therefore looking up with the map which includes 465 // name in strict mode. Therefore looking up with the map which includes
466 // "this" and "arguments" in addition to all formal parameters is safe. 466 // "this" and "arguments" in addition to all formal parameters is safe.
467 return variables_.Lookup(name) != NULL; 467 return variables_.Lookup(name) != NULL;
468 } 468 }
469 469
470 bool IsDeclaredParameter(const AstRawString* name) {
471 // If IsSimpleParameterList is false, duplicate parameters are not allowed,
472 // however `arguments` may be allowed if function is not strict code. Thus,
473 // the assumptions explained above do not hold.
474 return params_.Contains(variables_.Lookup(name));
475 }
476
470 // --------------------------------------------------------------------------- 477 // ---------------------------------------------------------------------------
471 // Debugging. 478 // Debugging.
472 479
473 #ifdef DEBUG 480 #ifdef DEBUG
474 void Print(int n = 0); // n = indentation; n < 0 => don't print recursively 481 void Print(int n = 0); // n = indentation; n < 0 => don't print recursively
475 #endif 482 #endif
476 483
477 // --------------------------------------------------------------------------- 484 // ---------------------------------------------------------------------------
478 // Implementation. 485 // Implementation.
479 protected: 486 protected:
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 Scope* outer_scope, 698 Scope* outer_scope,
692 Handle<ScopeInfo> scope_info); 699 Handle<ScopeInfo> scope_info);
693 700
694 AstValueFactory* ast_value_factory_; 701 AstValueFactory* ast_value_factory_;
695 Zone* zone_; 702 Zone* zone_;
696 }; 703 };
697 704
698 } } // namespace v8::internal 705 } } // namespace v8::internal
699 706
700 #endif // V8_SCOPES_H_ 707 #endif // V8_SCOPES_H_
OLDNEW
« no previous file with comments | « src/preparser.h ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698