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

Unified Diff: src/preparser.h

Issue 1125183008: [es6] Spread in array literals (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: cleanup 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
« no previous file with comments | « src/parser.cc ('k') | src/runtime.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/preparser.h
diff --git a/src/preparser.h b/src/preparser.h
index c14fb9b20cdc067c3f37b86938138aa648b73daa..d38aaaaa26e7f1fa3876c041b708d123c054660a 100644
--- a/src/preparser.h
+++ b/src/preparser.h
@@ -123,6 +123,9 @@ class ParserBase : public Traits {
bool allow_harmony_destructuring() const {
return allow_harmony_destructuring_;
}
+ bool allow_harmony_spread_arrays() const {
+ return allow_harmony_spread_arrays_;
+ }
bool allow_strong_mode() const { return allow_strong_mode_; }
@@ -161,7 +164,9 @@ class ParserBase : public Traits {
void set_allow_harmony_destructuring(bool allow) {
allow_harmony_destructuring_ = allow;
}
-
+ void set_allow_harmony_spread_arrays(bool allow) {
+ allow_harmony_spread_arrays_ = allow;
+ }
protected:
enum AllowRestrictedIdentifiers {
@@ -1011,6 +1016,7 @@ class ParserBase : public Traits {
bool allow_harmony_rest_params_;
bool allow_harmony_spreadcalls_;
bool allow_harmony_destructuring_;
+ bool allow_harmony_spread_arrays_;
bool allow_strong_mode_;
};
@@ -2508,12 +2514,13 @@ typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseArrayLiteral(
}
elem = this->GetLiteralTheHole(peek_position(), factory());
} else if (peek() == Token::ELLIPSIS) {
- ExpressionUnexpectedToken(classifier);
+ if (!allow_harmony_spread_arrays()) {
+ 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 {
« no previous file with comments | « src/parser.cc ('k') | src/runtime.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698