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

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

Issue 2315733003: Class fields, part 1 (parsing and infrastructure) (Closed)
Patch Set: whitespace Created 4 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/ast/prettyprinter.cc ('k') | src/bootstrapper.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/variables.h" 8 #include "src/ast/variables.h"
9 #include "src/base/hashmap.h" 9 #include "src/base/hashmap.h"
10 #include "src/globals.h" 10 #include "src/globals.h"
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 } 669 }
670 670
671 // Parameters. The left-most parameter has index 0. 671 // Parameters. The left-most parameter has index 0.
672 // Only valid for function scopes. 672 // Only valid for function scopes.
673 Variable* parameter(int index) const { 673 Variable* parameter(int index) const {
674 DCHECK(is_function_scope()); 674 DCHECK(is_function_scope());
675 return params_[index]; 675 return params_[index];
676 } 676 }
677 677
678 // Returns the default function arity excluding default or rest parameters. 678 // Returns the default function arity excluding default or rest parameters.
679 int default_function_length() const { return arity_; } 679 // This will be used to set the length of the function, by default.
680 // Class field initializers use this property to indicate the number of
681 // fields being initialized.
682 int arity() const { return arity_; }
683
684 // Normal code should not need to call this. Class field initializers use this
685 // property to indicate the number of fields being initialized.
686 void set_arity(int arity) { arity_ = arity; }
680 687
681 // Returns the number of formal parameters, excluding a possible rest 688 // Returns the number of formal parameters, excluding a possible rest
682 // parameter. Examples: 689 // parameter. Examples:
683 // function foo(a, b) {} ==> 2 690 // function foo(a, b) {} ==> 2
684 // function foo(a, b, ...c) {} ==> 2 691 // function foo(a, b, ...c) {} ==> 2
685 // function foo(a, b, c = 1) {} ==> 3 692 // function foo(a, b, c = 1) {} ==> 3
686 int num_parameters() const { 693 int num_parameters() const {
687 return has_rest_ ? params_.length() - 1 : params_.length(); 694 return has_rest_ ? params_.length() - 1 : params_.length();
688 } 695 }
689 696
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 void AllocateModuleVariables(); 850 void AllocateModuleVariables();
844 851
845 private: 852 private:
846 ModuleDescriptor* module_descriptor_; 853 ModuleDescriptor* module_descriptor_;
847 }; 854 };
848 855
849 } // namespace internal 856 } // namespace internal
850 } // namespace v8 857 } // namespace v8
851 858
852 #endif // V8_AST_SCOPES_H_ 859 #endif // V8_AST_SCOPES_H_
OLDNEW
« no previous file with comments | « src/ast/prettyprinter.cc ('k') | src/bootstrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698