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

Unified Diff: src/ast/ast.h

Issue 1564083002: Add spread rewriting (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase (just see comments) Created 4 years, 11 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/parsing/parser.h » ('j') | src/parsing/parser.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ast/ast.h
diff --git a/src/ast/ast.h b/src/ast/ast.h
index 7f00955a644fcaeeeca1be192c67a5afa7ec0b70..a48b90f31ef410704d14ecfb705a3791434513ea 100644
--- a/src/ast/ast.h
+++ b/src/ast/ast.h
@@ -1683,6 +1683,19 @@ class ArrayLiteral final : public MaterializedLiteral {
return flags;
}
+ // Provide a mechanism for iterating through values to rewrite spreads.
+ ZoneList<Expression*>::iterator FirstSpread() const {
+ return (first_spread_index_ >= 0) ? values_->begin() + first_spread_index_
+ : values_->end();
+ }
+ ZoneList<Expression*>::iterator EndValue() const { return values_->end(); }
+
+ // Rewind an array literal omitting everything from the first spread on.
+ void RewindSpreads() {
+ values_->Rewind(first_spread_index_);
+ first_spread_index_ = -1;
+ }
+
enum Flags {
kNoFlags = 0,
kShallowElements = 1,
@@ -2372,17 +2385,20 @@ class Spread final : public Expression {
Expression* expression() const { return expression_; }
void set_expression(Expression* e) { expression_ = e; }
+ int expression_position() const { return expr_pos_; }
+
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 pos, int expr_pos)
+ : Expression(zone, pos), expression_(expression), expr_pos_(expr_pos) {}
static int parent_num_ids() { return Expression::num_ids(); }
private:
int local_id(int n) const { return base_id() + parent_num_ids() + n; }
Expression* expression_;
+ int expr_pos_;
};
@@ -3389,8 +3405,8 @@ class AstNodeFactory final BASE_EMBEDDED {
CompareOperation(local_zone_, op, left, right, pos);
}
- Spread* NewSpread(Expression* expression, int pos) {
- return new (local_zone_) Spread(local_zone_, expression, pos);
+ Spread* NewSpread(Expression* expression, int pos, int expr_pos) {
+ return new (local_zone_) Spread(local_zone_, expression, pos, expr_pos);
}
Conditional* NewConditional(Expression* condition,
« no previous file with comments | « no previous file | src/parsing/parser.h » ('j') | src/parsing/parser.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698