OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_AST_AST_H_ | 5 #ifndef V8_AST_AST_H_ |
6 #define V8_AST_AST_H_ | 6 #define V8_AST_AST_H_ |
7 | 7 |
8 #include "src/assembler.h" | 8 #include "src/assembler.h" |
9 #include "src/ast/ast-value-factory.h" | 9 #include "src/ast/ast-value-factory.h" |
10 #include "src/ast/modules.h" | 10 #include "src/ast/modules.h" |
(...skipping 1665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1676 int flags = depth() == 1 ? kShallowElements : kNoFlags; | 1676 int flags = depth() == 1 ? kShallowElements : kNoFlags; |
1677 if (disable_mementos) { | 1677 if (disable_mementos) { |
1678 flags |= kDisableMementos; | 1678 flags |= kDisableMementos; |
1679 } | 1679 } |
1680 if (is_strong()) { | 1680 if (is_strong()) { |
1681 flags |= kIsStrong; | 1681 flags |= kIsStrong; |
1682 } | 1682 } |
1683 return flags; | 1683 return flags; |
1684 } | 1684 } |
1685 | 1685 |
| 1686 // Provide a mechanism for iterating through values to rewrite spreads. |
| 1687 ZoneList<Expression*>::iterator FirstSpread() const { |
| 1688 return (first_spread_index_ >= 0) ? values_->begin() + first_spread_index_ |
| 1689 : values_->end(); |
| 1690 } |
| 1691 ZoneList<Expression*>::iterator EndValue() const { return values_->end(); } |
| 1692 |
| 1693 // Rewind an array literal omitting everything from the first spread on. |
| 1694 void RewindSpreads() { |
| 1695 values_->Rewind(first_spread_index_); |
| 1696 first_spread_index_ = -1; |
| 1697 } |
| 1698 |
1686 enum Flags { | 1699 enum Flags { |
1687 kNoFlags = 0, | 1700 kNoFlags = 0, |
1688 kShallowElements = 1, | 1701 kShallowElements = 1, |
1689 kDisableMementos = 1 << 1, | 1702 kDisableMementos = 1 << 1, |
1690 kIsStrong = 1 << 2 | 1703 kIsStrong = 1 << 2 |
1691 }; | 1704 }; |
1692 | 1705 |
1693 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, | 1706 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, |
1694 FeedbackVectorSlotCache* cache) override; | 1707 FeedbackVectorSlotCache* cache) override; |
1695 FeedbackVectorSlot LiteralFeedbackSlot() const { return literal_slot_; } | 1708 FeedbackVectorSlot LiteralFeedbackSlot() const { return literal_slot_; } |
(...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2365 }; | 2378 }; |
2366 | 2379 |
2367 | 2380 |
2368 class Spread final : public Expression { | 2381 class Spread final : public Expression { |
2369 public: | 2382 public: |
2370 DECLARE_NODE_TYPE(Spread) | 2383 DECLARE_NODE_TYPE(Spread) |
2371 | 2384 |
2372 Expression* expression() const { return expression_; } | 2385 Expression* expression() const { return expression_; } |
2373 void set_expression(Expression* e) { expression_ = e; } | 2386 void set_expression(Expression* e) { expression_ = e; } |
2374 | 2387 |
| 2388 int expression_position() const { return expr_pos_; } |
| 2389 |
2375 static int num_ids() { return parent_num_ids(); } | 2390 static int num_ids() { return parent_num_ids(); } |
2376 | 2391 |
2377 protected: | 2392 protected: |
2378 Spread(Zone* zone, Expression* expression, int pos) | 2393 Spread(Zone* zone, Expression* expression, int pos, int expr_pos) |
2379 : Expression(zone, pos), expression_(expression) {} | 2394 : Expression(zone, pos), expression_(expression), expr_pos_(expr_pos) {} |
2380 static int parent_num_ids() { return Expression::num_ids(); } | 2395 static int parent_num_ids() { return Expression::num_ids(); } |
2381 | 2396 |
2382 private: | 2397 private: |
2383 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 2398 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
2384 | 2399 |
2385 Expression* expression_; | 2400 Expression* expression_; |
| 2401 int expr_pos_; |
2386 }; | 2402 }; |
2387 | 2403 |
2388 | 2404 |
2389 class Conditional final : public Expression { | 2405 class Conditional final : public Expression { |
2390 public: | 2406 public: |
2391 DECLARE_NODE_TYPE(Conditional) | 2407 DECLARE_NODE_TYPE(Conditional) |
2392 | 2408 |
2393 Expression* condition() const { return condition_; } | 2409 Expression* condition() const { return condition_; } |
2394 Expression* then_expression() const { return then_expression_; } | 2410 Expression* then_expression() const { return then_expression_; } |
2395 Expression* else_expression() const { return else_expression_; } | 2411 Expression* else_expression() const { return else_expression_; } |
(...skipping 986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3382 } | 3398 } |
3383 | 3399 |
3384 CompareOperation* NewCompareOperation(Token::Value op, | 3400 CompareOperation* NewCompareOperation(Token::Value op, |
3385 Expression* left, | 3401 Expression* left, |
3386 Expression* right, | 3402 Expression* right, |
3387 int pos) { | 3403 int pos) { |
3388 return new (local_zone_) | 3404 return new (local_zone_) |
3389 CompareOperation(local_zone_, op, left, right, pos); | 3405 CompareOperation(local_zone_, op, left, right, pos); |
3390 } | 3406 } |
3391 | 3407 |
3392 Spread* NewSpread(Expression* expression, int pos) { | 3408 Spread* NewSpread(Expression* expression, int pos, int expr_pos) { |
3393 return new (local_zone_) Spread(local_zone_, expression, pos); | 3409 return new (local_zone_) Spread(local_zone_, expression, pos, expr_pos); |
3394 } | 3410 } |
3395 | 3411 |
3396 Conditional* NewConditional(Expression* condition, | 3412 Conditional* NewConditional(Expression* condition, |
3397 Expression* then_expression, | 3413 Expression* then_expression, |
3398 Expression* else_expression, | 3414 Expression* else_expression, |
3399 int position) { | 3415 int position) { |
3400 return new (local_zone_) Conditional( | 3416 return new (local_zone_) Conditional( |
3401 local_zone_, condition, then_expression, else_expression, position); | 3417 local_zone_, condition, then_expression, else_expression, position); |
3402 } | 3418 } |
3403 | 3419 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3526 // the parser-level zone. | 3542 // the parser-level zone. |
3527 Zone* parser_zone_; | 3543 Zone* parser_zone_; |
3528 AstValueFactory* ast_value_factory_; | 3544 AstValueFactory* ast_value_factory_; |
3529 }; | 3545 }; |
3530 | 3546 |
3531 | 3547 |
3532 } // namespace internal | 3548 } // namespace internal |
3533 } // namespace v8 | 3549 } // namespace v8 |
3534 | 3550 |
3535 #endif // V8_AST_AST_H_ | 3551 #endif // V8_AST_AST_H_ |
OLD | NEW |