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

Unified Diff: src/preparser.h

Issue 1151503002: [destructuring] Implement spread binding patterns. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Comments addressed Created 5 years, 7 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
Index: src/preparser.h
diff --git a/src/preparser.h b/src/preparser.h
index 116a8eac9b891721e208bea92d9f3b7e4ad30528..c14fb9b20cdc067c3f37b86938138aa648b73daa 100644
--- a/src/preparser.h
+++ b/src/preparser.h
@@ -2497,6 +2497,7 @@ typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseArrayLiteral(
this->NewExpressionList(4, zone_);
Expect(Token::LBRACK, CHECK_OK);
while (peek() != Token::RBRACK) {
+ bool seen_spread = false;
ExpressionT elem = this->EmptyExpression();
if (peek() == Token::COMMA) {
if (is_strong(language_mode())) {
@@ -2506,11 +2507,23 @@ typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseArrayLiteral(
return this->EmptyExpression();
}
elem = this->GetLiteralTheHole(peek_position(), factory());
+ } else if (peek() == Token::ELLIPSIS) {
+ ExpressionUnexpectedToken(classifier);
+ int start_pos = peek_position();
+ Consume(Token::ELLIPSIS);
+ ExpressionT argument =
+ this->ParseAssignmentExpression(true, classifier, CHECK_OK);
+
+ elem = factory()->NewSpread(argument, start_pos);
+ seen_spread = true;
} else {
elem = this->ParseAssignmentExpression(true, classifier, CHECK_OK);
}
values->Add(elem, zone_);
if (peek() != Token::RBRACK) {
+ if (seen_spread) {
+ BindingPatternUnexpectedToken(classifier);
+ }
Expect(Token::COMMA, CHECK_OK);
}
}
« src/pattern-rewriter.cc ('K') | « src/pattern-rewriter.cc ('k') | src/runtime.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698