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

Unified Diff: src/ast.h

Issue 1168643005: [es6] parse destructuring assignment (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: WIP #1 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 | « no previous file | src/expression-classifier.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ast.h
diff --git a/src/ast.h b/src/ast.h
index 1366041387215bc4c018c4b1650d39ff5f6549c4..b497427bf228aaf59126cc0023d5d68486ba7cd5 100644
--- a/src/ast.h
+++ b/src/ast.h
@@ -368,6 +368,10 @@ class Expression : public AstNode {
// True iff the expression is a valid target for an assignment.
bool IsValidReferenceExpressionOrThis() const;
+ bool IsPatternOrLiteral() const {
+ return IsObjectLiteral() || IsArrayLiteral();
+ }
+
// Expression type bounds
Bounds bounds() const { return bounds_; }
void set_bounds(Bounds bounds) { bounds_ = bounds; }
@@ -2356,6 +2360,11 @@ class Assignment final : public Expression {
// This check relies on the definition order of token in token.h.
bool is_compound() const { return op() > Token::ASSIGN; }
+ // Returns true if op is `=` and LHS is might be a pattern
+ bool IsDestructuring() const {
+ return op() == Token::ASSIGN && target()->IsPatternOrLiteral();
+ }
+
static int num_ids() { return parent_num_ids() + 2; }
BailoutId AssignmentId() const { return BailoutId(local_id(0)); }
« no previous file with comments | « no previous file | src/expression-classifier.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698