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

Unified Diff: src/ast/scopes.h

Issue 2276923002: Remove the rest_parameter(int*) variant, use rest_parameter() instead. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Ports. Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/ast/ast-numbering.cc ('k') | src/ast/scopes.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ast/scopes.h
diff --git a/src/ast/scopes.h b/src/ast/scopes.h
index c4adb8037d71e2b50d1dacb6b5ffce1823efbf39..b8c4f1aea81cd01afe39a0c77339c5ad11898912 100644
--- a/src/ast/scopes.h
+++ b/src/ast/scopes.h
@@ -682,38 +682,20 @@ class DeclarationScope : public Scope {
// Returns the default function arity excluding default or rest parameters.
int default_function_length() const { return arity_; }
- // Returns the number of formal parameters, up to but not including the
- // rest parameter index (if the function has rest parameters), i.e. it
- // says 2 for
- //
- // function foo(a, b) { ... }
- //
- // and
- //
- // function foo(a, b, ...c) { ... }
- //
- // but for
- //
- // function foo(a, b, c = 1) { ... }
- //
- // we return 3 here.
+ // Returns the number of formal parameters, excluding a possible rest
+ // parameter. Examples:
+ // function foo(a, b) {} ==> 2
+ // function foo(a, b, ...c) {} ==> 2
+ // function foo(a, b, c = 1) {} ==> 3
int num_parameters() const {
- return has_rest_parameter() ? params_.length() - 1 : params_.length();
+ return has_rest_ ? params_.length() - 1 : params_.length();
}
- // A function can have at most one rest parameter. Returns Variable* or NULL.
- Variable* rest_parameter(int* index) const {
- if (!has_rest_parameter()) return nullptr;
- *index = params_.length() - 1;
- return rest_parameter();
- }
+ // The function's rest parameter (nullptr if there is none).
Variable* rest_parameter() const {
- DCHECK(has_rest_parameter());
- return params_[params_.length() - 1];
+ return has_rest_ ? params_[params_.length() - 1] : nullptr;
}
- bool has_rest_parameter() const { return has_rest_; }
-
bool has_simple_parameters() const { return has_simple_parameters_; }
// TODO(caitp): manage this state in a better way. PreParser must be able to
« no previous file with comments | « src/ast/ast-numbering.cc ('k') | src/ast/scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698