Chromium Code Reviews| 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 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 int default_function_length() const { return arity_; } |
| 680 | 680 |
| 681 // Normal code should not need to call this. Class field initializers use this | |
| 682 // property to store information about the number of fields. | |
|
Benedikt Meurer
2016/09/08 03:51:02
That function name seems misleading then.
| |
| 683 void set_default_function_length(int arity) { arity_ = arity; } | |
| 684 | |
| 681 // Returns the number of formal parameters, excluding a possible rest | 685 // Returns the number of formal parameters, excluding a possible rest |
| 682 // parameter. Examples: | 686 // parameter. Examples: |
| 683 // function foo(a, b) {} ==> 2 | 687 // function foo(a, b) {} ==> 2 |
| 684 // function foo(a, b, ...c) {} ==> 2 | 688 // function foo(a, b, ...c) {} ==> 2 |
| 685 // function foo(a, b, c = 1) {} ==> 3 | 689 // function foo(a, b, c = 1) {} ==> 3 |
| 686 int num_parameters() const { | 690 int num_parameters() const { |
| 687 return has_rest_ ? params_.length() - 1 : params_.length(); | 691 return has_rest_ ? params_.length() - 1 : params_.length(); |
| 688 } | 692 } |
| 689 | 693 |
| 690 // The function's rest parameter (nullptr if there is none). | 694 // The function's rest parameter (nullptr if there is none). |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 843 void AllocateModuleVariables(); | 847 void AllocateModuleVariables(); |
| 844 | 848 |
| 845 private: | 849 private: |
| 846 ModuleDescriptor* module_descriptor_; | 850 ModuleDescriptor* module_descriptor_; |
| 847 }; | 851 }; |
| 848 | 852 |
| 849 } // namespace internal | 853 } // namespace internal |
| 850 } // namespace v8 | 854 } // namespace v8 |
| 851 | 855 |
| 852 #endif // V8_AST_SCOPES_H_ | 856 #endif // V8_AST_SCOPES_H_ |
| OLD | NEW |