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

Unified Diff: src/ast/scopes.h

Issue 2269293004: Replace rest_index_ with has_rest_ (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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 | « no previous file | 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 78ad0c4b009abe78c2113454088a17cce798df75..45539c9ec9fe121757c619828e351fd9f9e28efd 100644
--- a/src/ast/scopes.h
+++ b/src/ast/scopes.h
@@ -730,12 +730,16 @@ class DeclarationScope : public Scope {
// A function can have at most one rest parameter. Returns Variable* or NULL.
Variable* rest_parameter(int* index) const {
- *index = rest_index_;
- if (rest_index_ < 0) return nullptr;
- return params_[rest_index_];
+ if (!has_rest_parameter()) return nullptr;
+ *index = params_.length() - 1;
+ return rest_parameter();
+ }
+ Variable* rest_parameter() const {
+ DCHECK(has_rest_parameter());
+ return params_[params_.length() - 1];
}
- bool has_rest_parameter() const { return rest_index_ >= 0; }
+ bool has_rest_parameter() const { return has_rest_; }
bool has_simple_parameters() const { return has_simple_parameters_; }
@@ -843,6 +847,8 @@ class DeclarationScope : public Scope {
// This scope's outer context is an asm module.
bool asm_function_ : 1;
bool force_eager_compilation_ : 1;
+ // This function scope has a rest parameter.
+ bool has_rest_ : 1;
// This scope has a parameter called "arguments".
bool has_arguments_parameter_ : 1;
// This scope uses "super" property ('super.foo').
@@ -850,7 +856,6 @@ class DeclarationScope : public Scope {
// Info about the parameter list of a function.
int arity_;
- int rest_index_;
// Compiler-allocated (user-invisible) temporaries.
ZoneList<Variable*> temps_;
// Parameter list in source order.
« no previous file with comments | « no previous file | src/ast/scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698