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 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
640 | 640 |
641 | 641 |
642 class IterationStatement : public BreakableStatement { | 642 class IterationStatement : public BreakableStatement { |
643 public: | 643 public: |
644 // Type testing & conversion. | 644 // Type testing & conversion. |
645 IterationStatement* AsIterationStatement() final { return this; } | 645 IterationStatement* AsIterationStatement() final { return this; } |
646 | 646 |
647 Statement* body() const { return body_; } | 647 Statement* body() const { return body_; } |
648 void set_body(Statement* s) { body_ = s; } | 648 void set_body(Statement* s) { body_ = s; } |
649 | 649 |
650 int yield_count() { return yield_count_; } | 650 int yield_count() const { return yield_count_; } |
| 651 int first_yield_id() const { return first_yield_id_; } |
651 void set_yield_count(int yield_count) { yield_count_ = yield_count; } | 652 void set_yield_count(int yield_count) { yield_count_ = yield_count; } |
| 653 void set_first_yield_id(int first_yield_id) { |
| 654 first_yield_id_ = first_yield_id; |
| 655 } |
652 | 656 |
653 static int num_ids() { return parent_num_ids() + 1; } | 657 static int num_ids() { return parent_num_ids() + 1; } |
654 BailoutId OsrEntryId() const { return BailoutId(local_id(0)); } | 658 BailoutId OsrEntryId() const { return BailoutId(local_id(0)); } |
655 virtual BailoutId ContinueId() const = 0; | 659 virtual BailoutId ContinueId() const = 0; |
656 virtual BailoutId StackCheckId() const = 0; | 660 virtual BailoutId StackCheckId() const = 0; |
657 | 661 |
658 // Code generation | 662 // Code generation |
659 Label* continue_target() { return &continue_target_; } | 663 Label* continue_target() { return &continue_target_; } |
660 | 664 |
661 protected: | 665 protected: |
662 IterationStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) | 666 IterationStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) |
663 : BreakableStatement(zone, labels, TARGET_FOR_ANONYMOUS, pos), | 667 : BreakableStatement(zone, labels, TARGET_FOR_ANONYMOUS, pos), |
664 body_(NULL), | 668 body_(NULL), |
665 yield_count_(0) {} | 669 yield_count_(0), |
| 670 first_yield_id_(0) {} |
666 static int parent_num_ids() { return BreakableStatement::num_ids(); } | 671 static int parent_num_ids() { return BreakableStatement::num_ids(); } |
667 void Initialize(Statement* body) { body_ = body; } | 672 void Initialize(Statement* body) { body_ = body; } |
668 | 673 |
669 private: | 674 private: |
670 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 675 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
671 | 676 |
672 Statement* body_; | 677 Statement* body_; |
673 Label continue_target_; | 678 Label continue_target_; |
674 int yield_count_; | 679 int yield_count_; |
| 680 int first_yield_id_; |
675 }; | 681 }; |
676 | 682 |
677 | 683 |
678 class DoWhileStatement final : public IterationStatement { | 684 class DoWhileStatement final : public IterationStatement { |
679 public: | 685 public: |
680 DECLARE_NODE_TYPE(DoWhileStatement) | 686 DECLARE_NODE_TYPE(DoWhileStatement) |
681 | 687 |
682 void Initialize(Expression* cond, Statement* body) { | 688 void Initialize(Expression* cond, Statement* body) { |
683 IterationStatement::Initialize(body); | 689 IterationStatement::Initialize(body); |
684 cond_ = cond; | 690 cond_ = cond; |
(...skipping 1839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2524 | 2530 |
2525 // Our Yield is different from the JS yield in that it "returns" its argument as | 2531 // Our Yield is different from the JS yield in that it "returns" its argument as |
2526 // is, without wrapping it in an iterator result object. Such wrapping, if | 2532 // is, without wrapping it in an iterator result object. Such wrapping, if |
2527 // desired, must be done beforehand (see the parser). | 2533 // desired, must be done beforehand (see the parser). |
2528 class Yield final : public Expression { | 2534 class Yield final : public Expression { |
2529 public: | 2535 public: |
2530 DECLARE_NODE_TYPE(Yield) | 2536 DECLARE_NODE_TYPE(Yield) |
2531 | 2537 |
2532 Expression* generator_object() const { return generator_object_; } | 2538 Expression* generator_object() const { return generator_object_; } |
2533 Expression* expression() const { return expression_; } | 2539 Expression* expression() const { return expression_; } |
| 2540 int yield_id() const { return yield_id_; } |
2534 | 2541 |
2535 void set_generator_object(Expression* e) { generator_object_ = e; } | 2542 void set_generator_object(Expression* e) { generator_object_ = e; } |
2536 void set_expression(Expression* e) { expression_ = e; } | 2543 void set_expression(Expression* e) { expression_ = e; } |
| 2544 void set_yield_id(int yield_id) { yield_id_ = yield_id; } |
2537 | 2545 |
2538 protected: | 2546 protected: |
2539 Yield(Zone* zone, Expression* generator_object, Expression* expression, | 2547 Yield(Zone* zone, Expression* generator_object, Expression* expression, |
2540 int pos) | 2548 int pos) |
2541 : Expression(zone, pos), | 2549 : Expression(zone, pos), |
2542 generator_object_(generator_object), | 2550 generator_object_(generator_object), |
2543 expression_(expression) {} | 2551 expression_(expression), |
| 2552 yield_id_(-1) {} |
2544 | 2553 |
2545 private: | 2554 private: |
2546 Expression* generator_object_; | 2555 Expression* generator_object_; |
2547 Expression* expression_; | 2556 Expression* expression_; |
| 2557 int yield_id_; |
2548 }; | 2558 }; |
2549 | 2559 |
2550 | 2560 |
2551 class Throw final : public Expression { | 2561 class Throw final : public Expression { |
2552 public: | 2562 public: |
2553 DECLARE_NODE_TYPE(Throw) | 2563 DECLARE_NODE_TYPE(Throw) |
2554 | 2564 |
2555 Expression* exception() const { return exception_; } | 2565 Expression* exception() const { return exception_; } |
2556 void set_exception(Expression* e) { exception_ = e; } | 2566 void set_exception(Expression* e) { exception_ = e; } |
2557 | 2567 |
(...skipping 990 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3548 : NULL; \ | 3558 : NULL; \ |
3549 } | 3559 } |
3550 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) | 3560 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) |
3551 #undef DECLARE_NODE_FUNCTIONS | 3561 #undef DECLARE_NODE_FUNCTIONS |
3552 | 3562 |
3553 | 3563 |
3554 } // namespace internal | 3564 } // namespace internal |
3555 } // namespace v8 | 3565 } // namespace v8 |
3556 | 3566 |
3557 #endif // V8_AST_AST_H_ | 3567 #endif // V8_AST_AST_H_ |
OLD | NEW |