| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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_ |
| OLD | NEW |