| Index: src/ast.h
|
| diff --git a/src/ast.h b/src/ast.h
|
| index 14f71a6cc28bfb03e95f2f767c97cce90727542d..d48d1820437619422346bef34c29fbfe0f3c8c2d 100644
|
| --- a/src/ast.h
|
| +++ b/src/ast.h
|
| @@ -75,6 +75,7 @@ namespace internal {
|
| V(ObjectLiteral) \
|
| V(ArrayLiteral) \
|
| V(Assignment) \
|
| + V(AssignmentPattern) \
|
| V(Yield) \
|
| V(Throw) \
|
| V(Property) \
|
| @@ -2396,6 +2397,42 @@ class Assignment final : public Expression {
|
| };
|
|
|
|
|
| +class AssignmentPattern final : public Expression {
|
| + public:
|
| + DECLARE_NODE_TYPE(AssignmentPattern)
|
| +
|
| + // AssignmentPattern should always be the Target of an Assignment.
|
| + // If encountered during compilation, and the assignment expression
|
| + // is not null (the node has been rewritten), the rewritten expression
|
| + // should be used in place of the normal assignment behaviour.
|
| + // Otherwise, the LHS is treated as the original pattern, which should
|
| + // result in an exception.
|
| + bool is_rewritten() const { return expression_ != pattern_; }
|
| + Expression* pattern() const { return pattern_; }
|
| + Expression* expression() const { return expression_; }
|
| +
|
| + static int num_ids() { return parent_num_ids(); }
|
| +
|
| + void set_expression(Expression* expr) {
|
| + // Only to be called by Parser::PatternRewriter
|
| + DCHECK_NE(expr, pattern_);
|
| + DCHECK_NOT_NULL(expr);
|
| + expression_ = expr;
|
| + }
|
| +
|
| + protected:
|
| + AssignmentPattern(Zone* zone, Expression* pattern, int pos)
|
| + : Expression(zone, pos), pattern_(pattern), expression_(pattern) {}
|
| + static int parent_num_ids() { return Expression::num_ids(); }
|
| +
|
| + private:
|
| + int local_id(int n) const { return base_id() + parent_num_ids() + n; }
|
| +
|
| + Expression* pattern_;
|
| + Expression* expression_;
|
| +};
|
| +
|
| +
|
| class Yield final : public Expression {
|
| public:
|
| DECLARE_NODE_TYPE(Yield)
|
| @@ -3557,6 +3594,11 @@ class AstNodeFactory final BASE_EMBEDDED {
|
| return assign;
|
| }
|
|
|
| + AssignmentPattern* NewAssignmentPattern(Expression* pattern, int pos) {
|
| + DCHECK(pattern->IsObjectLiteral() || pattern->IsArrayLiteral());
|
| + return new (local_zone_) AssignmentPattern(local_zone_, pattern, pos);
|
| + }
|
| +
|
| Yield* NewYield(Expression *generator_object,
|
| Expression* expression,
|
| Yield::Kind yield_kind,
|
|
|