| 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 906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 917 // result.done | 917 // result.done |
| 918 Expression* result_done() const { | 918 Expression* result_done() const { |
| 919 return result_done_; | 919 return result_done_; |
| 920 } | 920 } |
| 921 | 921 |
| 922 // each = result.value | 922 // each = result.value |
| 923 Expression* assign_each() const { | 923 Expression* assign_each() const { |
| 924 return assign_each_; | 924 return assign_each_; |
| 925 } | 925 } |
| 926 | 926 |
| 927 void set_assign_iterator(Expression* e) { assign_iterator_ = e; } |
| 928 void set_next_result(Expression* e) { next_result_ = e; } |
| 929 void set_result_done(Expression* e) { result_done_ = e; } |
| 930 void set_assign_each(Expression* e) { assign_each_ = e; } |
| 931 |
| 927 BailoutId ContinueId() const override { return EntryId(); } | 932 BailoutId ContinueId() const override { return EntryId(); } |
| 928 BailoutId StackCheckId() const override { return BackEdgeId(); } | 933 BailoutId StackCheckId() const override { return BackEdgeId(); } |
| 929 | 934 |
| 930 static int num_ids() { return parent_num_ids() + 1; } | 935 static int num_ids() { return parent_num_ids() + 1; } |
| 931 BailoutId BackEdgeId() const { return BailoutId(local_id(0)); } | 936 BailoutId BackEdgeId() const { return BailoutId(local_id(0)); } |
| 932 | 937 |
| 933 protected: | 938 protected: |
| 934 ForOfStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) | 939 ForOfStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) |
| 935 : ForEachStatement(zone, labels, pos), | 940 : ForEachStatement(zone, labels, pos), |
| 936 assign_iterator_(NULL), | 941 assign_iterator_(NULL), |
| (...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1675 int flags = depth() == 1 ? kShallowElements : kNoFlags; | 1680 int flags = depth() == 1 ? kShallowElements : kNoFlags; |
| 1676 if (disable_mementos) { | 1681 if (disable_mementos) { |
| 1677 flags |= kDisableMementos; | 1682 flags |= kDisableMementos; |
| 1678 } | 1683 } |
| 1679 if (is_strong()) { | 1684 if (is_strong()) { |
| 1680 flags |= kIsStrong; | 1685 flags |= kIsStrong; |
| 1681 } | 1686 } |
| 1682 return flags; | 1687 return flags; |
| 1683 } | 1688 } |
| 1684 | 1689 |
| 1690 // Provide a mechanism for iterating through values to rewrite spreads. |
| 1691 ZoneList<Expression*>::iterator FirstSpread() const { |
| 1692 return (first_spread_index_ >= 0) ? values_->begin() + first_spread_index_ |
| 1693 : values_->end(); |
| 1694 } |
| 1695 ZoneList<Expression*>::iterator EndValue() const { return values_->end(); } |
| 1696 |
| 1697 // Rewind an array literal omitting everything from the first spread on. |
| 1698 void RewindSpreads() { |
| 1699 values_->Rewind(first_spread_index_); |
| 1700 first_spread_index_ = -1; |
| 1701 } |
| 1702 |
| 1685 enum Flags { | 1703 enum Flags { |
| 1686 kNoFlags = 0, | 1704 kNoFlags = 0, |
| 1687 kShallowElements = 1, | 1705 kShallowElements = 1, |
| 1688 kDisableMementos = 1 << 1, | 1706 kDisableMementos = 1 << 1, |
| 1689 kIsStrong = 1 << 2 | 1707 kIsStrong = 1 << 2 |
| 1690 }; | 1708 }; |
| 1691 | 1709 |
| 1692 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, | 1710 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, |
| 1693 FeedbackVectorSlotCache* cache) override; | 1711 FeedbackVectorSlotCache* cache) override; |
| 1694 FeedbackVectorSlot LiteralFeedbackSlot() const { return literal_slot_; } | 1712 FeedbackVectorSlot LiteralFeedbackSlot() const { return literal_slot_; } |
| (...skipping 1683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3378 stack_overflow_ = false; \ | 3396 stack_overflow_ = false; \ |
| 3379 } \ | 3397 } \ |
| 3380 \ | 3398 \ |
| 3381 uintptr_t stack_limit_; \ | 3399 uintptr_t stack_limit_; \ |
| 3382 bool stack_overflow_ | 3400 bool stack_overflow_ |
| 3383 | 3401 |
| 3384 #define DEFINE_AST_REWRITER_SUBCLASS_MEMBERS() \ | 3402 #define DEFINE_AST_REWRITER_SUBCLASS_MEMBERS() \ |
| 3385 public: \ | 3403 public: \ |
| 3386 AstNode* Rewrite(AstNode* node) { \ | 3404 AstNode* Rewrite(AstNode* node) { \ |
| 3387 DCHECK_NULL(replacement_); \ | 3405 DCHECK_NULL(replacement_); \ |
| 3406 DCHECK_NOT_NULL(node); \ |
| 3388 Visit(node); \ | 3407 Visit(node); \ |
| 3389 if (HasStackOverflow()) return nullptr; \ | 3408 if (HasStackOverflow()) return node; \ |
| 3390 if (replacement_ == nullptr) return node; \ | 3409 if (replacement_ == nullptr) return node; \ |
| 3391 AstNode* result = replacement_; \ | 3410 AstNode* result = replacement_; \ |
| 3392 replacement_ = nullptr; \ | 3411 replacement_ = nullptr; \ |
| 3393 return result; \ | 3412 return result; \ |
| 3394 } \ | 3413 } \ |
| 3395 \ | 3414 \ |
| 3396 private: \ | 3415 private: \ |
| 3397 void InitializeAstRewriter(Isolate* isolate) { \ | 3416 void InitializeAstRewriter(Isolate* isolate) { \ |
| 3398 InitializeAstVisitor(isolate); \ | 3417 InitializeAstVisitor(isolate); \ |
| 3399 replacement_ = nullptr; \ | 3418 replacement_ = nullptr; \ |
| (...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3871 // the parser-level zone. | 3890 // the parser-level zone. |
| 3872 Zone* parser_zone_; | 3891 Zone* parser_zone_; |
| 3873 AstValueFactory* ast_value_factory_; | 3892 AstValueFactory* ast_value_factory_; |
| 3874 }; | 3893 }; |
| 3875 | 3894 |
| 3876 | 3895 |
| 3877 } // namespace internal | 3896 } // namespace internal |
| 3878 } // namespace v8 | 3897 } // namespace v8 |
| 3879 | 3898 |
| 3880 #endif // V8_AST_AST_H_ | 3899 #endif // V8_AST_AST_H_ |
| OLD | NEW |