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

Unified Diff: src/ast.h

Issue 1151503002: [destructuring] Implement spread binding patterns. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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 | « no previous file | src/ast-value-factory.h » ('j') | src/pattern-rewriter.cc » ('J')
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 60f0068d37aebe855c31c352469af4d9ca058bf5..74c0194f8d9ba5a741fed7fe8151aa0f979551b7 100644
--- a/src/ast.h
+++ b/src/ast.h
@@ -2204,16 +2204,26 @@ class Spread final : public Expression {
Expression* expression() const { return expression_; }
+ int literal_index() const {
+ DCHECK(literal_index_ >= 0);
+ return literal_index_;
+ }
+
static int num_ids() { return parent_num_ids(); }
protected:
- Spread(Zone* zone, Expression* expression, int pos)
- : Expression(zone, pos), expression_(expression) {}
+ Spread(Zone* zone, Expression* expression, int literal_index, int pos)
+ : Expression(zone, pos),
+ literal_index_(literal_index),
+ expression_(expression) {}
static int parent_num_ids() { return Expression::num_ids(); }
private:
int local_id(int n) const { return base_id() + parent_num_ids() + n; }
+ // Literal index is only used when Spread is renterpreted as a pattern.
rossberg 2015/05/20 12:57:35 Nit: typo
Dmitry Lomov (no reviews) 2015/05/20 14:22:02 Undid this change.
+ int literal_index_;
+
Expression* expression_;
};
@@ -3424,8 +3434,8 @@ class AstNodeFactory final BASE_EMBEDDED {
return new (zone_) CompareOperation(zone_, op, left, right, pos);
}
- Spread* NewSpread(Expression* expression, int pos) {
- return new (zone_) Spread(zone_, expression, pos);
+ Spread* NewSpread(Expression* expression, int literal_index, int pos) {
+ return new (zone_) Spread(zone_, expression, literal_index, pos);
}
Conditional* NewConditional(Expression* condition,
« no previous file with comments | « no previous file | src/ast-value-factory.h » ('j') | src/pattern-rewriter.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698