Chromium Code Reviews| Index: src/parsing/parser-base.h |
| diff --git a/src/parsing/parser-base.h b/src/parsing/parser-base.h |
| index 9ce9c32309328c7cc890f4877ed169897099685b..c264eb6bc0e914bfaa7b08eae056decddacdba65 100644 |
| --- a/src/parsing/parser-base.h |
| +++ b/src/parsing/parser-base.h |
| @@ -217,7 +217,8 @@ class ParserBase { |
| allow_harmony_async_await_(false), |
| allow_harmony_restrictive_generators_(false), |
| allow_harmony_trailing_commas_(false), |
| - allow_harmony_class_fields_(false) {} |
| + allow_harmony_class_fields_(false), |
| + allow_harmony_object_spread_(false) {} |
| #define ALLOW_ACCESSORS(name) \ |
| bool allow_##name() const { return allow_##name##_; } \ |
| @@ -231,6 +232,7 @@ class ParserBase { |
| ALLOW_ACCESSORS(harmony_restrictive_generators); |
| ALLOW_ACCESSORS(harmony_trailing_commas); |
| ALLOW_ACCESSORS(harmony_class_fields); |
| + ALLOW_ACCESSORS(harmony_object_spread); |
| #undef ALLOW_ACCESSORS |
| @@ -1149,6 +1151,7 @@ class ParserBase { |
| kShorthandProperty, |
| kMethodProperty, |
| kClassField, |
| + kSpreadProperty, |
| kNotSet |
| }; |
| @@ -1455,6 +1458,7 @@ class ParserBase { |
| bool allow_harmony_restrictive_generators_; |
| bool allow_harmony_trailing_commas_; |
| bool allow_harmony_class_fields_; |
| + bool allow_harmony_object_spread_; |
| friend class DiscardableZoneScope; |
| }; |
| @@ -2108,6 +2112,24 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParsePropertyName( |
| break; |
| } |
| + case Token::ELLIPSIS: { |
| + if (allow_harmony_object_spread()) { |
| + // TODO(gsathya): Implement destructuring/rest |
| + BindingPatternUnexpectedToken(); |
| + classifier()->RecordAssignmentPatternError( |
| + scanner()->location(), MessageTemplate::kUnexpectedToken); |
| + |
| + *name = impl()->EmptyIdentifier(); |
| + Consume(Token::ELLIPSIS); |
| + ExpressionClassifier spread_classifier(this); |
| + expression = ParseAssignmentExpression(true, CHECK_OK); |
| + impl()->RewriteNonPattern(CHECK_OK); |
| + impl()->AccumulateFormalParameterContainmentErrors(); |
| + *kind = PropertyKind::kSpreadProperty; |
| + return expression; |
| + } |
| + } |
| + |
| default: |
| *name = ParseIdentifierName(CHECK_OK); |
| break; |
| @@ -2268,6 +2290,8 @@ ParserBase<Impl>::ParseClassPropertyDefinition( |
| *property_kind, *is_static, |
| *is_computed_name); |
| } |
| + case PropertyKind::kSpreadProperty: |
| + UNREACHABLE(); |
| } |
| UNREACHABLE(); |
| return impl()->EmptyClassLiteralProperty(); |
| @@ -2329,6 +2353,19 @@ ParserBase<Impl>::ParseObjectPropertyDefinition(ObjectLiteralChecker* checker, |
| is_computed_name, CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); |
| switch (kind) { |
| + case PropertyKind::kSpreadProperty: { |
|
adamk
2016/12/29 18:32:46
Nit: no need for the block.
gsathya
2017/01/05 22:18:36
Rest of the cases seem to be blocks. Changed anywa
adamk
2017/01/05 22:39:14
The rest of the cases that are blocks declare vari
|
| + DCHECK(allow_harmony_object_spread()); |
| + DCHECK(!is_get && !is_set && !is_generator && !is_async && |
| + !*is_computed_name); |
| + DCHECK(name_token == Token::ELLIPSIS); |
| + |
| + *is_computed_name = true; |
| + |
| + return factory()->NewObjectLiteralProperty( |
| + impl()->GetLiteralTheHole(kNoSourcePosition), name_expression, |
| + ObjectLiteralProperty::SPREAD, true); |
| + } |
| + |
| case PropertyKind::kValueProperty: { |
| DCHECK(!is_get && !is_set && !is_generator && !is_async); |