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

Unified Diff: src/scopes.h

Issue 1311163002: [es6] Correct length for functions with default parameters (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Comment Created 5 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/parser.h ('k') | src/scopes.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/scopes.h
diff --git a/src/scopes.h b/src/scopes.h
index 4990fab994574a9fb9fbb27814ba93faf3ad5c86..28cc742eb25ac0c1a2a9247784e653aca5e50588 100644
--- a/src/scopes.h
+++ b/src/scopes.h
@@ -128,8 +128,9 @@ class Scope: public ZoneObject {
// Declare a parameter in this scope. When there are duplicated
// parameters the rightmost one 'wins'. However, the implementation
// expects all parameters to be declared and from left to right.
- Variable* DeclareParameter(const AstRawString* name, VariableMode mode,
- bool is_rest, bool* is_duplicate);
+ Variable* DeclareParameter(
+ const AstRawString* name, VariableMode mode,
+ bool is_optional, bool is_rest, bool* is_duplicate);
// Declare a local variable in this scope. If the variable has been
// declared before, the previously declared variable is returned.
@@ -365,16 +366,8 @@ class Scope: public ZoneObject {
return params_[index];
}
- // Returns the default function arity --- does not include rest parameters.
- int default_function_length() const {
- int count = params_.length();
- if (rest_index_ >= 0) {
- DCHECK(count > 0);
- DCHECK(is_function_scope());
- --count;
- }
- return count;
- }
+ // Returns the default function arity excluding default or rest parameters.
+ int default_function_length() const { return arity_; }
int num_parameters() const { return params_.length(); }
@@ -632,6 +625,7 @@ class Scope: public ZoneObject {
Variable* module_var_;
// Info about the parameter list of a function.
+ int arity_;
bool has_simple_parameters_;
Variable* rest_parameter_;
int rest_index_;
« no previous file with comments | « src/parser.h ('k') | src/scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698