| 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 V(BinaryOperation) \ | 86 V(BinaryOperation) \ |
| 87 V(CompareOperation) \ | 87 V(CompareOperation) \ |
| 88 V(Spread) \ | 88 V(Spread) \ |
| 89 V(ThisFunction) \ | 89 V(ThisFunction) \ |
| 90 V(SuperPropertyReference) \ | 90 V(SuperPropertyReference) \ |
| 91 V(SuperCallReference) \ | 91 V(SuperCallReference) \ |
| 92 V(CaseClause) \ | 92 V(CaseClause) \ |
| 93 V(EmptyParentheses) \ | 93 V(EmptyParentheses) \ |
| 94 V(DoExpression) | 94 V(DoExpression) |
| 95 | 95 |
| 96 #define AST_NODE_LIST(V) \ | 96 #define AST_NODE_LIST(V) \ |
| 97 DECLARATION_NODE_LIST(V) \ | 97 DECLARATION_NODE_LIST(V) \ |
| 98 STATEMENT_NODE_LIST(V) \ | 98 STATEMENT_NODE_LIST(V) \ |
| 99 EXPRESSION_NODE_LIST(V) | 99 EXPRESSION_NODE_LIST(V) |
| 100 | 100 |
| 101 // Forward declarations | 101 // Forward declarations |
| 102 class AstNodeFactory; | 102 class AstNodeFactory; |
| 103 class AstVisitor; | 103 class AstVisitor; |
| 104 class Declaration; | 104 class Declaration; |
| 105 class Module; | 105 class Module; |
| 106 class BreakableStatement; | 106 class BreakableStatement; |
| 107 class Expression; | 107 class Expression; |
| 108 class IterationStatement; | 108 class IterationStatement; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 | 184 |
| 185 private: | 185 private: |
| 186 Flags flags_; | 186 Flags flags_; |
| 187 int node_count_; | 187 int node_count_; |
| 188 FeedbackVectorSpec spec_; | 188 FeedbackVectorSpec spec_; |
| 189 }; | 189 }; |
| 190 | 190 |
| 191 DEFINE_OPERATORS_FOR_FLAGS(AstProperties::Flags) | 191 DEFINE_OPERATORS_FOR_FLAGS(AstProperties::Flags) |
| 192 | 192 |
| 193 | 193 |
| 194 class AstNode: public ZoneObject { | 194 class AstNode : public ZoneObject { |
| 195 public: | 195 public: |
| 196 #define DECLARE_TYPE_ENUM(type) k##type, | 196 #define DECLARE_TYPE_ENUM(type) k##type, |
| 197 enum NodeType { | 197 enum NodeType { AST_NODE_LIST(DECLARE_TYPE_ENUM) kInvalid = -1 }; |
| 198 AST_NODE_LIST(DECLARE_TYPE_ENUM) | |
| 199 kInvalid = -1 | |
| 200 }; | |
| 201 #undef DECLARE_TYPE_ENUM | 198 #undef DECLARE_TYPE_ENUM |
| 202 | 199 |
| 203 void* operator new(size_t size, Zone* zone) { return zone->New(size); } | 200 void* operator new(size_t size, Zone* zone) { return zone->New(size); } |
| 204 | 201 |
| 205 explicit AstNode(int position): position_(position) {} | 202 explicit AstNode(int position) : position_(position) {} |
| 206 virtual ~AstNode() {} | 203 virtual ~AstNode() {} |
| 207 | 204 |
| 208 virtual void Accept(AstVisitor* v) = 0; | 205 virtual void Accept(AstVisitor* v) = 0; |
| 209 virtual NodeType node_type() const = 0; | 206 virtual NodeType node_type() const = 0; |
| 210 int position() const { return position_; } | 207 int position() const { return position_; } |
| 211 | 208 |
| 212 // Type testing & conversion functions overridden by concrete subclasses. | 209 // Type testing & conversion functions overridden by concrete subclasses. |
| 213 #define DECLARE_NODE_FUNCTIONS(type) \ | 210 #define DECLARE_NODE_FUNCTIONS(type) \ |
| 214 bool Is##type() const { return node_type() == AstNode::k##type; } \ | 211 bool Is##type() const { return node_type() == AstNode::k##type; } \ |
| 215 type* As##type() { \ | 212 type* As##type() { \ |
| 216 return Is##type() ? reinterpret_cast<type*>(this) : NULL; \ | 213 return Is##type() ? reinterpret_cast<type*>(this) : NULL; \ |
| 217 } \ | 214 } \ |
| 218 const type* As##type() const { \ | 215 const type* As##type() const { \ |
| 219 return Is##type() ? reinterpret_cast<const type*>(this) : NULL; \ | 216 return Is##type() ? reinterpret_cast<const type*>(this) : NULL; \ |
| 220 } | 217 } |
| 221 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) | 218 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) |
| 222 #undef DECLARE_NODE_FUNCTIONS | 219 #undef DECLARE_NODE_FUNCTIONS |
| 223 | 220 |
| 224 virtual BreakableStatement* AsBreakableStatement() { return NULL; } | 221 virtual BreakableStatement* AsBreakableStatement() { return NULL; } |
| 225 virtual IterationStatement* AsIterationStatement() { return NULL; } | 222 virtual IterationStatement* AsIterationStatement() { return NULL; } |
| 226 virtual MaterializedLiteral* AsMaterializedLiteral() { return NULL; } | 223 virtual MaterializedLiteral* AsMaterializedLiteral() { return NULL; } |
| 227 | 224 |
| 228 // The interface for feedback slots, with default no-op implementations for | 225 // The interface for feedback slots, with default no-op implementations for |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 if (at(i)->FindRootMap() != root_map) { | 275 if (at(i)->FindRootMap() != root_map) { |
| 279 list_.RemoveElement(list_.at(i)); | 276 list_.RemoveElement(list_.at(i)); |
| 280 } | 277 } |
| 281 } | 278 } |
| 282 } | 279 } |
| 283 | 280 |
| 284 void Add(Handle<Map> handle, Zone* zone) { | 281 void Add(Handle<Map> handle, Zone* zone) { |
| 285 list_.Add(handle.location(), zone); | 282 list_.Add(handle.location(), zone); |
| 286 } | 283 } |
| 287 | 284 |
| 288 Handle<Map> at(int i) const { | 285 Handle<Map> at(int i) const { return Handle<Map>(list_.at(i)); } |
| 289 return Handle<Map>(list_.at(i)); | |
| 290 } | |
| 291 | 286 |
| 292 Handle<Map> first() const { return at(0); } | 287 Handle<Map> first() const { return at(0); } |
| 293 Handle<Map> last() const { return at(length() - 1); } | 288 Handle<Map> last() const { return at(length() - 1); } |
| 294 | 289 |
| 295 private: | 290 private: |
| 296 // The list stores pointers to Map*, that is Map**, so it's GC safe. | 291 // The list stores pointers to Map*, that is Map**, so it's GC safe. |
| 297 SmallPointerList<Map*> list_; | 292 SmallPointerList<Map*> list_; |
| 298 | 293 |
| 299 DISALLOW_COPY_AND_ASSIGN(SmallMapList); | 294 DISALLOW_COPY_AND_ASSIGN(SmallMapList); |
| 300 }; | 295 }; |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 Bounds bounds_; | 392 Bounds bounds_; |
| 398 class ToBooleanTypesField : public BitField16<uint16_t, 0, 9> {}; | 393 class ToBooleanTypesField : public BitField16<uint16_t, 0, 9> {}; |
| 399 uint16_t bit_field_; | 394 uint16_t bit_field_; |
| 400 // Ends with 16-bit field; deriving classes in turn begin with | 395 // Ends with 16-bit field; deriving classes in turn begin with |
| 401 // 16-bit fields for optimum packing efficiency. | 396 // 16-bit fields for optimum packing efficiency. |
| 402 }; | 397 }; |
| 403 | 398 |
| 404 | 399 |
| 405 class BreakableStatement : public Statement { | 400 class BreakableStatement : public Statement { |
| 406 public: | 401 public: |
| 407 enum BreakableType { | 402 enum BreakableType { TARGET_FOR_ANONYMOUS, TARGET_FOR_NAMED_ONLY }; |
| 408 TARGET_FOR_ANONYMOUS, | |
| 409 TARGET_FOR_NAMED_ONLY | |
| 410 }; | |
| 411 | 403 |
| 412 // The labels associated with this statement. May be NULL; | 404 // The labels associated with this statement. May be NULL; |
| 413 // if it is != NULL, guaranteed to contain at least one entry. | 405 // if it is != NULL, guaranteed to contain at least one entry. |
| 414 ZoneList<const AstRawString*>* labels() const { return labels_; } | 406 ZoneList<const AstRawString*>* labels() const { return labels_; } |
| 415 | 407 |
| 416 // Type testing & conversion. | 408 // Type testing & conversion. |
| 417 BreakableStatement* AsBreakableStatement() final { return this; } | 409 BreakableStatement* AsBreakableStatement() final { return this; } |
| 418 | 410 |
| 419 // Code generation | 411 // Code generation |
| 420 Label* break_target() { return &break_target_; } | 412 Label* break_target() { return &break_target_; } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 public: | 451 public: |
| 460 DECLARE_NODE_TYPE(Block) | 452 DECLARE_NODE_TYPE(Block) |
| 461 | 453 |
| 462 ZoneList<Statement*>* statements() { return &statements_; } | 454 ZoneList<Statement*>* statements() { return &statements_; } |
| 463 bool ignore_completion_value() const { return ignore_completion_value_; } | 455 bool ignore_completion_value() const { return ignore_completion_value_; } |
| 464 | 456 |
| 465 static int num_ids() { return parent_num_ids() + 1; } | 457 static int num_ids() { return parent_num_ids() + 1; } |
| 466 BailoutId DeclsId() const { return BailoutId(local_id(0)); } | 458 BailoutId DeclsId() const { return BailoutId(local_id(0)); } |
| 467 | 459 |
| 468 bool IsJump() const override { | 460 bool IsJump() const override { |
| 469 return !statements_.is_empty() && statements_.last()->IsJump() | 461 return !statements_.is_empty() && statements_.last()->IsJump() && |
| 470 && labels() == NULL; // Good enough as an approximation... | 462 labels() == NULL; // Good enough as an approximation... |
| 471 } | 463 } |
| 472 | 464 |
| 473 Scope* scope() const { return scope_; } | 465 Scope* scope() const { return scope_; } |
| 474 void set_scope(Scope* scope) { scope_ = scope; } | 466 void set_scope(Scope* scope) { scope_ = scope; } |
| 475 | 467 |
| 476 protected: | 468 protected: |
| 477 Block(Zone* zone, ZoneList<const AstRawString*>* labels, int capacity, | 469 Block(Zone* zone, ZoneList<const AstRawString*>* labels, int capacity, |
| 478 bool ignore_completion_value, int pos) | 470 bool ignore_completion_value, int pos) |
| 479 : BreakableStatement(zone, labels, TARGET_FOR_NAMED_ONLY, pos), | 471 : BreakableStatement(zone, labels, TARGET_FOR_NAMED_ONLY, pos), |
| 480 statements_(capacity, zone), | 472 statements_(capacity, zone), |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 public: | 563 public: |
| 572 DECLARE_NODE_TYPE(FunctionDeclaration) | 564 DECLARE_NODE_TYPE(FunctionDeclaration) |
| 573 | 565 |
| 574 FunctionLiteral* fun() const { return fun_; } | 566 FunctionLiteral* fun() const { return fun_; } |
| 575 InitializationFlag initialization() const override { | 567 InitializationFlag initialization() const override { |
| 576 return kCreatedInitialized; | 568 return kCreatedInitialized; |
| 577 } | 569 } |
| 578 bool IsInlineable() const override; | 570 bool IsInlineable() const override; |
| 579 | 571 |
| 580 protected: | 572 protected: |
| 581 FunctionDeclaration(Zone* zone, | 573 FunctionDeclaration(Zone* zone, VariableProxy* proxy, VariableMode mode, |
| 582 VariableProxy* proxy, | 574 FunctionLiteral* fun, Scope* scope, int pos) |
| 583 VariableMode mode, | 575 : Declaration(zone, proxy, mode, scope, pos), fun_(fun) { |
| 584 FunctionLiteral* fun, | |
| 585 Scope* scope, | |
| 586 int pos) | |
| 587 : Declaration(zone, proxy, mode, scope, pos), | |
| 588 fun_(fun) { | |
| 589 DCHECK(mode == VAR || mode == LET || mode == CONST); | 576 DCHECK(mode == VAR || mode == LET || mode == CONST); |
| 590 DCHECK(fun != NULL); | 577 DCHECK(fun != NULL); |
| 591 } | 578 } |
| 592 | 579 |
| 593 private: | 580 private: |
| 594 FunctionLiteral* fun_; | 581 FunctionLiteral* fun_; |
| 595 }; | 582 }; |
| 596 | 583 |
| 597 | 584 |
| 598 class ImportDeclaration final : public Declaration { | 585 class ImportDeclaration final : public Declaration { |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 661 | 648 |
| 662 Statement* body() const { return body_; } | 649 Statement* body() const { return body_; } |
| 663 void set_body(Statement* s) { body_ = s; } | 650 void set_body(Statement* s) { body_ = s; } |
| 664 | 651 |
| 665 static int num_ids() { return parent_num_ids() + 1; } | 652 static int num_ids() { return parent_num_ids() + 1; } |
| 666 BailoutId OsrEntryId() const { return BailoutId(local_id(0)); } | 653 BailoutId OsrEntryId() const { return BailoutId(local_id(0)); } |
| 667 virtual BailoutId ContinueId() const = 0; | 654 virtual BailoutId ContinueId() const = 0; |
| 668 virtual BailoutId StackCheckId() const = 0; | 655 virtual BailoutId StackCheckId() const = 0; |
| 669 | 656 |
| 670 // Code generation | 657 // Code generation |
| 671 Label* continue_target() { return &continue_target_; } | 658 Label* continue_target() { return &continue_target_; } |
| 672 | 659 |
| 673 protected: | 660 protected: |
| 674 IterationStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) | 661 IterationStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) |
| 675 : BreakableStatement(zone, labels, TARGET_FOR_ANONYMOUS, pos), | 662 : BreakableStatement(zone, labels, TARGET_FOR_ANONYMOUS, pos), |
| 676 body_(NULL) {} | 663 body_(NULL) {} |
| 677 static int parent_num_ids() { return BreakableStatement::num_ids(); } | 664 static int parent_num_ids() { return BreakableStatement::num_ids(); } |
| 678 void Initialize(Statement* body) { body_ = body; } | 665 void Initialize(Statement* body) { body_ = body; } |
| 679 | 666 |
| 680 private: | 667 private: |
| 681 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 668 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 738 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 725 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
| 739 | 726 |
| 740 Expression* cond_; | 727 Expression* cond_; |
| 741 }; | 728 }; |
| 742 | 729 |
| 743 | 730 |
| 744 class ForStatement final : public IterationStatement { | 731 class ForStatement final : public IterationStatement { |
| 745 public: | 732 public: |
| 746 DECLARE_NODE_TYPE(ForStatement) | 733 DECLARE_NODE_TYPE(ForStatement) |
| 747 | 734 |
| 748 void Initialize(Statement* init, | 735 void Initialize(Statement* init, Expression* cond, Statement* next, |
| 749 Expression* cond, | |
| 750 Statement* next, | |
| 751 Statement* body) { | 736 Statement* body) { |
| 752 IterationStatement::Initialize(body); | 737 IterationStatement::Initialize(body); |
| 753 init_ = init; | 738 init_ = init; |
| 754 cond_ = cond; | 739 cond_ = cond; |
| 755 next_ = next; | 740 next_ = next; |
| 756 } | 741 } |
| 757 | 742 |
| 758 Statement* init() const { return init_; } | 743 Statement* init() const { return init_; } |
| 759 Expression* cond() const { return cond_; } | 744 Expression* cond() const { return cond_; } |
| 760 Statement* next() const { return next_; } | 745 Statement* next() const { return next_; } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 777 | 762 |
| 778 Statement* init_; | 763 Statement* init_; |
| 779 Expression* cond_; | 764 Expression* cond_; |
| 780 Statement* next_; | 765 Statement* next_; |
| 781 }; | 766 }; |
| 782 | 767 |
| 783 | 768 |
| 784 class ForEachStatement : public IterationStatement { | 769 class ForEachStatement : public IterationStatement { |
| 785 public: | 770 public: |
| 786 enum VisitMode { | 771 enum VisitMode { |
| 787 ENUMERATE, // for (each in subject) body; | 772 ENUMERATE, // for (each in subject) body; |
| 788 ITERATE // for (each of subject) body; | 773 ITERATE // for (each of subject) body; |
| 789 }; | 774 }; |
| 790 | 775 |
| 791 void Initialize(Expression* each, Expression* subject, Statement* body) { | 776 void Initialize(Expression* each, Expression* subject, Statement* body) { |
| 792 IterationStatement::Initialize(body); | 777 IterationStatement::Initialize(body); |
| 793 each_ = each; | 778 each_ = each; |
| 794 subject_ = subject; | 779 subject_ = subject; |
| 795 } | 780 } |
| 796 | 781 |
| 797 Expression* each() const { return each_; } | 782 Expression* each() const { return each_; } |
| 798 Expression* subject() const { return subject_; } | 783 Expression* subject() const { return subject_; } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 809 Expression* each_; | 794 Expression* each_; |
| 810 Expression* subject_; | 795 Expression* subject_; |
| 811 FeedbackVectorSlot each_slot_; | 796 FeedbackVectorSlot each_slot_; |
| 812 }; | 797 }; |
| 813 | 798 |
| 814 | 799 |
| 815 class ForInStatement final : public ForEachStatement { | 800 class ForInStatement final : public ForEachStatement { |
| 816 public: | 801 public: |
| 817 DECLARE_NODE_TYPE(ForInStatement) | 802 DECLARE_NODE_TYPE(ForInStatement) |
| 818 | 803 |
| 819 Expression* enumerable() const { | 804 Expression* enumerable() const { return subject(); } |
| 820 return subject(); | |
| 821 } | |
| 822 | 805 |
| 823 // Type feedback information. | 806 // Type feedback information. |
| 824 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, | 807 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, |
| 825 FeedbackVectorSlotCache* cache) override { | 808 FeedbackVectorSlotCache* cache) override { |
| 826 ForEachStatement::AssignFeedbackVectorSlots(isolate, spec, cache); | 809 ForEachStatement::AssignFeedbackVectorSlots(isolate, spec, cache); |
| 827 for_in_feedback_slot_ = spec->AddGeneralSlot(); | 810 for_in_feedback_slot_ = spec->AddGeneralSlot(); |
| 828 } | 811 } |
| 829 | 812 |
| 830 FeedbackVectorSlot ForInFeedbackSlot() { | 813 FeedbackVectorSlot ForInFeedbackSlot() { |
| 831 DCHECK(!for_in_feedback_slot_.IsInvalid()); | 814 DCHECK(!for_in_feedback_slot_.IsInvalid()); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 856 | 839 |
| 857 ForInType for_in_type_; | 840 ForInType for_in_type_; |
| 858 FeedbackVectorSlot for_in_feedback_slot_; | 841 FeedbackVectorSlot for_in_feedback_slot_; |
| 859 }; | 842 }; |
| 860 | 843 |
| 861 | 844 |
| 862 class ForOfStatement final : public ForEachStatement { | 845 class ForOfStatement final : public ForEachStatement { |
| 863 public: | 846 public: |
| 864 DECLARE_NODE_TYPE(ForOfStatement) | 847 DECLARE_NODE_TYPE(ForOfStatement) |
| 865 | 848 |
| 866 void Initialize(Expression* each, | 849 void Initialize(Expression* each, Expression* subject, Statement* body, |
| 867 Expression* subject, | 850 Expression* assign_iterator, Expression* next_result, |
| 868 Statement* body, | 851 Expression* result_done, Expression* assign_each) { |
| 869 Expression* assign_iterator, | |
| 870 Expression* next_result, | |
| 871 Expression* result_done, | |
| 872 Expression* assign_each) { | |
| 873 ForEachStatement::Initialize(each, subject, body); | 852 ForEachStatement::Initialize(each, subject, body); |
| 874 assign_iterator_ = assign_iterator; | 853 assign_iterator_ = assign_iterator; |
| 875 next_result_ = next_result; | 854 next_result_ = next_result; |
| 876 result_done_ = result_done; | 855 result_done_ = result_done; |
| 877 assign_each_ = assign_each; | 856 assign_each_ = assign_each; |
| 878 } | 857 } |
| 879 | 858 |
| 880 Expression* iterable() const { | 859 Expression* iterable() const { return subject(); } |
| 881 return subject(); | |
| 882 } | |
| 883 | 860 |
| 884 // iterator = subject[Symbol.iterator]() | 861 // iterator = subject[Symbol.iterator]() |
| 885 Expression* assign_iterator() const { | 862 Expression* assign_iterator() const { return assign_iterator_; } |
| 886 return assign_iterator_; | |
| 887 } | |
| 888 | 863 |
| 889 // result = iterator.next() // with type check | 864 // result = iterator.next() // with type check |
| 890 Expression* next_result() const { | 865 Expression* next_result() const { return next_result_; } |
| 891 return next_result_; | |
| 892 } | |
| 893 | 866 |
| 894 // result.done | 867 // result.done |
| 895 Expression* result_done() const { | 868 Expression* result_done() const { return result_done_; } |
| 896 return result_done_; | |
| 897 } | |
| 898 | 869 |
| 899 // each = result.value | 870 // each = result.value |
| 900 Expression* assign_each() const { | 871 Expression* assign_each() const { return assign_each_; } |
| 901 return assign_each_; | |
| 902 } | |
| 903 | 872 |
| 904 BailoutId ContinueId() const override { return EntryId(); } | 873 BailoutId ContinueId() const override { return EntryId(); } |
| 905 BailoutId StackCheckId() const override { return BackEdgeId(); } | 874 BailoutId StackCheckId() const override { return BackEdgeId(); } |
| 906 | 875 |
| 907 static int num_ids() { return parent_num_ids() + 1; } | 876 static int num_ids() { return parent_num_ids() + 1; } |
| 908 BailoutId BackEdgeId() const { return BailoutId(local_id(0)); } | 877 BailoutId BackEdgeId() const { return BailoutId(local_id(0)); } |
| 909 | 878 |
| 910 protected: | 879 protected: |
| 911 ForOfStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) | 880 ForOfStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) |
| 912 : ForEachStatement(zone, labels, pos), | 881 : ForEachStatement(zone, labels, pos), |
| (...skipping 16 matching lines...) Expand all Loading... |
| 929 class ExpressionStatement final : public Statement { | 898 class ExpressionStatement final : public Statement { |
| 930 public: | 899 public: |
| 931 DECLARE_NODE_TYPE(ExpressionStatement) | 900 DECLARE_NODE_TYPE(ExpressionStatement) |
| 932 | 901 |
| 933 void set_expression(Expression* e) { expression_ = e; } | 902 void set_expression(Expression* e) { expression_ = e; } |
| 934 Expression* expression() const { return expression_; } | 903 Expression* expression() const { return expression_; } |
| 935 bool IsJump() const override { return expression_->IsThrow(); } | 904 bool IsJump() const override { return expression_->IsThrow(); } |
| 936 | 905 |
| 937 protected: | 906 protected: |
| 938 ExpressionStatement(Zone* zone, Expression* expression, int pos) | 907 ExpressionStatement(Zone* zone, Expression* expression, int pos) |
| 939 : Statement(zone, pos), expression_(expression) { } | 908 : Statement(zone, pos), expression_(expression) {} |
| 940 | 909 |
| 941 private: | 910 private: |
| 942 Expression* expression_; | 911 Expression* expression_; |
| 943 }; | 912 }; |
| 944 | 913 |
| 945 | 914 |
| 946 class JumpStatement : public Statement { | 915 class JumpStatement : public Statement { |
| 947 public: | 916 public: |
| 948 bool IsJump() const final { return true; } | 917 bool IsJump() const final { return true; } |
| 949 | 918 |
| 950 protected: | 919 protected: |
| 951 explicit JumpStatement(Zone* zone, int pos) : Statement(zone, pos) {} | 920 explicit JumpStatement(Zone* zone, int pos) : Statement(zone, pos) {} |
| 952 }; | 921 }; |
| 953 | 922 |
| 954 | 923 |
| 955 class ContinueStatement final : public JumpStatement { | 924 class ContinueStatement final : public JumpStatement { |
| 956 public: | 925 public: |
| 957 DECLARE_NODE_TYPE(ContinueStatement) | 926 DECLARE_NODE_TYPE(ContinueStatement) |
| 958 | 927 |
| 959 IterationStatement* target() const { return target_; } | 928 IterationStatement* target() const { return target_; } |
| 960 | 929 |
| 961 protected: | 930 protected: |
| 962 explicit ContinueStatement(Zone* zone, IterationStatement* target, int pos) | 931 explicit ContinueStatement(Zone* zone, IterationStatement* target, int pos) |
| 963 : JumpStatement(zone, pos), target_(target) { } | 932 : JumpStatement(zone, pos), target_(target) {} |
| 964 | 933 |
| 965 private: | 934 private: |
| 966 IterationStatement* target_; | 935 IterationStatement* target_; |
| 967 }; | 936 }; |
| 968 | 937 |
| 969 | 938 |
| 970 class BreakStatement final : public JumpStatement { | 939 class BreakStatement final : public JumpStatement { |
| 971 public: | 940 public: |
| 972 DECLARE_NODE_TYPE(BreakStatement) | 941 DECLARE_NODE_TYPE(BreakStatement) |
| 973 | 942 |
| 974 BreakableStatement* target() const { return target_; } | 943 BreakableStatement* target() const { return target_; } |
| 975 | 944 |
| 976 protected: | 945 protected: |
| 977 explicit BreakStatement(Zone* zone, BreakableStatement* target, int pos) | 946 explicit BreakStatement(Zone* zone, BreakableStatement* target, int pos) |
| 978 : JumpStatement(zone, pos), target_(target) { } | 947 : JumpStatement(zone, pos), target_(target) {} |
| 979 | 948 |
| 980 private: | 949 private: |
| 981 BreakableStatement* target_; | 950 BreakableStatement* target_; |
| 982 }; | 951 }; |
| 983 | 952 |
| 984 | 953 |
| 985 class ReturnStatement final : public JumpStatement { | 954 class ReturnStatement final : public JumpStatement { |
| 986 public: | 955 public: |
| 987 DECLARE_NODE_TYPE(ReturnStatement) | 956 DECLARE_NODE_TYPE(ReturnStatement) |
| 988 | 957 |
| 989 Expression* expression() const { return expression_; } | 958 Expression* expression() const { return expression_; } |
| 990 | 959 |
| 991 protected: | 960 protected: |
| 992 explicit ReturnStatement(Zone* zone, Expression* expression, int pos) | 961 explicit ReturnStatement(Zone* zone, Expression* expression, int pos) |
| 993 : JumpStatement(zone, pos), expression_(expression) { } | 962 : JumpStatement(zone, pos), expression_(expression) {} |
| 994 | 963 |
| 995 private: | 964 private: |
| 996 Expression* expression_; | 965 Expression* expression_; |
| 997 }; | 966 }; |
| 998 | 967 |
| 999 | 968 |
| 1000 class WithStatement final : public Statement { | 969 class WithStatement final : public Statement { |
| 1001 public: | 970 public: |
| 1002 DECLARE_NODE_TYPE(WithStatement) | 971 DECLARE_NODE_TYPE(WithStatement) |
| 1003 | 972 |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1107 bool HasElseStatement() const { return !else_statement()->IsEmpty(); } | 1076 bool HasElseStatement() const { return !else_statement()->IsEmpty(); } |
| 1108 | 1077 |
| 1109 Expression* condition() const { return condition_; } | 1078 Expression* condition() const { return condition_; } |
| 1110 Statement* then_statement() const { return then_statement_; } | 1079 Statement* then_statement() const { return then_statement_; } |
| 1111 Statement* else_statement() const { return else_statement_; } | 1080 Statement* else_statement() const { return else_statement_; } |
| 1112 | 1081 |
| 1113 void set_then_statement(Statement* s) { then_statement_ = s; } | 1082 void set_then_statement(Statement* s) { then_statement_ = s; } |
| 1114 void set_else_statement(Statement* s) { else_statement_ = s; } | 1083 void set_else_statement(Statement* s) { else_statement_ = s; } |
| 1115 | 1084 |
| 1116 bool IsJump() const override { | 1085 bool IsJump() const override { |
| 1117 return HasThenStatement() && then_statement()->IsJump() | 1086 return HasThenStatement() && then_statement()->IsJump() && |
| 1118 && HasElseStatement() && else_statement()->IsJump(); | 1087 HasElseStatement() && else_statement()->IsJump(); |
| 1119 } | 1088 } |
| 1120 | 1089 |
| 1121 void set_base_id(int id) { base_id_ = id; } | 1090 void set_base_id(int id) { base_id_ = id; } |
| 1122 static int num_ids() { return parent_num_ids() + 3; } | 1091 static int num_ids() { return parent_num_ids() + 3; } |
| 1123 BailoutId IfId() const { return BailoutId(local_id(0)); } | 1092 BailoutId IfId() const { return BailoutId(local_id(0)); } |
| 1124 BailoutId ThenId() const { return BailoutId(local_id(1)); } | 1093 BailoutId ThenId() const { return BailoutId(local_id(1)); } |
| 1125 BailoutId ElseId() const { return BailoutId(local_id(2)); } | 1094 BailoutId ElseId() const { return BailoutId(local_id(2)); } |
| 1126 | 1095 |
| 1127 protected: | 1096 protected: |
| 1128 IfStatement(Zone* zone, Expression* condition, Statement* then_statement, | 1097 IfStatement(Zone* zone, Expression* condition, Statement* then_statement, |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1242 | 1211 |
| 1243 int base_id_; | 1212 int base_id_; |
| 1244 }; | 1213 }; |
| 1245 | 1214 |
| 1246 | 1215 |
| 1247 class EmptyStatement final : public Statement { | 1216 class EmptyStatement final : public Statement { |
| 1248 public: | 1217 public: |
| 1249 DECLARE_NODE_TYPE(EmptyStatement) | 1218 DECLARE_NODE_TYPE(EmptyStatement) |
| 1250 | 1219 |
| 1251 protected: | 1220 protected: |
| 1252 explicit EmptyStatement(Zone* zone, int pos): Statement(zone, pos) {} | 1221 explicit EmptyStatement(Zone* zone, int pos) : Statement(zone, pos) {} |
| 1253 }; | 1222 }; |
| 1254 | 1223 |
| 1255 | 1224 |
| 1256 // Delegates to another statement, which may be overwritten. | 1225 // Delegates to another statement, which may be overwritten. |
| 1257 // This was introduced to implement ES2015 Annex B3.3 for conditionally making | 1226 // This was introduced to implement ES2015 Annex B3.3 for conditionally making |
| 1258 // sloppy-mode block-scoped functions have a var binding, which is changed | 1227 // sloppy-mode block-scoped functions have a var binding, which is changed |
| 1259 // from one statement to another during parsing. | 1228 // from one statement to another during parsing. |
| 1260 class SloppyBlockFunctionStatement final : public Statement { | 1229 class SloppyBlockFunctionStatement final : public Statement { |
| 1261 public: | 1230 public: |
| 1262 DECLARE_NODE_TYPE(SloppyBlockFunctionStatement) | 1231 DECLARE_NODE_TYPE(SloppyBlockFunctionStatement) |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1380 | 1349 |
| 1381 // Property is used for passing information | 1350 // Property is used for passing information |
| 1382 // about an object literal's properties from the parser | 1351 // about an object literal's properties from the parser |
| 1383 // to the code generator. | 1352 // to the code generator. |
| 1384 class ObjectLiteralProperty final : public ZoneObject { | 1353 class ObjectLiteralProperty final : public ZoneObject { |
| 1385 public: | 1354 public: |
| 1386 enum Kind { | 1355 enum Kind { |
| 1387 CONSTANT, // Property with constant value (compile time). | 1356 CONSTANT, // Property with constant value (compile time). |
| 1388 COMPUTED, // Property with computed value (execution time). | 1357 COMPUTED, // Property with computed value (execution time). |
| 1389 MATERIALIZED_LITERAL, // Property value is a materialized literal. | 1358 MATERIALIZED_LITERAL, // Property value is a materialized literal. |
| 1390 GETTER, SETTER, // Property is an accessor function. | 1359 GETTER, |
| 1391 PROTOTYPE // Property is __proto__. | 1360 SETTER, // Property is an accessor function. |
| 1361 PROTOTYPE // Property is __proto__. |
| 1392 }; | 1362 }; |
| 1393 | 1363 |
| 1394 Expression* key() { return key_; } | 1364 Expression* key() { return key_; } |
| 1395 Expression* value() { return value_; } | 1365 Expression* value() { return value_; } |
| 1396 Kind kind() { return kind_; } | 1366 Kind kind() { return kind_; } |
| 1397 | 1367 |
| 1398 // Type feedback information. | 1368 // Type feedback information. |
| 1399 bool IsMonomorphic() { return !receiver_type_.is_null(); } | 1369 bool IsMonomorphic() { return !receiver_type_.is_null(); } |
| 1400 Handle<Map> GetReceiverType() { return receiver_type_; } | 1370 Handle<Map> GetReceiverType() { return receiver_type_; } |
| 1401 | 1371 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1486 | 1456 |
| 1487 enum Flags { | 1457 enum Flags { |
| 1488 kNoFlags = 0, | 1458 kNoFlags = 0, |
| 1489 kFastElements = 1, | 1459 kFastElements = 1, |
| 1490 kHasFunction = 1 << 1, | 1460 kHasFunction = 1 << 1, |
| 1491 kShallowProperties = 1 << 2, | 1461 kShallowProperties = 1 << 2, |
| 1492 kDisableMementos = 1 << 3, | 1462 kDisableMementos = 1 << 3, |
| 1493 kIsStrong = 1 << 4 | 1463 kIsStrong = 1 << 4 |
| 1494 }; | 1464 }; |
| 1495 | 1465 |
| 1496 struct Accessors: public ZoneObject { | 1466 struct Accessors : public ZoneObject { |
| 1497 Accessors() : getter(NULL), setter(NULL) {} | 1467 Accessors() : getter(NULL), setter(NULL) {} |
| 1498 ObjectLiteralProperty* getter; | 1468 ObjectLiteralProperty* getter; |
| 1499 ObjectLiteralProperty* setter; | 1469 ObjectLiteralProperty* setter; |
| 1500 }; | 1470 }; |
| 1501 | 1471 |
| 1502 BailoutId CreateLiteralId() const { return BailoutId(local_id(0)); } | 1472 BailoutId CreateLiteralId() const { return BailoutId(local_id(0)); } |
| 1503 | 1473 |
| 1504 // Return an AST id for a property that is used in simulate instructions. | 1474 // Return an AST id for a property that is used in simulate instructions. |
| 1505 BailoutId GetIdForProperty(int i) { return BailoutId(local_id(i + 1)); } | 1475 BailoutId GetIdForProperty(int i) { return BailoutId(local_id(i + 1)); } |
| 1506 | 1476 |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1971 callnew_feedback_slot_ = spec->AddGeneralSlot(); | 1941 callnew_feedback_slot_ = spec->AddGeneralSlot(); |
| 1972 } | 1942 } |
| 1973 | 1943 |
| 1974 FeedbackVectorSlot CallNewFeedbackSlot() { | 1944 FeedbackVectorSlot CallNewFeedbackSlot() { |
| 1975 DCHECK(!callnew_feedback_slot_.IsInvalid()); | 1945 DCHECK(!callnew_feedback_slot_.IsInvalid()); |
| 1976 return callnew_feedback_slot_; | 1946 return callnew_feedback_slot_; |
| 1977 } | 1947 } |
| 1978 | 1948 |
| 1979 bool IsMonomorphic() override { return is_monomorphic_; } | 1949 bool IsMonomorphic() override { return is_monomorphic_; } |
| 1980 Handle<JSFunction> target() const { return target_; } | 1950 Handle<JSFunction> target() const { return target_; } |
| 1981 Handle<AllocationSite> allocation_site() const { | 1951 Handle<AllocationSite> allocation_site() const { return allocation_site_; } |
| 1982 return allocation_site_; | |
| 1983 } | |
| 1984 | 1952 |
| 1985 static int num_ids() { return parent_num_ids() + 1; } | 1953 static int num_ids() { return parent_num_ids() + 1; } |
| 1986 static int feedback_slots() { return 1; } | 1954 static int feedback_slots() { return 1; } |
| 1987 BailoutId ReturnId() const { return BailoutId(local_id(0)); } | 1955 BailoutId ReturnId() const { return BailoutId(local_id(0)); } |
| 1988 | 1956 |
| 1989 void set_allocation_site(Handle<AllocationSite> site) { | 1957 void set_allocation_site(Handle<AllocationSite> site) { |
| 1990 allocation_site_ = site; | 1958 allocation_site_ = site; |
| 1991 } | 1959 } |
| 1992 void set_is_monomorphic(bool monomorphic) { is_monomorphic_ = monomorphic; } | 1960 void set_is_monomorphic(bool monomorphic) { is_monomorphic_ = monomorphic; } |
| 1993 void set_target(Handle<JSFunction> target) { target_ = target; } | 1961 void set_target(Handle<JSFunction> target) { target_ = target; } |
| (...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2459 Throw(Zone* zone, Expression* exception, int pos) | 2427 Throw(Zone* zone, Expression* exception, int pos) |
| 2460 : Expression(zone, pos), exception_(exception) {} | 2428 : Expression(zone, pos), exception_(exception) {} |
| 2461 | 2429 |
| 2462 private: | 2430 private: |
| 2463 Expression* exception_; | 2431 Expression* exception_; |
| 2464 }; | 2432 }; |
| 2465 | 2433 |
| 2466 | 2434 |
| 2467 class FunctionLiteral final : public Expression { | 2435 class FunctionLiteral final : public Expression { |
| 2468 public: | 2436 public: |
| 2469 enum FunctionType { | 2437 enum FunctionType { ANONYMOUS_EXPRESSION, NAMED_EXPRESSION, DECLARATION }; |
| 2470 ANONYMOUS_EXPRESSION, | |
| 2471 NAMED_EXPRESSION, | |
| 2472 DECLARATION | |
| 2473 }; | |
| 2474 | 2438 |
| 2475 enum ParameterFlag { | 2439 enum ParameterFlag { |
| 2476 kNoDuplicateParameters = 0, | 2440 kNoDuplicateParameters = 0, |
| 2477 kHasDuplicateParameters = 1 | 2441 kHasDuplicateParameters = 1 |
| 2478 }; | 2442 }; |
| 2479 | 2443 |
| 2480 enum IsFunctionFlag { | 2444 enum IsFunctionFlag { kGlobalOrEval, kIsFunction }; |
| 2481 kGlobalOrEval, | |
| 2482 kIsFunction | |
| 2483 }; | |
| 2484 | 2445 |
| 2485 enum EagerCompileHint { kShouldEagerCompile, kShouldLazyCompile }; | 2446 enum EagerCompileHint { kShouldEagerCompile, kShouldLazyCompile }; |
| 2486 | 2447 |
| 2487 enum ShouldBeUsedOnceHint { kShouldBeUsedOnce, kDontKnowIfShouldBeUsedOnce }; | 2448 enum ShouldBeUsedOnceHint { kShouldBeUsedOnce, kDontKnowIfShouldBeUsedOnce }; |
| 2488 | 2449 |
| 2489 enum ArityRestriction { | 2450 enum ArityRestriction { NORMAL_ARITY, GETTER_ARITY, SETTER_ARITY }; |
| 2490 NORMAL_ARITY, | |
| 2491 GETTER_ARITY, | |
| 2492 SETTER_ARITY | |
| 2493 }; | |
| 2494 | 2451 |
| 2495 DECLARE_NODE_TYPE(FunctionLiteral) | 2452 DECLARE_NODE_TYPE(FunctionLiteral) |
| 2496 | 2453 |
| 2497 Handle<String> name() const { return raw_name_->string(); } | 2454 Handle<String> name() const { return raw_name_->string(); } |
| 2498 const AstRawString* raw_name() const { return raw_name_; } | 2455 const AstRawString* raw_name() const { return raw_name_; } |
| 2499 Scope* scope() const { return scope_; } | 2456 Scope* scope() const { return scope_; } |
| 2500 ZoneList<Statement*>* body() const { return body_; } | 2457 ZoneList<Statement*>* body() const { return body_; } |
| 2501 void set_function_token_position(int pos) { function_token_position_ = pos; } | 2458 void set_function_token_position(int pos) { function_token_position_ = pos; } |
| 2502 int function_token_position() const { return function_token_position_; } | 2459 int function_token_position() const { return function_token_position_; } |
| 2503 int start_position() const; | 2460 int start_position() const; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 2532 return raw_inferred_name_->string(); | 2489 return raw_inferred_name_->string(); |
| 2533 } | 2490 } |
| 2534 UNREACHABLE(); | 2491 UNREACHABLE(); |
| 2535 return Handle<String>(); | 2492 return Handle<String>(); |
| 2536 } | 2493 } |
| 2537 | 2494 |
| 2538 // Only one of {set_inferred_name, set_raw_inferred_name} should be called. | 2495 // Only one of {set_inferred_name, set_raw_inferred_name} should be called. |
| 2539 void set_inferred_name(Handle<String> inferred_name) { | 2496 void set_inferred_name(Handle<String> inferred_name) { |
| 2540 DCHECK(!inferred_name.is_null()); | 2497 DCHECK(!inferred_name.is_null()); |
| 2541 inferred_name_ = inferred_name; | 2498 inferred_name_ = inferred_name; |
| 2542 DCHECK(raw_inferred_name_== NULL || raw_inferred_name_->IsEmpty()); | 2499 DCHECK(raw_inferred_name_ == NULL || raw_inferred_name_->IsEmpty()); |
| 2543 raw_inferred_name_ = NULL; | 2500 raw_inferred_name_ = NULL; |
| 2544 } | 2501 } |
| 2545 | 2502 |
| 2546 void set_raw_inferred_name(const AstString* raw_inferred_name) { | 2503 void set_raw_inferred_name(const AstString* raw_inferred_name) { |
| 2547 DCHECK(raw_inferred_name != NULL); | 2504 DCHECK(raw_inferred_name != NULL); |
| 2548 raw_inferred_name_ = raw_inferred_name; | 2505 raw_inferred_name_ = raw_inferred_name; |
| 2549 DCHECK(inferred_name_.is_null()); | 2506 DCHECK(inferred_name_.is_null()); |
| 2550 inferred_name_ = Handle<String>(); | 2507 inferred_name_ = Handle<String>(); |
| 2551 } | 2508 } |
| 2552 | 2509 |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2815 | 2772 |
| 2816 #undef DECLARE_NODE_TYPE | 2773 #undef DECLARE_NODE_TYPE |
| 2817 | 2774 |
| 2818 | 2775 |
| 2819 // ---------------------------------------------------------------------------- | 2776 // ---------------------------------------------------------------------------- |
| 2820 // Regular expressions | 2777 // Regular expressions |
| 2821 | 2778 |
| 2822 | 2779 |
| 2823 class RegExpVisitor BASE_EMBEDDED { | 2780 class RegExpVisitor BASE_EMBEDDED { |
| 2824 public: | 2781 public: |
| 2825 virtual ~RegExpVisitor() { } | 2782 virtual ~RegExpVisitor() {} |
| 2826 #define MAKE_CASE(Name) \ | 2783 #define MAKE_CASE(Name) \ |
| 2827 virtual void* Visit##Name(RegExp##Name*, void* data) = 0; | 2784 virtual void* Visit##Name(RegExp##Name*, void* data) = 0; |
| 2828 FOR_EACH_REG_EXP_TREE_TYPE(MAKE_CASE) | 2785 FOR_EACH_REG_EXP_TREE_TYPE(MAKE_CASE) |
| 2829 #undef MAKE_CASE | 2786 #undef MAKE_CASE |
| 2830 }; | 2787 }; |
| 2831 | 2788 |
| 2832 | 2789 |
| 2833 class RegExpTree : public ZoneObject { | 2790 class RegExpTree : public ZoneObject { |
| 2834 public: | 2791 public: |
| 2835 static const int kInfinity = kMaxInt; | 2792 static const int kInfinity = kMaxInt; |
| 2836 virtual ~RegExpTree() {} | 2793 virtual ~RegExpTree() {} |
| 2837 virtual void* Accept(RegExpVisitor* visitor, void* data) = 0; | 2794 virtual void* Accept(RegExpVisitor* visitor, void* data) = 0; |
| 2838 virtual RegExpNode* ToNode(RegExpCompiler* compiler, | 2795 virtual RegExpNode* ToNode(RegExpCompiler* compiler, |
| 2839 RegExpNode* on_success) = 0; | 2796 RegExpNode* on_success) = 0; |
| 2840 virtual bool IsTextElement() { return false; } | 2797 virtual bool IsTextElement() { return false; } |
| 2841 virtual bool IsAnchoredAtStart() { return false; } | 2798 virtual bool IsAnchoredAtStart() { return false; } |
| 2842 virtual bool IsAnchoredAtEnd() { return false; } | 2799 virtual bool IsAnchoredAtEnd() { return false; } |
| 2843 virtual int min_match() = 0; | 2800 virtual int min_match() = 0; |
| 2844 virtual int max_match() = 0; | 2801 virtual int max_match() = 0; |
| 2845 // Returns the interval of registers used for captures within this | 2802 // Returns the interval of registers used for captures within this |
| 2846 // expression. | 2803 // expression. |
| 2847 virtual Interval CaptureRegisters() { return Interval::Empty(); } | 2804 virtual Interval CaptureRegisters() { return Interval::Empty(); } |
| 2848 virtual void AppendToText(RegExpText* text, Zone* zone); | 2805 virtual void AppendToText(RegExpText* text, Zone* zone); |
| 2849 std::ostream& Print(std::ostream& os, Zone* zone); // NOLINT | 2806 std::ostream& Print(std::ostream& os, Zone* zone); // NOLINT |
| 2850 #define MAKE_ASTYPE(Name) \ | 2807 #define MAKE_ASTYPE(Name) \ |
| 2851 virtual RegExp##Name* As##Name(); \ | 2808 virtual RegExp##Name* As##Name(); \ |
| 2852 virtual bool Is##Name(); | 2809 virtual bool Is##Name(); |
| 2853 FOR_EACH_REG_EXP_TREE_TYPE(MAKE_ASTYPE) | 2810 FOR_EACH_REG_EXP_TREE_TYPE(MAKE_ASTYPE) |
| 2854 #undef MAKE_ASTYPE | 2811 #undef MAKE_ASTYPE |
| 2855 }; | 2812 }; |
| 2856 | 2813 |
| 2857 | 2814 |
| 2858 class RegExpDisjunction final : public RegExpTree { | 2815 class RegExpDisjunction final : public RegExpTree { |
| 2859 public: | 2816 public: |
| 2860 explicit RegExpDisjunction(ZoneList<RegExpTree*>* alternatives); | 2817 explicit RegExpDisjunction(ZoneList<RegExpTree*>* alternatives); |
| 2861 void* Accept(RegExpVisitor* visitor, void* data) override; | 2818 void* Accept(RegExpVisitor* visitor, void* data) override; |
| 2862 RegExpNode* ToNode(RegExpCompiler* compiler, RegExpNode* on_success) override; | 2819 RegExpNode* ToNode(RegExpCompiler* compiler, RegExpNode* on_success) override; |
| 2863 RegExpDisjunction* AsDisjunction() override; | 2820 RegExpDisjunction* AsDisjunction() override; |
| 2864 Interval CaptureRegisters() override; | 2821 Interval CaptureRegisters() override; |
| 2865 bool IsDisjunction() override; | 2822 bool IsDisjunction() override; |
| 2866 bool IsAnchoredAtStart() override; | 2823 bool IsAnchoredAtStart() override; |
| 2867 bool IsAnchoredAtEnd() override; | 2824 bool IsAnchoredAtEnd() override; |
| 2868 int min_match() override { return min_match_; } | 2825 int min_match() override { return min_match_; } |
| 2869 int max_match() override { return max_match_; } | 2826 int max_match() override { return max_match_; } |
| 2870 ZoneList<RegExpTree*>* alternatives() { return alternatives_; } | 2827 ZoneList<RegExpTree*>* alternatives() { return alternatives_; } |
| 2828 |
| 2871 private: | 2829 private: |
| 2872 bool SortConsecutiveAtoms(RegExpCompiler* compiler); | 2830 bool SortConsecutiveAtoms(RegExpCompiler* compiler); |
| 2873 void RationalizeConsecutiveAtoms(RegExpCompiler* compiler); | 2831 void RationalizeConsecutiveAtoms(RegExpCompiler* compiler); |
| 2874 void FixSingleCharacterDisjunctions(RegExpCompiler* compiler); | 2832 void FixSingleCharacterDisjunctions(RegExpCompiler* compiler); |
| 2875 ZoneList<RegExpTree*>* alternatives_; | 2833 ZoneList<RegExpTree*>* alternatives_; |
| 2876 int min_match_; | 2834 int min_match_; |
| 2877 int max_match_; | 2835 int max_match_; |
| 2878 }; | 2836 }; |
| 2879 | 2837 |
| 2880 | 2838 |
| 2881 class RegExpAlternative final : public RegExpTree { | 2839 class RegExpAlternative final : public RegExpTree { |
| 2882 public: | 2840 public: |
| 2883 explicit RegExpAlternative(ZoneList<RegExpTree*>* nodes); | 2841 explicit RegExpAlternative(ZoneList<RegExpTree*>* nodes); |
| 2884 void* Accept(RegExpVisitor* visitor, void* data) override; | 2842 void* Accept(RegExpVisitor* visitor, void* data) override; |
| 2885 RegExpNode* ToNode(RegExpCompiler* compiler, RegExpNode* on_success) override; | 2843 RegExpNode* ToNode(RegExpCompiler* compiler, RegExpNode* on_success) override; |
| 2886 RegExpAlternative* AsAlternative() override; | 2844 RegExpAlternative* AsAlternative() override; |
| 2887 Interval CaptureRegisters() override; | 2845 Interval CaptureRegisters() override; |
| 2888 bool IsAlternative() override; | 2846 bool IsAlternative() override; |
| 2889 bool IsAnchoredAtStart() override; | 2847 bool IsAnchoredAtStart() override; |
| 2890 bool IsAnchoredAtEnd() override; | 2848 bool IsAnchoredAtEnd() override; |
| 2891 int min_match() override { return min_match_; } | 2849 int min_match() override { return min_match_; } |
| 2892 int max_match() override { return max_match_; } | 2850 int max_match() override { return max_match_; } |
| 2893 ZoneList<RegExpTree*>* nodes() { return nodes_; } | 2851 ZoneList<RegExpTree*>* nodes() { return nodes_; } |
| 2852 |
| 2894 private: | 2853 private: |
| 2895 ZoneList<RegExpTree*>* nodes_; | 2854 ZoneList<RegExpTree*>* nodes_; |
| 2896 int min_match_; | 2855 int min_match_; |
| 2897 int max_match_; | 2856 int max_match_; |
| 2898 }; | 2857 }; |
| 2899 | 2858 |
| 2900 | 2859 |
| 2901 class RegExpAssertion final : public RegExpTree { | 2860 class RegExpAssertion final : public RegExpTree { |
| 2902 public: | 2861 public: |
| 2903 enum AssertionType { | 2862 enum AssertionType { |
| 2904 START_OF_LINE, | 2863 START_OF_LINE, |
| 2905 START_OF_INPUT, | 2864 START_OF_INPUT, |
| 2906 END_OF_LINE, | 2865 END_OF_LINE, |
| 2907 END_OF_INPUT, | 2866 END_OF_INPUT, |
| 2908 BOUNDARY, | 2867 BOUNDARY, |
| 2909 NON_BOUNDARY | 2868 NON_BOUNDARY |
| 2910 }; | 2869 }; |
| 2911 explicit RegExpAssertion(AssertionType type) : assertion_type_(type) { } | 2870 explicit RegExpAssertion(AssertionType type) : assertion_type_(type) {} |
| 2912 void* Accept(RegExpVisitor* visitor, void* data) override; | 2871 void* Accept(RegExpVisitor* visitor, void* data) override; |
| 2913 RegExpNode* ToNode(RegExpCompiler* compiler, RegExpNode* on_success) override; | 2872 RegExpNode* ToNode(RegExpCompiler* compiler, RegExpNode* on_success) override; |
| 2914 RegExpAssertion* AsAssertion() override; | 2873 RegExpAssertion* AsAssertion() override; |
| 2915 bool IsAssertion() override; | 2874 bool IsAssertion() override; |
| 2916 bool IsAnchoredAtStart() override; | 2875 bool IsAnchoredAtStart() override; |
| 2917 bool IsAnchoredAtEnd() override; | 2876 bool IsAnchoredAtEnd() override; |
| 2918 int min_match() override { return 0; } | 2877 int min_match() override { return 0; } |
| 2919 int max_match() override { return 0; } | 2878 int max_match() override { return 0; } |
| 2920 AssertionType assertion_type() { return assertion_type_; } | 2879 AssertionType assertion_type() { return assertion_type_; } |
| 2880 |
| 2921 private: | 2881 private: |
| 2922 AssertionType assertion_type_; | 2882 AssertionType assertion_type_; |
| 2923 }; | 2883 }; |
| 2924 | 2884 |
| 2925 | 2885 |
| 2926 class CharacterSet final BASE_EMBEDDED { | 2886 class CharacterSet final BASE_EMBEDDED { |
| 2927 public: | 2887 public: |
| 2928 explicit CharacterSet(uc16 standard_set_type) | 2888 explicit CharacterSet(uc16 standard_set_type) |
| 2929 : ranges_(NULL), | 2889 : ranges_(NULL), standard_set_type_(standard_set_type) {} |
| 2930 standard_set_type_(standard_set_type) {} | |
| 2931 explicit CharacterSet(ZoneList<CharacterRange>* ranges) | 2890 explicit CharacterSet(ZoneList<CharacterRange>* ranges) |
| 2932 : ranges_(ranges), | 2891 : ranges_(ranges), standard_set_type_(0) {} |
| 2933 standard_set_type_(0) {} | |
| 2934 ZoneList<CharacterRange>* ranges(Zone* zone); | 2892 ZoneList<CharacterRange>* ranges(Zone* zone); |
| 2935 uc16 standard_set_type() { return standard_set_type_; } | 2893 uc16 standard_set_type() { return standard_set_type_; } |
| 2936 void set_standard_set_type(uc16 special_set_type) { | 2894 void set_standard_set_type(uc16 special_set_type) { |
| 2937 standard_set_type_ = special_set_type; | 2895 standard_set_type_ = special_set_type; |
| 2938 } | 2896 } |
| 2939 bool is_standard() { return standard_set_type_ != 0; } | 2897 bool is_standard() { return standard_set_type_ != 0; } |
| 2940 void Canonicalize(); | 2898 void Canonicalize(); |
| 2899 |
| 2941 private: | 2900 private: |
| 2942 ZoneList<CharacterRange>* ranges_; | 2901 ZoneList<CharacterRange>* ranges_; |
| 2943 // If non-zero, the value represents a standard set (e.g., all whitespace | 2902 // If non-zero, the value represents a standard set (e.g., all whitespace |
| 2944 // characters) without having to expand the ranges. | 2903 // characters) without having to expand the ranges. |
| 2945 uc16 standard_set_type_; | 2904 uc16 standard_set_type_; |
| 2946 }; | 2905 }; |
| 2947 | 2906 |
| 2948 | 2907 |
| 2949 class RegExpCharacterClass final : public RegExpTree { | 2908 class RegExpCharacterClass final : public RegExpTree { |
| 2950 public: | 2909 public: |
| 2951 RegExpCharacterClass(ZoneList<CharacterRange>* ranges, bool is_negated) | 2910 RegExpCharacterClass(ZoneList<CharacterRange>* ranges, bool is_negated) |
| 2952 : set_(ranges), | 2911 : set_(ranges), is_negated_(is_negated) {} |
| 2953 is_negated_(is_negated) { } | 2912 explicit RegExpCharacterClass(uc16 type) : set_(type), is_negated_(false) {} |
| 2954 explicit RegExpCharacterClass(uc16 type) | |
| 2955 : set_(type), | |
| 2956 is_negated_(false) { } | |
| 2957 void* Accept(RegExpVisitor* visitor, void* data) override; | 2913 void* Accept(RegExpVisitor* visitor, void* data) override; |
| 2958 RegExpNode* ToNode(RegExpCompiler* compiler, RegExpNode* on_success) override; | 2914 RegExpNode* ToNode(RegExpCompiler* compiler, RegExpNode* on_success) override; |
| 2959 RegExpCharacterClass* AsCharacterClass() override; | 2915 RegExpCharacterClass* AsCharacterClass() override; |
| 2960 bool IsCharacterClass() override; | 2916 bool IsCharacterClass() override; |
| 2961 bool IsTextElement() override { return true; } | 2917 bool IsTextElement() override { return true; } |
| 2962 int min_match() override { return 1; } | 2918 int min_match() override { return 1; } |
| 2963 int max_match() override { return 1; } | 2919 int max_match() override { return 1; } |
| 2964 void AppendToText(RegExpText* text, Zone* zone) override; | 2920 void AppendToText(RegExpText* text, Zone* zone) override; |
| 2965 CharacterSet character_set() { return set_; } | 2921 CharacterSet character_set() { return set_; } |
| 2966 // TODO(lrn): Remove need for complex version if is_standard that | 2922 // TODO(lrn): Remove need for complex version if is_standard that |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2982 bool is_negated() { return is_negated_; } | 2938 bool is_negated() { return is_negated_; } |
| 2983 | 2939 |
| 2984 private: | 2940 private: |
| 2985 CharacterSet set_; | 2941 CharacterSet set_; |
| 2986 bool is_negated_; | 2942 bool is_negated_; |
| 2987 }; | 2943 }; |
| 2988 | 2944 |
| 2989 | 2945 |
| 2990 class RegExpAtom final : public RegExpTree { | 2946 class RegExpAtom final : public RegExpTree { |
| 2991 public: | 2947 public: |
| 2992 explicit RegExpAtom(Vector<const uc16> data) : data_(data) { } | 2948 explicit RegExpAtom(Vector<const uc16> data) : data_(data) {} |
| 2993 void* Accept(RegExpVisitor* visitor, void* data) override; | 2949 void* Accept(RegExpVisitor* visitor, void* data) override; |
| 2994 RegExpNode* ToNode(RegExpCompiler* compiler, RegExpNode* on_success) override; | 2950 RegExpNode* ToNode(RegExpCompiler* compiler, RegExpNode* on_success) override; |
| 2995 RegExpAtom* AsAtom() override; | 2951 RegExpAtom* AsAtom() override; |
| 2996 bool IsAtom() override; | 2952 bool IsAtom() override; |
| 2997 bool IsTextElement() override { return true; } | 2953 bool IsTextElement() override { return true; } |
| 2998 int min_match() override { return data_.length(); } | 2954 int min_match() override { return data_.length(); } |
| 2999 int max_match() override { return data_.length(); } | 2955 int max_match() override { return data_.length(); } |
| 3000 void AppendToText(RegExpText* text, Zone* zone) override; | 2956 void AppendToText(RegExpText* text, Zone* zone) override; |
| 3001 Vector<const uc16> data() { return data_; } | 2957 Vector<const uc16> data() { return data_; } |
| 3002 int length() { return data_.length(); } | 2958 int length() { return data_.length(); } |
| 2959 |
| 3003 private: | 2960 private: |
| 3004 Vector<const uc16> data_; | 2961 Vector<const uc16> data_; |
| 3005 }; | 2962 }; |
| 3006 | 2963 |
| 3007 | 2964 |
| 3008 class RegExpText final : public RegExpTree { | 2965 class RegExpText final : public RegExpTree { |
| 3009 public: | 2966 public: |
| 3010 explicit RegExpText(Zone* zone) : elements_(2, zone), length_(0) {} | 2967 explicit RegExpText(Zone* zone) : elements_(2, zone), length_(0) {} |
| 3011 void* Accept(RegExpVisitor* visitor, void* data) override; | 2968 void* Accept(RegExpVisitor* visitor, void* data) override; |
| 3012 RegExpNode* ToNode(RegExpCompiler* compiler, RegExpNode* on_success) override; | 2969 RegExpNode* ToNode(RegExpCompiler* compiler, RegExpNode* on_success) override; |
| 3013 RegExpText* AsText() override; | 2970 RegExpText* AsText() override; |
| 3014 bool IsText() override; | 2971 bool IsText() override; |
| 3015 bool IsTextElement() override { return true; } | 2972 bool IsTextElement() override { return true; } |
| 3016 int min_match() override { return length_; } | 2973 int min_match() override { return length_; } |
| 3017 int max_match() override { return length_; } | 2974 int max_match() override { return length_; } |
| 3018 void AppendToText(RegExpText* text, Zone* zone) override; | 2975 void AppendToText(RegExpText* text, Zone* zone) override; |
| 3019 void AddElement(TextElement elm, Zone* zone) { | 2976 void AddElement(TextElement elm, Zone* zone) { |
| 3020 elements_.Add(elm, zone); | 2977 elements_.Add(elm, zone); |
| 3021 length_ += elm.length(); | 2978 length_ += elm.length(); |
| 3022 } | 2979 } |
| 3023 ZoneList<TextElement>* elements() { return &elements_; } | 2980 ZoneList<TextElement>* elements() { return &elements_; } |
| 2981 |
| 3024 private: | 2982 private: |
| 3025 ZoneList<TextElement> elements_; | 2983 ZoneList<TextElement> elements_; |
| 3026 int length_; | 2984 int length_; |
| 3027 }; | 2985 }; |
| 3028 | 2986 |
| 3029 | 2987 |
| 3030 class RegExpQuantifier final : public RegExpTree { | 2988 class RegExpQuantifier final : public RegExpTree { |
| 3031 public: | 2989 public: |
| 3032 enum QuantifierType { GREEDY, NON_GREEDY, POSSESSIVE }; | 2990 enum QuantifierType { GREEDY, NON_GREEDY, POSSESSIVE }; |
| 3033 RegExpQuantifier(int min, int max, QuantifierType type, RegExpTree* body) | 2991 RegExpQuantifier(int min, int max, QuantifierType type, RegExpTree* body) |
| 3034 : body_(body), | 2992 : body_(body), |
| 3035 min_(min), | 2993 min_(min), |
| 3036 max_(max), | 2994 max_(max), |
| 3037 min_match_(min * body->min_match()), | 2995 min_match_(min * body->min_match()), |
| 3038 quantifier_type_(type) { | 2996 quantifier_type_(type) { |
| 3039 if (max > 0 && body->max_match() > kInfinity / max) { | 2997 if (max > 0 && body->max_match() > kInfinity / max) { |
| 3040 max_match_ = kInfinity; | 2998 max_match_ = kInfinity; |
| 3041 } else { | 2999 } else { |
| 3042 max_match_ = max * body->max_match(); | 3000 max_match_ = max * body->max_match(); |
| 3043 } | 3001 } |
| 3044 } | 3002 } |
| 3045 void* Accept(RegExpVisitor* visitor, void* data) override; | 3003 void* Accept(RegExpVisitor* visitor, void* data) override; |
| 3046 RegExpNode* ToNode(RegExpCompiler* compiler, RegExpNode* on_success) override; | 3004 RegExpNode* ToNode(RegExpCompiler* compiler, RegExpNode* on_success) override; |
| 3047 static RegExpNode* ToNode(int min, | 3005 static RegExpNode* ToNode(int min, int max, bool is_greedy, RegExpTree* body, |
| 3048 int max, | 3006 RegExpCompiler* compiler, RegExpNode* on_success, |
| 3049 bool is_greedy, | |
| 3050 RegExpTree* body, | |
| 3051 RegExpCompiler* compiler, | |
| 3052 RegExpNode* on_success, | |
| 3053 bool not_at_start = false); | 3007 bool not_at_start = false); |
| 3054 RegExpQuantifier* AsQuantifier() override; | 3008 RegExpQuantifier* AsQuantifier() override; |
| 3055 Interval CaptureRegisters() override; | 3009 Interval CaptureRegisters() override; |
| 3056 bool IsQuantifier() override; | 3010 bool IsQuantifier() override; |
| 3057 int min_match() override { return min_match_; } | 3011 int min_match() override { return min_match_; } |
| 3058 int max_match() override { return max_match_; } | 3012 int max_match() override { return max_match_; } |
| 3059 int min() { return min_; } | 3013 int min() { return min_; } |
| 3060 int max() { return max_; } | 3014 int max() { return max_; } |
| 3061 bool is_possessive() { return quantifier_type_ == POSSESSIVE; } | 3015 bool is_possessive() { return quantifier_type_ == POSSESSIVE; } |
| 3062 bool is_non_greedy() { return quantifier_type_ == NON_GREEDY; } | 3016 bool is_non_greedy() { return quantifier_type_ == NON_GREEDY; } |
| 3063 bool is_greedy() { return quantifier_type_ == GREEDY; } | 3017 bool is_greedy() { return quantifier_type_ == GREEDY; } |
| 3064 RegExpTree* body() { return body_; } | 3018 RegExpTree* body() { return body_; } |
| 3065 | 3019 |
| 3066 private: | 3020 private: |
| 3067 RegExpTree* body_; | 3021 RegExpTree* body_; |
| 3068 int min_; | 3022 int min_; |
| 3069 int max_; | 3023 int max_; |
| 3070 int min_match_; | 3024 int min_match_; |
| 3071 int max_match_; | 3025 int max_match_; |
| 3072 QuantifierType quantifier_type_; | 3026 QuantifierType quantifier_type_; |
| 3073 }; | 3027 }; |
| 3074 | 3028 |
| 3075 | 3029 |
| 3076 class RegExpCapture final : public RegExpTree { | 3030 class RegExpCapture final : public RegExpTree { |
| 3077 public: | 3031 public: |
| 3078 explicit RegExpCapture(int index) : body_(NULL), index_(index) {} | 3032 explicit RegExpCapture(int index) : body_(NULL), index_(index) {} |
| 3079 void* Accept(RegExpVisitor* visitor, void* data) override; | 3033 void* Accept(RegExpVisitor* visitor, void* data) override; |
| 3080 RegExpNode* ToNode(RegExpCompiler* compiler, RegExpNode* on_success) override; | 3034 RegExpNode* ToNode(RegExpCompiler* compiler, RegExpNode* on_success) override; |
| 3081 static RegExpNode* ToNode(RegExpTree* body, | 3035 static RegExpNode* ToNode(RegExpTree* body, int index, |
| 3082 int index, | 3036 RegExpCompiler* compiler, RegExpNode* on_success); |
| 3083 RegExpCompiler* compiler, | |
| 3084 RegExpNode* on_success); | |
| 3085 RegExpCapture* AsCapture() override; | 3037 RegExpCapture* AsCapture() override; |
| 3086 bool IsAnchoredAtStart() override; | 3038 bool IsAnchoredAtStart() override; |
| 3087 bool IsAnchoredAtEnd() override; | 3039 bool IsAnchoredAtEnd() override; |
| 3088 Interval CaptureRegisters() override; | 3040 Interval CaptureRegisters() override; |
| 3089 bool IsCapture() override; | 3041 bool IsCapture() override; |
| 3090 int min_match() override { return body_->min_match(); } | 3042 int min_match() override { return body_->min_match(); } |
| 3091 int max_match() override { return body_->max_match(); } | 3043 int max_match() override { return body_->max_match(); } |
| 3092 RegExpTree* body() { return body_; } | 3044 RegExpTree* body() { return body_; } |
| 3093 void set_body(RegExpTree* body) { body_ = body; } | 3045 void set_body(RegExpTree* body) { body_ = body; } |
| 3094 int index() { return index_; } | 3046 int index() { return index_; } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3131 RegExpTree* body_; | 3083 RegExpTree* body_; |
| 3132 bool is_positive_; | 3084 bool is_positive_; |
| 3133 int capture_count_; | 3085 int capture_count_; |
| 3134 int capture_from_; | 3086 int capture_from_; |
| 3135 Type type_; | 3087 Type type_; |
| 3136 }; | 3088 }; |
| 3137 | 3089 |
| 3138 | 3090 |
| 3139 class RegExpBackReference final : public RegExpTree { | 3091 class RegExpBackReference final : public RegExpTree { |
| 3140 public: | 3092 public: |
| 3141 explicit RegExpBackReference(RegExpCapture* capture) | 3093 explicit RegExpBackReference(RegExpCapture* capture) : capture_(capture) {} |
| 3142 : capture_(capture) { } | |
| 3143 void* Accept(RegExpVisitor* visitor, void* data) override; | 3094 void* Accept(RegExpVisitor* visitor, void* data) override; |
| 3144 RegExpNode* ToNode(RegExpCompiler* compiler, RegExpNode* on_success) override; | 3095 RegExpNode* ToNode(RegExpCompiler* compiler, RegExpNode* on_success) override; |
| 3145 RegExpBackReference* AsBackReference() override; | 3096 RegExpBackReference* AsBackReference() override; |
| 3146 bool IsBackReference() override; | 3097 bool IsBackReference() override; |
| 3147 int min_match() override { return 0; } | 3098 int min_match() override { return 0; } |
| 3148 // The capture may not be completely parsed yet, if the reference occurs | 3099 // The capture may not be completely parsed yet, if the reference occurs |
| 3149 // before the capture. In the ordinary case, nothing has been captured yet, | 3100 // before the capture. In the ordinary case, nothing has been captured yet, |
| 3150 // so the back reference must have the length 0. If the back reference is | 3101 // so the back reference must have the length 0. If the back reference is |
| 3151 // inside a lookbehind, effectively making it a forward reference, we return | 3102 // inside a lookbehind, effectively making it a forward reference, we return |
| 3152 // 0 since lookbehinds have a length of 0. | 3103 // 0 since lookbehinds have a length of 0. |
| 3153 int max_match() override { | 3104 int max_match() override { |
| 3154 return capture_->body() ? capture_->max_match() : 0; | 3105 return capture_->body() ? capture_->max_match() : 0; |
| 3155 } | 3106 } |
| 3156 int index() { return capture_->index(); } | 3107 int index() { return capture_->index(); } |
| 3157 RegExpCapture* capture() { return capture_; } | 3108 RegExpCapture* capture() { return capture_; } |
| 3109 |
| 3158 private: | 3110 private: |
| 3159 RegExpCapture* capture_; | 3111 RegExpCapture* capture_; |
| 3160 }; | 3112 }; |
| 3161 | 3113 |
| 3162 | 3114 |
| 3163 class RegExpEmpty final : public RegExpTree { | 3115 class RegExpEmpty final : public RegExpTree { |
| 3164 public: | 3116 public: |
| 3165 RegExpEmpty() { } | 3117 RegExpEmpty() {} |
| 3166 void* Accept(RegExpVisitor* visitor, void* data) override; | 3118 void* Accept(RegExpVisitor* visitor, void* data) override; |
| 3167 RegExpNode* ToNode(RegExpCompiler* compiler, RegExpNode* on_success) override; | 3119 RegExpNode* ToNode(RegExpCompiler* compiler, RegExpNode* on_success) override; |
| 3168 RegExpEmpty* AsEmpty() override; | 3120 RegExpEmpty* AsEmpty() override; |
| 3169 bool IsEmpty() override; | 3121 bool IsEmpty() override; |
| 3170 int min_match() override { return 0; } | 3122 int min_match() override { return 0; } |
| 3171 int max_match() override { return 0; } | 3123 int max_match() override { return 0; } |
| 3172 }; | 3124 }; |
| 3173 | 3125 |
| 3174 | 3126 |
| 3175 // ---------------------------------------------------------------------------- | 3127 // ---------------------------------------------------------------------------- |
| 3176 // Basic visitor | 3128 // Basic visitor |
| 3177 // - leaf node visitors are abstract. | 3129 // - leaf node visitors are abstract. |
| 3178 | 3130 |
| 3179 class AstVisitor BASE_EMBEDDED { | 3131 class AstVisitor BASE_EMBEDDED { |
| 3180 public: | 3132 public: |
| 3181 AstVisitor() {} | 3133 AstVisitor() {} |
| 3182 virtual ~AstVisitor() {} | 3134 virtual ~AstVisitor() {} |
| 3183 | 3135 |
| 3184 // Stack overflow check and dynamic dispatch. | 3136 // Stack overflow check and dynamic dispatch. |
| 3185 virtual void Visit(AstNode* node) = 0; | 3137 virtual void Visit(AstNode* node) = 0; |
| 3186 | 3138 |
| 3187 // Iteration left-to-right. | 3139 // Iteration left-to-right. |
| 3188 virtual void VisitDeclarations(ZoneList<Declaration*>* declarations); | 3140 virtual void VisitDeclarations(ZoneList<Declaration*>* declarations); |
| 3189 virtual void VisitStatements(ZoneList<Statement*>* statements); | 3141 virtual void VisitStatements(ZoneList<Statement*>* statements); |
| 3190 virtual void VisitExpressions(ZoneList<Expression*>* expressions); | 3142 virtual void VisitExpressions(ZoneList<Expression*>* expressions); |
| 3191 | 3143 |
| 3192 // Individual AST nodes. | 3144 // Individual AST nodes. |
| 3193 #define DEF_VISIT(type) \ | 3145 #define DEF_VISIT(type) virtual void Visit##type(type* node) = 0; |
| 3194 virtual void Visit##type(type* node) = 0; | |
| 3195 AST_NODE_LIST(DEF_VISIT) | 3146 AST_NODE_LIST(DEF_VISIT) |
| 3196 #undef DEF_VISIT | 3147 #undef DEF_VISIT |
| 3197 }; | 3148 }; |
| 3198 | 3149 |
| 3199 | 3150 |
| 3200 #define DEFINE_AST_VISITOR_SUBCLASS_MEMBERS() \ | 3151 #define DEFINE_AST_VISITOR_SUBCLASS_MEMBERS() \ |
| 3201 public: \ | 3152 public: \ |
| 3202 void Visit(AstNode* node) final { \ | 3153 void Visit(AstNode* node) final { \ |
| 3203 if (!CheckStackOverflow()) node->Accept(this); \ | 3154 if (!CheckStackOverflow()) node->Accept(this); \ |
| 3204 } \ | 3155 } \ |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3247 VariableProxy* proxy, VariableMode mode, Scope* scope, int pos, | 3198 VariableProxy* proxy, VariableMode mode, Scope* scope, int pos, |
| 3248 bool is_class_declaration = false, int declaration_group_start = -1) { | 3199 bool is_class_declaration = false, int declaration_group_start = -1) { |
| 3249 return new (parser_zone_) | 3200 return new (parser_zone_) |
| 3250 VariableDeclaration(parser_zone_, proxy, mode, scope, pos, | 3201 VariableDeclaration(parser_zone_, proxy, mode, scope, pos, |
| 3251 is_class_declaration, declaration_group_start); | 3202 is_class_declaration, declaration_group_start); |
| 3252 } | 3203 } |
| 3253 | 3204 |
| 3254 FunctionDeclaration* NewFunctionDeclaration(VariableProxy* proxy, | 3205 FunctionDeclaration* NewFunctionDeclaration(VariableProxy* proxy, |
| 3255 VariableMode mode, | 3206 VariableMode mode, |
| 3256 FunctionLiteral* fun, | 3207 FunctionLiteral* fun, |
| 3257 Scope* scope, | 3208 Scope* scope, int pos) { |
| 3258 int pos) { | |
| 3259 return new (parser_zone_) | 3209 return new (parser_zone_) |
| 3260 FunctionDeclaration(parser_zone_, proxy, mode, fun, scope, pos); | 3210 FunctionDeclaration(parser_zone_, proxy, mode, fun, scope, pos); |
| 3261 } | 3211 } |
| 3262 | 3212 |
| 3263 ImportDeclaration* NewImportDeclaration(VariableProxy* proxy, | 3213 ImportDeclaration* NewImportDeclaration(VariableProxy* proxy, |
| 3264 const AstRawString* import_name, | 3214 const AstRawString* import_name, |
| 3265 const AstRawString* module_specifier, | 3215 const AstRawString* module_specifier, |
| 3266 Scope* scope, int pos) { | 3216 Scope* scope, int pos) { |
| 3267 return new (parser_zone_) ImportDeclaration( | 3217 return new (parser_zone_) ImportDeclaration( |
| 3268 parser_zone_, proxy, import_name, module_specifier, scope, pos); | 3218 parser_zone_, proxy, import_name, module_specifier, scope, pos); |
| 3269 } | 3219 } |
| 3270 | 3220 |
| 3271 ExportDeclaration* NewExportDeclaration(VariableProxy* proxy, | 3221 ExportDeclaration* NewExportDeclaration(VariableProxy* proxy, Scope* scope, |
| 3272 Scope* scope, | |
| 3273 int pos) { | 3222 int pos) { |
| 3274 return new (parser_zone_) | 3223 return new (parser_zone_) |
| 3275 ExportDeclaration(parser_zone_, proxy, scope, pos); | 3224 ExportDeclaration(parser_zone_, proxy, scope, pos); |
| 3276 } | 3225 } |
| 3277 | 3226 |
| 3278 Block* NewBlock(ZoneList<const AstRawString*>* labels, int capacity, | 3227 Block* NewBlock(ZoneList<const AstRawString*>* labels, int capacity, |
| 3279 bool ignore_completion_value, int pos) { | 3228 bool ignore_completion_value, int pos) { |
| 3280 return new (local_zone_) | 3229 return new (local_zone_) |
| 3281 Block(local_zone_, labels, capacity, ignore_completion_value, pos); | 3230 Block(local_zone_, labels, capacity, ignore_completion_value, pos); |
| 3282 } | 3231 } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3315 } | 3264 } |
| 3316 | 3265 |
| 3317 BreakStatement* NewBreakStatement(BreakableStatement* target, int pos) { | 3266 BreakStatement* NewBreakStatement(BreakableStatement* target, int pos) { |
| 3318 return new (local_zone_) BreakStatement(local_zone_, target, pos); | 3267 return new (local_zone_) BreakStatement(local_zone_, target, pos); |
| 3319 } | 3268 } |
| 3320 | 3269 |
| 3321 ReturnStatement* NewReturnStatement(Expression* expression, int pos) { | 3270 ReturnStatement* NewReturnStatement(Expression* expression, int pos) { |
| 3322 return new (local_zone_) ReturnStatement(local_zone_, expression, pos); | 3271 return new (local_zone_) ReturnStatement(local_zone_, expression, pos); |
| 3323 } | 3272 } |
| 3324 | 3273 |
| 3325 WithStatement* NewWithStatement(Scope* scope, | 3274 WithStatement* NewWithStatement(Scope* scope, Expression* expression, |
| 3326 Expression* expression, | 3275 Statement* statement, int pos) { |
| 3327 Statement* statement, | |
| 3328 int pos) { | |
| 3329 return new (local_zone_) | 3276 return new (local_zone_) |
| 3330 WithStatement(local_zone_, scope, expression, statement, pos); | 3277 WithStatement(local_zone_, scope, expression, statement, pos); |
| 3331 } | 3278 } |
| 3332 | 3279 |
| 3333 IfStatement* NewIfStatement(Expression* condition, | 3280 IfStatement* NewIfStatement(Expression* condition, Statement* then_statement, |
| 3334 Statement* then_statement, | 3281 Statement* else_statement, int pos) { |
| 3335 Statement* else_statement, | |
| 3336 int pos) { | |
| 3337 return new (local_zone_) IfStatement(local_zone_, condition, then_statement, | 3282 return new (local_zone_) IfStatement(local_zone_, condition, then_statement, |
| 3338 else_statement, pos); | 3283 else_statement, pos); |
| 3339 } | 3284 } |
| 3340 | 3285 |
| 3341 TryCatchStatement* NewTryCatchStatement(Block* try_block, Scope* scope, | 3286 TryCatchStatement* NewTryCatchStatement(Block* try_block, Scope* scope, |
| 3342 Variable* variable, | 3287 Variable* variable, |
| 3343 Block* catch_block, int pos) { | 3288 Block* catch_block, int pos) { |
| 3344 return new (local_zone_) TryCatchStatement(local_zone_, try_block, scope, | 3289 return new (local_zone_) TryCatchStatement(local_zone_, try_block, scope, |
| 3345 variable, catch_block, pos); | 3290 variable, catch_block, pos); |
| 3346 } | 3291 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 3358 EmptyStatement* NewEmptyStatement(int pos) { | 3303 EmptyStatement* NewEmptyStatement(int pos) { |
| 3359 return new (local_zone_) EmptyStatement(local_zone_, pos); | 3304 return new (local_zone_) EmptyStatement(local_zone_, pos); |
| 3360 } | 3305 } |
| 3361 | 3306 |
| 3362 SloppyBlockFunctionStatement* NewSloppyBlockFunctionStatement( | 3307 SloppyBlockFunctionStatement* NewSloppyBlockFunctionStatement( |
| 3363 Statement* statement, Scope* scope) { | 3308 Statement* statement, Scope* scope) { |
| 3364 return new (local_zone_) | 3309 return new (local_zone_) |
| 3365 SloppyBlockFunctionStatement(local_zone_, statement, scope); | 3310 SloppyBlockFunctionStatement(local_zone_, statement, scope); |
| 3366 } | 3311 } |
| 3367 | 3312 |
| 3368 CaseClause* NewCaseClause( | 3313 CaseClause* NewCaseClause(Expression* label, ZoneList<Statement*>* statements, |
| 3369 Expression* label, ZoneList<Statement*>* statements, int pos) { | 3314 int pos) { |
| 3370 return new (local_zone_) CaseClause(local_zone_, label, statements, pos); | 3315 return new (local_zone_) CaseClause(local_zone_, label, statements, pos); |
| 3371 } | 3316 } |
| 3372 | 3317 |
| 3373 Literal* NewStringLiteral(const AstRawString* string, int pos) { | 3318 Literal* NewStringLiteral(const AstRawString* string, int pos) { |
| 3374 return new (local_zone_) | 3319 return new (local_zone_) |
| 3375 Literal(local_zone_, ast_value_factory_->NewString(string), pos); | 3320 Literal(local_zone_, ast_value_factory_->NewString(string), pos); |
| 3376 } | 3321 } |
| 3377 | 3322 |
| 3378 // A JavaScript symbol (ECMA-262 edition 6). | 3323 // A JavaScript symbol (ECMA-262 edition 6). |
| 3379 Literal* NewSymbolLiteral(const char* name, int pos) { | 3324 Literal* NewSymbolLiteral(const char* name, int pos) { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 3405 return new (local_zone_) | 3350 return new (local_zone_) |
| 3406 Literal(local_zone_, ast_value_factory_->NewUndefined(), pos); | 3351 Literal(local_zone_, ast_value_factory_->NewUndefined(), pos); |
| 3407 } | 3352 } |
| 3408 | 3353 |
| 3409 Literal* NewTheHoleLiteral(int pos) { | 3354 Literal* NewTheHoleLiteral(int pos) { |
| 3410 return new (local_zone_) | 3355 return new (local_zone_) |
| 3411 Literal(local_zone_, ast_value_factory_->NewTheHole(), pos); | 3356 Literal(local_zone_, ast_value_factory_->NewTheHole(), pos); |
| 3412 } | 3357 } |
| 3413 | 3358 |
| 3414 ObjectLiteral* NewObjectLiteral( | 3359 ObjectLiteral* NewObjectLiteral( |
| 3415 ZoneList<ObjectLiteral::Property*>* properties, | 3360 ZoneList<ObjectLiteral::Property*>* properties, int literal_index, |
| 3416 int literal_index, | 3361 int boilerplate_properties, bool has_function, bool is_strong, int pos) { |
| 3417 int boilerplate_properties, | |
| 3418 bool has_function, | |
| 3419 bool is_strong, | |
| 3420 int pos) { | |
| 3421 return new (local_zone_) | 3362 return new (local_zone_) |
| 3422 ObjectLiteral(local_zone_, properties, literal_index, | 3363 ObjectLiteral(local_zone_, properties, literal_index, |
| 3423 boilerplate_properties, has_function, is_strong, pos); | 3364 boilerplate_properties, has_function, is_strong, pos); |
| 3424 } | 3365 } |
| 3425 | 3366 |
| 3426 ObjectLiteral::Property* NewObjectLiteralProperty( | 3367 ObjectLiteral::Property* NewObjectLiteralProperty( |
| 3427 Expression* key, Expression* value, ObjectLiteralProperty::Kind kind, | 3368 Expression* key, Expression* value, ObjectLiteralProperty::Kind kind, |
| 3428 bool is_static, bool is_computed_name) { | 3369 bool is_static, bool is_computed_name) { |
| 3429 return new (local_zone_) | 3370 return new (local_zone_) |
| 3430 ObjectLiteral::Property(key, value, kind, is_static, is_computed_name); | 3371 ObjectLiteral::Property(key, value, kind, is_static, is_computed_name); |
| 3431 } | 3372 } |
| 3432 | 3373 |
| 3433 ObjectLiteral::Property* NewObjectLiteralProperty(Expression* key, | 3374 ObjectLiteral::Property* NewObjectLiteralProperty(Expression* key, |
| 3434 Expression* value, | 3375 Expression* value, |
| 3435 bool is_static, | 3376 bool is_static, |
| 3436 bool is_computed_name) { | 3377 bool is_computed_name) { |
| 3437 return new (local_zone_) ObjectLiteral::Property( | 3378 return new (local_zone_) ObjectLiteral::Property( |
| 3438 ast_value_factory_, key, value, is_static, is_computed_name); | 3379 ast_value_factory_, key, value, is_static, is_computed_name); |
| 3439 } | 3380 } |
| 3440 | 3381 |
| 3441 RegExpLiteral* NewRegExpLiteral(const AstRawString* pattern, int flags, | 3382 RegExpLiteral* NewRegExpLiteral(const AstRawString* pattern, int flags, |
| 3442 int literal_index, bool is_strong, int pos) { | 3383 int literal_index, bool is_strong, int pos) { |
| 3443 return new (local_zone_) RegExpLiteral(local_zone_, pattern, flags, | 3384 return new (local_zone_) RegExpLiteral(local_zone_, pattern, flags, |
| 3444 literal_index, is_strong, pos); | 3385 literal_index, is_strong, pos); |
| 3445 } | 3386 } |
| 3446 | 3387 |
| 3447 ArrayLiteral* NewArrayLiteral(ZoneList<Expression*>* values, | 3388 ArrayLiteral* NewArrayLiteral(ZoneList<Expression*>* values, |
| 3448 int literal_index, | 3389 int literal_index, bool is_strong, int pos) { |
| 3449 bool is_strong, | |
| 3450 int pos) { | |
| 3451 return new (local_zone_) | 3390 return new (local_zone_) |
| 3452 ArrayLiteral(local_zone_, values, -1, literal_index, is_strong, pos); | 3391 ArrayLiteral(local_zone_, values, -1, literal_index, is_strong, pos); |
| 3453 } | 3392 } |
| 3454 | 3393 |
| 3455 ArrayLiteral* NewArrayLiteral(ZoneList<Expression*>* values, | 3394 ArrayLiteral* NewArrayLiteral(ZoneList<Expression*>* values, |
| 3456 int first_spread_index, int literal_index, | 3395 int first_spread_index, int literal_index, |
| 3457 bool is_strong, int pos) { | 3396 bool is_strong, int pos) { |
| 3458 return new (local_zone_) ArrayLiteral( | 3397 return new (local_zone_) ArrayLiteral( |
| 3459 local_zone_, values, first_spread_index, literal_index, is_strong, pos); | 3398 local_zone_, values, first_spread_index, literal_index, is_strong, pos); |
| 3460 } | 3399 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 3472 int end_position = RelocInfo::kNoPosition) { | 3411 int end_position = RelocInfo::kNoPosition) { |
| 3473 DCHECK_NOT_NULL(name); | 3412 DCHECK_NOT_NULL(name); |
| 3474 return new (parser_zone_) VariableProxy(parser_zone_, name, variable_kind, | 3413 return new (parser_zone_) VariableProxy(parser_zone_, name, variable_kind, |
| 3475 start_position, end_position); | 3414 start_position, end_position); |
| 3476 } | 3415 } |
| 3477 | 3416 |
| 3478 Property* NewProperty(Expression* obj, Expression* key, int pos) { | 3417 Property* NewProperty(Expression* obj, Expression* key, int pos) { |
| 3479 return new (local_zone_) Property(local_zone_, obj, key, pos); | 3418 return new (local_zone_) Property(local_zone_, obj, key, pos); |
| 3480 } | 3419 } |
| 3481 | 3420 |
| 3482 Call* NewCall(Expression* expression, | 3421 Call* NewCall(Expression* expression, ZoneList<Expression*>* arguments, |
| 3483 ZoneList<Expression*>* arguments, | |
| 3484 int pos) { | 3422 int pos) { |
| 3485 return new (local_zone_) Call(local_zone_, expression, arguments, pos); | 3423 return new (local_zone_) Call(local_zone_, expression, arguments, pos); |
| 3486 } | 3424 } |
| 3487 | 3425 |
| 3488 CallNew* NewCallNew(Expression* expression, | 3426 CallNew* NewCallNew(Expression* expression, ZoneList<Expression*>* arguments, |
| 3489 ZoneList<Expression*>* arguments, | |
| 3490 int pos) { | 3427 int pos) { |
| 3491 return new (local_zone_) CallNew(local_zone_, expression, arguments, pos); | 3428 return new (local_zone_) CallNew(local_zone_, expression, arguments, pos); |
| 3492 } | 3429 } |
| 3493 | 3430 |
| 3494 CallRuntime* NewCallRuntime(Runtime::FunctionId id, | 3431 CallRuntime* NewCallRuntime(Runtime::FunctionId id, |
| 3495 ZoneList<Expression*>* arguments, int pos) { | 3432 ZoneList<Expression*>* arguments, int pos) { |
| 3496 return new (local_zone_) | 3433 return new (local_zone_) |
| 3497 CallRuntime(local_zone_, Runtime::FunctionForId(id), arguments, pos); | 3434 CallRuntime(local_zone_, Runtime::FunctionForId(id), arguments, pos); |
| 3498 } | 3435 } |
| 3499 | 3436 |
| 3500 CallRuntime* NewCallRuntime(const Runtime::Function* function, | 3437 CallRuntime* NewCallRuntime(const Runtime::Function* function, |
| 3501 ZoneList<Expression*>* arguments, int pos) { | 3438 ZoneList<Expression*>* arguments, int pos) { |
| 3502 return new (local_zone_) CallRuntime(local_zone_, function, arguments, pos); | 3439 return new (local_zone_) CallRuntime(local_zone_, function, arguments, pos); |
| 3503 } | 3440 } |
| 3504 | 3441 |
| 3505 CallRuntime* NewCallRuntime(int context_index, | 3442 CallRuntime* NewCallRuntime(int context_index, |
| 3506 ZoneList<Expression*>* arguments, int pos) { | 3443 ZoneList<Expression*>* arguments, int pos) { |
| 3507 return new (local_zone_) | 3444 return new (local_zone_) |
| 3508 CallRuntime(local_zone_, context_index, arguments, pos); | 3445 CallRuntime(local_zone_, context_index, arguments, pos); |
| 3509 } | 3446 } |
| 3510 | 3447 |
| 3511 UnaryOperation* NewUnaryOperation(Token::Value op, | 3448 UnaryOperation* NewUnaryOperation(Token::Value op, Expression* expression, |
| 3512 Expression* expression, | |
| 3513 int pos) { | 3449 int pos) { |
| 3514 return new (local_zone_) UnaryOperation(local_zone_, op, expression, pos); | 3450 return new (local_zone_) UnaryOperation(local_zone_, op, expression, pos); |
| 3515 } | 3451 } |
| 3516 | 3452 |
| 3517 BinaryOperation* NewBinaryOperation(Token::Value op, | 3453 BinaryOperation* NewBinaryOperation(Token::Value op, Expression* left, |
| 3518 Expression* left, | 3454 Expression* right, int pos) { |
| 3519 Expression* right, | |
| 3520 int pos) { | |
| 3521 return new (local_zone_) BinaryOperation(local_zone_, op, left, right, pos); | 3455 return new (local_zone_) BinaryOperation(local_zone_, op, left, right, pos); |
| 3522 } | 3456 } |
| 3523 | 3457 |
| 3524 CountOperation* NewCountOperation(Token::Value op, | 3458 CountOperation* NewCountOperation(Token::Value op, bool is_prefix, |
| 3525 bool is_prefix, | 3459 Expression* expr, int pos) { |
| 3526 Expression* expr, | |
| 3527 int pos) { | |
| 3528 return new (local_zone_) | 3460 return new (local_zone_) |
| 3529 CountOperation(local_zone_, op, is_prefix, expr, pos); | 3461 CountOperation(local_zone_, op, is_prefix, expr, pos); |
| 3530 } | 3462 } |
| 3531 | 3463 |
| 3532 CompareOperation* NewCompareOperation(Token::Value op, | 3464 CompareOperation* NewCompareOperation(Token::Value op, Expression* left, |
| 3533 Expression* left, | 3465 Expression* right, int pos) { |
| 3534 Expression* right, | |
| 3535 int pos) { | |
| 3536 return new (local_zone_) | 3466 return new (local_zone_) |
| 3537 CompareOperation(local_zone_, op, left, right, pos); | 3467 CompareOperation(local_zone_, op, left, right, pos); |
| 3538 } | 3468 } |
| 3539 | 3469 |
| 3540 Spread* NewSpread(Expression* expression, int pos) { | 3470 Spread* NewSpread(Expression* expression, int pos) { |
| 3541 return new (local_zone_) Spread(local_zone_, expression, pos); | 3471 return new (local_zone_) Spread(local_zone_, expression, pos); |
| 3542 } | 3472 } |
| 3543 | 3473 |
| 3544 Conditional* NewConditional(Expression* condition, | 3474 Conditional* NewConditional(Expression* condition, |
| 3545 Expression* then_expression, | 3475 Expression* then_expression, |
| 3546 Expression* else_expression, | 3476 Expression* else_expression, int position) { |
| 3547 int position) { | |
| 3548 return new (local_zone_) Conditional( | 3477 return new (local_zone_) Conditional( |
| 3549 local_zone_, condition, then_expression, else_expression, position); | 3478 local_zone_, condition, then_expression, else_expression, position); |
| 3550 } | 3479 } |
| 3551 | 3480 |
| 3552 Assignment* NewAssignment(Token::Value op, | 3481 Assignment* NewAssignment(Token::Value op, Expression* target, |
| 3553 Expression* target, | 3482 Expression* value, int pos) { |
| 3554 Expression* value, | |
| 3555 int pos) { | |
| 3556 DCHECK(Token::IsAssignmentOp(op)); | 3483 DCHECK(Token::IsAssignmentOp(op)); |
| 3557 Assignment* assign = | 3484 Assignment* assign = |
| 3558 new (local_zone_) Assignment(local_zone_, op, target, value, pos); | 3485 new (local_zone_) Assignment(local_zone_, op, target, value, pos); |
| 3559 if (assign->is_compound()) { | 3486 if (assign->is_compound()) { |
| 3560 DCHECK(Token::IsAssignmentOp(op)); | 3487 DCHECK(Token::IsAssignmentOp(op)); |
| 3561 assign->binary_operation_ = | 3488 assign->binary_operation_ = |
| 3562 NewBinaryOperation(assign->binary_op(), target, value, pos + 1); | 3489 NewBinaryOperation(assign->binary_op(), target, value, pos + 1); |
| 3563 } | 3490 } |
| 3564 return assign; | 3491 return assign; |
| 3565 } | 3492 } |
| 3566 | 3493 |
| 3567 Yield* NewYield(Expression *generator_object, | 3494 Yield* NewYield(Expression* generator_object, Expression* expression, |
| 3568 Expression* expression, | 3495 Yield::Kind yield_kind, int pos) { |
| 3569 Yield::Kind yield_kind, | |
| 3570 int pos) { | |
| 3571 if (!expression) expression = NewUndefinedLiteral(pos); | 3496 if (!expression) expression = NewUndefinedLiteral(pos); |
| 3572 return new (local_zone_) | 3497 return new (local_zone_) |
| 3573 Yield(local_zone_, generator_object, expression, yield_kind, pos); | 3498 Yield(local_zone_, generator_object, expression, yield_kind, pos); |
| 3574 } | 3499 } |
| 3575 | 3500 |
| 3576 Throw* NewThrow(Expression* exception, int pos) { | 3501 Throw* NewThrow(Expression* exception, int pos) { |
| 3577 return new (local_zone_) Throw(local_zone_, exception, pos); | 3502 return new (local_zone_) Throw(local_zone_, exception, pos); |
| 3578 } | 3503 } |
| 3579 | 3504 |
| 3580 FunctionLiteral* NewFunctionLiteral( | 3505 FunctionLiteral* NewFunctionLiteral( |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3667 // the parser-level zone. | 3592 // the parser-level zone. |
| 3668 Zone* parser_zone_; | 3593 Zone* parser_zone_; |
| 3669 AstValueFactory* ast_value_factory_; | 3594 AstValueFactory* ast_value_factory_; |
| 3670 }; | 3595 }; |
| 3671 | 3596 |
| 3672 | 3597 |
| 3673 } // namespace internal | 3598 } // namespace internal |
| 3674 } // namespace v8 | 3599 } // namespace v8 |
| 3675 | 3600 |
| 3676 #endif // V8_AST_AST_H_ | 3601 #endif // V8_AST_AST_H_ |
| OLD | NEW |