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

Unified Diff: src/parser.h

Issue 1272673003: [es6] Re-implement rest parameters via desugaring. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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/ia32/code-stubs-ia32.cc ('k') | src/parser.cc » ('j') | src/parser.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parser.h
diff --git a/src/parser.h b/src/parser.h
index 4a77d91b0ac859aeb6b938c40c36e4b00d5d37f1..9669ac4434abe6b91d68f28f31a823518fa1b64e 100644
--- a/src/parser.h
+++ b/src/parser.h
@@ -975,6 +975,7 @@ class Parser : public ParserBase<ParserTraits> {
Scope* scope;
VariableMode mode;
bool is_const;
+ bool is_rest;
bool needs_init;
int declaration_pos;
int initialization_pos;
@@ -993,6 +994,8 @@ class Parser : public ParserBase<ParserTraits> {
Expression* pattern;
int initializer_position;
Expression* initializer;
+ bool is_rest = false;
+ int rest_literal_index = 0;
};
DeclarationParsingResult()
@@ -1314,9 +1317,9 @@ Expression* ParserTraits::SpreadCallNew(
void ParserTraits::AddFormalParameter(
ParserFormalParameters* parameters, Expression* pattern, bool is_rest) {
- bool is_simple = pattern->IsVariableProxy();
- DCHECK(parser_->allow_harmony_destructuring() ||
- parser_->allow_harmony_rest_parameters() || is_simple);
+ bool is_simple = !is_rest && pattern->IsVariableProxy();
+ DCHECK((!is_rest || parser_->allow_harmony_rest_parameters()) ||
+ (!is_simple && parser_->allow_harmony_destructuring()) || is_simple);
const AstRawString* name = is_simple
? pattern->AsVariableProxy()->raw_name()
: parser_->ast_value_factory()->empty_string();
@@ -1330,10 +1333,9 @@ void ParserTraits::DeclareFormalParameter(
Scope* scope, const ParserFormalParameters::Parameter& parameter,
bool is_simple, ExpressionClassifier* classifier) {
bool is_duplicate = false;
- // TODO(caitp): Remove special handling for rest once desugaring is in.
- auto name = is_simple || parameter.is_rest
- ? parameter.name : parser_->ast_value_factory()->empty_string();
- auto mode = is_simple || parameter.is_rest ? VAR : TEMPORARY;
+ auto name =
+ is_simple ? parameter.name : parser_->ast_value_factory()->empty_string();
+ auto mode = is_simple ? VAR : TEMPORARY;
Variable* var =
scope->DeclareParameter(name, mode, parameter.is_rest, &is_duplicate);
if (is_duplicate) {
« no previous file with comments | « src/ia32/code-stubs-ia32.cc ('k') | src/parser.cc » ('j') | src/parser.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698