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_; } |
| 651 void set_yield_count(int yield_count) { yield_count_ = yield_count; } |
| 652 |
650 static int num_ids() { return parent_num_ids() + 1; } | 653 static int num_ids() { return parent_num_ids() + 1; } |
651 BailoutId OsrEntryId() const { return BailoutId(local_id(0)); } | 654 BailoutId OsrEntryId() const { return BailoutId(local_id(0)); } |
652 virtual BailoutId ContinueId() const = 0; | 655 virtual BailoutId ContinueId() const = 0; |
653 virtual BailoutId StackCheckId() const = 0; | 656 virtual BailoutId StackCheckId() const = 0; |
654 | 657 |
655 // Code generation | 658 // Code generation |
656 Label* continue_target() { return &continue_target_; } | 659 Label* continue_target() { return &continue_target_; } |
657 | 660 |
658 protected: | 661 protected: |
659 IterationStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) | 662 IterationStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) |
660 : BreakableStatement(zone, labels, TARGET_FOR_ANONYMOUS, pos), | 663 : BreakableStatement(zone, labels, TARGET_FOR_ANONYMOUS, pos), |
661 body_(NULL) {} | 664 body_(NULL), |
| 665 yield_count_(0) {} |
662 static int parent_num_ids() { return BreakableStatement::num_ids(); } | 666 static int parent_num_ids() { return BreakableStatement::num_ids(); } |
663 void Initialize(Statement* body) { body_ = body; } | 667 void Initialize(Statement* body) { body_ = body; } |
664 | 668 |
665 private: | 669 private: |
666 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 670 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
667 | 671 |
668 Statement* body_; | 672 Statement* body_; |
669 Label continue_target_; | 673 Label continue_target_; |
| 674 int yield_count_; |
670 }; | 675 }; |
671 | 676 |
672 | 677 |
673 class DoWhileStatement final : public IterationStatement { | 678 class DoWhileStatement final : public IterationStatement { |
674 public: | 679 public: |
675 DECLARE_NODE_TYPE(DoWhileStatement) | 680 DECLARE_NODE_TYPE(DoWhileStatement) |
676 | 681 |
677 void Initialize(Expression* cond, Statement* body) { | 682 void Initialize(Expression* cond, Statement* body) { |
678 IterationStatement::Initialize(body); | 683 IterationStatement::Initialize(body); |
679 cond_ = cond; | 684 cond_ = cond; |
(...skipping 1999 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2679 bool dont_optimize() { return dont_optimize_reason_ != kNoReason; } | 2684 bool dont_optimize() { return dont_optimize_reason_ != kNoReason; } |
2680 BailoutReason dont_optimize_reason() { return dont_optimize_reason_; } | 2685 BailoutReason dont_optimize_reason() { return dont_optimize_reason_; } |
2681 void set_dont_optimize_reason(BailoutReason reason) { | 2686 void set_dont_optimize_reason(BailoutReason reason) { |
2682 dont_optimize_reason_ = reason; | 2687 dont_optimize_reason_ = reason; |
2683 } | 2688 } |
2684 | 2689 |
2685 bool IsAnonymousFunctionDefinition() const final { | 2690 bool IsAnonymousFunctionDefinition() const final { |
2686 return is_anonymous_expression(); | 2691 return is_anonymous_expression(); |
2687 } | 2692 } |
2688 | 2693 |
| 2694 int yield_count() { return yield_count_; } |
| 2695 void set_yield_count(int yield_count) { yield_count_ = yield_count; } |
| 2696 |
2689 protected: | 2697 protected: |
2690 FunctionLiteral(Zone* zone, const AstString* name, | 2698 FunctionLiteral(Zone* zone, const AstString* name, |
2691 AstValueFactory* ast_value_factory, Scope* scope, | 2699 AstValueFactory* ast_value_factory, Scope* scope, |
2692 ZoneList<Statement*>* body, int materialized_literal_count, | 2700 ZoneList<Statement*>* body, int materialized_literal_count, |
2693 int expected_property_count, int parameter_count, | 2701 int expected_property_count, int parameter_count, |
2694 FunctionType function_type, | 2702 FunctionType function_type, |
2695 ParameterFlag has_duplicate_parameters, | 2703 ParameterFlag has_duplicate_parameters, |
2696 EagerCompileHint eager_compile_hint, FunctionKind kind, | 2704 EagerCompileHint eager_compile_hint, FunctionKind kind, |
2697 int position, bool is_function) | 2705 int position, bool is_function) |
2698 : Expression(zone, position), | 2706 : Expression(zone, position), |
2699 raw_name_(name), | 2707 raw_name_(name), |
2700 scope_(scope), | 2708 scope_(scope), |
2701 body_(body), | 2709 body_(body), |
2702 raw_inferred_name_(ast_value_factory->empty_string()), | 2710 raw_inferred_name_(ast_value_factory->empty_string()), |
2703 ast_properties_(zone), | 2711 ast_properties_(zone), |
2704 dont_optimize_reason_(kNoReason), | 2712 dont_optimize_reason_(kNoReason), |
2705 materialized_literal_count_(materialized_literal_count), | 2713 materialized_literal_count_(materialized_literal_count), |
2706 expected_property_count_(expected_property_count), | 2714 expected_property_count_(expected_property_count), |
2707 parameter_count_(parameter_count), | 2715 parameter_count_(parameter_count), |
2708 function_token_position_(RelocInfo::kNoPosition) { | 2716 function_token_position_(RelocInfo::kNoPosition), |
| 2717 yield_count_(0) { |
2709 bitfield_ = | 2718 bitfield_ = |
2710 IsDeclaration::encode(function_type == kDeclaration) | | 2719 IsDeclaration::encode(function_type == kDeclaration) | |
2711 IsNamedExpression::encode(function_type == kNamedExpression) | | 2720 IsNamedExpression::encode(function_type == kNamedExpression) | |
2712 IsAnonymousExpression::encode(function_type == kAnonymousExpression) | | 2721 IsAnonymousExpression::encode(function_type == kAnonymousExpression) | |
2713 Pretenure::encode(false) | | 2722 Pretenure::encode(false) | |
2714 HasDuplicateParameters::encode(has_duplicate_parameters == | 2723 HasDuplicateParameters::encode(has_duplicate_parameters == |
2715 kHasDuplicateParameters) | | 2724 kHasDuplicateParameters) | |
2716 IsFunction::encode(is_function) | | 2725 IsFunction::encode(is_function) | |
2717 ShouldEagerCompile::encode(eager_compile_hint == kShouldEagerCompile) | | 2726 ShouldEagerCompile::encode(eager_compile_hint == kShouldEagerCompile) | |
2718 FunctionKindBits::encode(kind) | ShouldBeUsedOnceHint::encode(false); | 2727 FunctionKindBits::encode(kind) | ShouldBeUsedOnceHint::encode(false); |
(...skipping 20 matching lines...) Expand all Loading... |
2739 ZoneList<Statement*>* body_; | 2748 ZoneList<Statement*>* body_; |
2740 const AstString* raw_inferred_name_; | 2749 const AstString* raw_inferred_name_; |
2741 Handle<String> inferred_name_; | 2750 Handle<String> inferred_name_; |
2742 AstProperties ast_properties_; | 2751 AstProperties ast_properties_; |
2743 BailoutReason dont_optimize_reason_; | 2752 BailoutReason dont_optimize_reason_; |
2744 | 2753 |
2745 int materialized_literal_count_; | 2754 int materialized_literal_count_; |
2746 int expected_property_count_; | 2755 int expected_property_count_; |
2747 int parameter_count_; | 2756 int parameter_count_; |
2748 int function_token_position_; | 2757 int function_token_position_; |
| 2758 int yield_count_; |
2749 }; | 2759 }; |
2750 | 2760 |
2751 | 2761 |
2752 class ClassLiteral final : public Expression { | 2762 class ClassLiteral final : public Expression { |
2753 public: | 2763 public: |
2754 typedef ObjectLiteralProperty Property; | 2764 typedef ObjectLiteralProperty Property; |
2755 | 2765 |
2756 DECLARE_NODE_TYPE(ClassLiteral) | 2766 DECLARE_NODE_TYPE(ClassLiteral) |
2757 | 2767 |
2758 Scope* scope() const { return scope_; } | 2768 Scope* scope() const { return scope_; } |
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3538 : NULL; \ | 3548 : NULL; \ |
3539 } | 3549 } |
3540 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) | 3550 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) |
3541 #undef DECLARE_NODE_FUNCTIONS | 3551 #undef DECLARE_NODE_FUNCTIONS |
3542 | 3552 |
3543 | 3553 |
3544 } // namespace internal | 3554 } // namespace internal |
3545 } // namespace v8 | 3555 } // namespace v8 |
3546 | 3556 |
3547 #endif // V8_AST_AST_H_ | 3557 #endif // V8_AST_AST_H_ |
OLD | NEW |