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

Side by Side Diff: src/ast/scopes.h

Issue 1485823003: [cleanup] Remove cruft from old rest parameter implementation (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/ast/ast-value-factory.h ('k') | src/ast/scopes.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_AST_SCOPES_H_ 5 #ifndef V8_AST_SCOPES_H_
6 #define V8_AST_SCOPES_H_ 6 #define V8_AST_SCOPES_H_
7 7
8 #include "src/ast/ast.h" 8 #include "src/ast/ast.h"
9 #include "src/pending-compilation-error-handler.h" 9 #include "src/pending-compilation-error-handler.h"
10 #include "src/zone.h" 10 #include "src/zone.h"
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 Variable* parameter(int index) const { 413 Variable* parameter(int index) const {
414 DCHECK(is_function_scope()); 414 DCHECK(is_function_scope());
415 return params_[index]; 415 return params_[index];
416 } 416 }
417 417
418 // Returns the default function arity excluding default or rest parameters. 418 // Returns the default function arity excluding default or rest parameters.
419 int default_function_length() const { return arity_; } 419 int default_function_length() const { return arity_; }
420 420
421 int num_parameters() const { return params_.length(); } 421 int num_parameters() const { return params_.length(); }
422 422
423 // A function can have at most one rest parameter. Returns Variable* or NULL.
424 Variable* rest_parameter(int* index) const {
425 *index = rest_index_;
426 if (rest_index_ < 0) return NULL;
427 return rest_parameter_;
428 }
429
430 bool has_rest_parameter() const {
431 return rest_index_ >= 0;
432 }
433
434 bool has_simple_parameters() const { 423 bool has_simple_parameters() const {
435 return has_simple_parameters_; 424 return has_simple_parameters_;
436 } 425 }
437 426
438 // TODO(caitp): manage this state in a better way. PreParser must be able to 427 // TODO(caitp): manage this state in a better way. PreParser must be able to
439 // communicate that the scope is non-simple, without allocating any parameters 428 // communicate that the scope is non-simple, without allocating any parameters
440 // as the Parser does. This is necessary to ensure that TC39's proposed early 429 // as the Parser does. This is necessary to ensure that TC39's proposed early
441 // error can be reported consistently regardless of whether lazily parsed or 430 // error can be reported consistently regardless of whether lazily parsed or
442 // not. 431 // not.
443 void SetHasNonSimpleParameters() { 432 void SetHasNonSimpleParameters() {
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 // The number of modules (including nested ones). 684 // The number of modules (including nested ones).
696 int num_modules_; 685 int num_modules_;
697 686
698 // For module scopes, the host scope's temporary variable binding this module. 687 // For module scopes, the host scope's temporary variable binding this module.
699 Variable* module_var_; 688 Variable* module_var_;
700 689
701 // Info about the parameter list of a function. 690 // Info about the parameter list of a function.
702 int arity_; 691 int arity_;
703 bool has_simple_parameters_; 692 bool has_simple_parameters_;
704 Variable* rest_parameter_; 693 Variable* rest_parameter_;
705 int rest_index_;
706 694
707 // Serialized scope info support. 695 // Serialized scope info support.
708 Handle<ScopeInfo> scope_info_; 696 Handle<ScopeInfo> scope_info_;
709 bool already_resolved() { return already_resolved_; } 697 bool already_resolved() { return already_resolved_; }
710 698
711 // Create a non-local variable with a given name. 699 // Create a non-local variable with a given name.
712 // These variables are looked up dynamically at runtime. 700 // These variables are looked up dynamically at runtime.
713 Variable* NonLocal(const AstRawString* name, VariableMode mode); 701 Variable* NonLocal(const AstRawString* name, VariableMode mode);
714 702
715 // Variable resolution. 703 // Variable resolution.
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 831
844 // For tracking which classes are declared consecutively. Needed for strong 832 // For tracking which classes are declared consecutively. Needed for strong
845 // mode. 833 // mode.
846 int class_declaration_group_start_; 834 int class_declaration_group_start_;
847 }; 835 };
848 836
849 } // namespace internal 837 } // namespace internal
850 } // namespace v8 838 } // namespace v8
851 839
852 #endif // V8_AST_SCOPES_H_ 840 #endif // V8_AST_SCOPES_H_
OLDNEW
« no previous file with comments | « src/ast/ast-value-factory.h ('k') | src/ast/scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698