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/ast/ast-value-factory.h" | 8 #include "src/ast/ast-value-factory.h" |
9 #include "src/ast/modules.h" | 9 #include "src/ast/modules.h" |
10 #include "src/ast/variables.h" | 10 #include "src/ast/variables.h" |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
124 #define DEF_FORWARD_DECLARATION(type) class type; | 124 #define DEF_FORWARD_DECLARATION(type) class type; |
125 AST_NODE_LIST(DEF_FORWARD_DECLARATION) | 125 AST_NODE_LIST(DEF_FORWARD_DECLARATION) |
126 #undef DEF_FORWARD_DECLARATION | 126 #undef DEF_FORWARD_DECLARATION |
127 | 127 |
128 | 128 |
129 // Typedef only introduced to avoid unreadable code. | 129 // Typedef only introduced to avoid unreadable code. |
130 typedef ZoneList<Handle<String>> ZoneStringList; | 130 typedef ZoneList<Handle<String>> ZoneStringList; |
131 typedef ZoneList<Handle<Object>> ZoneObjectList; | 131 typedef ZoneList<Handle<Object>> ZoneObjectList; |
132 | 132 |
133 | 133 |
134 #define DECLARE_NODE_TYPE(type) \ | |
135 friend class AstNodeFactory; | |
136 | |
137 | |
138 class FeedbackVectorSlotCache { | 134 class FeedbackVectorSlotCache { |
139 public: | 135 public: |
140 explicit FeedbackVectorSlotCache(Zone* zone) | 136 explicit FeedbackVectorSlotCache(Zone* zone) |
141 : zone_(zone), | 137 : zone_(zone), |
142 hash_map_(base::HashMap::PointersMatch, | 138 hash_map_(base::HashMap::PointersMatch, |
143 ZoneHashMap::kDefaultHashMapCapacity, | 139 ZoneHashMap::kDefaultHashMapCapacity, |
144 ZoneAllocationPolicy(zone)) {} | 140 ZoneAllocationPolicy(zone)) {} |
145 | 141 |
146 void Put(Variable* variable, FeedbackVectorSlot slot) { | 142 void Put(Variable* variable, FeedbackVectorSlot slot) { |
147 ZoneHashMap::Entry* entry = hash_map_.LookupOrInsert( | 143 ZoneHashMap::Entry* entry = hash_map_.LookupOrInsert( |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
425 | 421 |
426 BreakableType breakable_type_; | 422 BreakableType breakable_type_; |
427 int base_id_; | 423 int base_id_; |
428 Label break_target_; | 424 Label break_target_; |
429 ZoneList<const AstRawString*>* labels_; | 425 ZoneList<const AstRawString*>* labels_; |
430 }; | 426 }; |
431 | 427 |
432 | 428 |
433 class Block final : public BreakableStatement { | 429 class Block final : public BreakableStatement { |
434 public: | 430 public: |
435 DECLARE_NODE_TYPE(Block) | 431 friend class AstNodeFactory; |
adamk
2016/08/05 21:52:35
I think we generally put friend declarations in th
| |
436 | 432 |
437 ZoneList<Statement*>* statements() { return &statements_; } | 433 ZoneList<Statement*>* statements() { return &statements_; } |
438 bool ignore_completion_value() const { return ignore_completion_value_; } | 434 bool ignore_completion_value() const { return ignore_completion_value_; } |
439 | 435 |
440 static int num_ids() { return parent_num_ids() + 1; } | 436 static int num_ids() { return parent_num_ids() + 1; } |
441 BailoutId DeclsId() const { return BailoutId(local_id(0)); } | 437 BailoutId DeclsId() const { return BailoutId(local_id(0)); } |
442 | 438 |
443 bool IsJump() const { | 439 bool IsJump() const { |
444 return !statements_.is_empty() && statements_.last()->IsJump() | 440 return !statements_.is_empty() && statements_.last()->IsJump() |
445 && labels() == NULL; // Good enough as an approximation... | 441 && labels() == NULL; // Good enough as an approximation... |
(...skipping 15 matching lines...) Expand all Loading... | |
461 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 457 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
462 | 458 |
463 ZoneList<Statement*> statements_; | 459 ZoneList<Statement*> statements_; |
464 bool ignore_completion_value_; | 460 bool ignore_completion_value_; |
465 Scope* scope_; | 461 Scope* scope_; |
466 }; | 462 }; |
467 | 463 |
468 | 464 |
469 class DoExpression final : public Expression { | 465 class DoExpression final : public Expression { |
470 public: | 466 public: |
471 DECLARE_NODE_TYPE(DoExpression) | 467 friend class AstNodeFactory; |
472 | 468 |
473 Block* block() { return block_; } | 469 Block* block() { return block_; } |
474 void set_block(Block* b) { block_ = b; } | 470 void set_block(Block* b) { block_ = b; } |
475 VariableProxy* result() { return result_; } | 471 VariableProxy* result() { return result_; } |
476 void set_result(VariableProxy* v) { result_ = v; } | 472 void set_result(VariableProxy* v) { result_ = v; } |
477 FunctionLiteral* represented_function() { return represented_function_; } | 473 FunctionLiteral* represented_function() { return represented_function_; } |
478 void set_represented_function(FunctionLiteral* f) { | 474 void set_represented_function(FunctionLiteral* f) { |
479 represented_function_ = f; | 475 represented_function_ = f; |
480 } | 476 } |
481 bool IsAnonymousFunctionDefinition() const; | 477 bool IsAnonymousFunctionDefinition() const; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
518 VariableMode mode_; | 514 VariableMode mode_; |
519 VariableProxy* proxy_; | 515 VariableProxy* proxy_; |
520 | 516 |
521 // Nested scope from which the declaration originated. | 517 // Nested scope from which the declaration originated. |
522 Scope* scope_; | 518 Scope* scope_; |
523 }; | 519 }; |
524 | 520 |
525 | 521 |
526 class VariableDeclaration final : public Declaration { | 522 class VariableDeclaration final : public Declaration { |
527 public: | 523 public: |
528 DECLARE_NODE_TYPE(VariableDeclaration) | 524 friend class AstNodeFactory; |
529 | 525 |
530 InitializationFlag initialization() const { | 526 InitializationFlag initialization() const { |
531 return mode() == VAR ? kCreatedInitialized : kNeedsInitialization; | 527 return mode() == VAR ? kCreatedInitialized : kNeedsInitialization; |
532 } | 528 } |
533 | 529 |
534 protected: | 530 protected: |
535 VariableDeclaration(Zone* zone, VariableProxy* proxy, VariableMode mode, | 531 VariableDeclaration(Zone* zone, VariableProxy* proxy, VariableMode mode, |
536 Scope* scope, int pos) | 532 Scope* scope, int pos) |
537 : Declaration(zone, proxy, mode, scope, pos, kVariableDeclaration) {} | 533 : Declaration(zone, proxy, mode, scope, pos, kVariableDeclaration) {} |
538 }; | 534 }; |
539 | 535 |
540 | 536 |
541 class FunctionDeclaration final : public Declaration { | 537 class FunctionDeclaration final : public Declaration { |
542 public: | 538 public: |
543 DECLARE_NODE_TYPE(FunctionDeclaration) | 539 friend class AstNodeFactory; |
544 | 540 |
545 FunctionLiteral* fun() const { return fun_; } | 541 FunctionLiteral* fun() const { return fun_; } |
546 void set_fun(FunctionLiteral* f) { fun_ = f; } | 542 void set_fun(FunctionLiteral* f) { fun_ = f; } |
547 InitializationFlag initialization() const { return kCreatedInitialized; } | 543 InitializationFlag initialization() const { return kCreatedInitialized; } |
548 | 544 |
549 protected: | 545 protected: |
550 FunctionDeclaration(Zone* zone, VariableProxy* proxy, VariableMode mode, | 546 FunctionDeclaration(Zone* zone, VariableProxy* proxy, VariableMode mode, |
551 FunctionLiteral* fun, Scope* scope, int pos) | 547 FunctionLiteral* fun, Scope* scope, int pos) |
552 : Declaration(zone, proxy, mode, scope, pos, kFunctionDeclaration), | 548 : Declaration(zone, proxy, mode, scope, pos, kFunctionDeclaration), |
553 fun_(fun) { | 549 fun_(fun) { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
593 | 589 |
594 Statement* body_; | 590 Statement* body_; |
595 Label continue_target_; | 591 Label continue_target_; |
596 int yield_count_; | 592 int yield_count_; |
597 int first_yield_id_; | 593 int first_yield_id_; |
598 }; | 594 }; |
599 | 595 |
600 | 596 |
601 class DoWhileStatement final : public IterationStatement { | 597 class DoWhileStatement final : public IterationStatement { |
602 public: | 598 public: |
603 DECLARE_NODE_TYPE(DoWhileStatement) | 599 friend class AstNodeFactory; |
604 | 600 |
605 void Initialize(Expression* cond, Statement* body) { | 601 void Initialize(Expression* cond, Statement* body) { |
606 IterationStatement::Initialize(body); | 602 IterationStatement::Initialize(body); |
607 cond_ = cond; | 603 cond_ = cond; |
608 } | 604 } |
609 | 605 |
610 Expression* cond() const { return cond_; } | 606 Expression* cond() const { return cond_; } |
611 void set_cond(Expression* e) { cond_ = e; } | 607 void set_cond(Expression* e) { cond_ = e; } |
612 | 608 |
613 static int num_ids() { return parent_num_ids() + 2; } | 609 static int num_ids() { return parent_num_ids() + 2; } |
614 BailoutId ContinueId() const { return BailoutId(local_id(0)); } | 610 BailoutId ContinueId() const { return BailoutId(local_id(0)); } |
615 BailoutId StackCheckId() const { return BackEdgeId(); } | 611 BailoutId StackCheckId() const { return BackEdgeId(); } |
616 BailoutId BackEdgeId() const { return BailoutId(local_id(1)); } | 612 BailoutId BackEdgeId() const { return BailoutId(local_id(1)); } |
617 | 613 |
618 protected: | 614 protected: |
619 DoWhileStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) | 615 DoWhileStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) |
620 : IterationStatement(zone, labels, pos, kDoWhileStatement), cond_(NULL) {} | 616 : IterationStatement(zone, labels, pos, kDoWhileStatement), cond_(NULL) {} |
621 static int parent_num_ids() { return IterationStatement::num_ids(); } | 617 static int parent_num_ids() { return IterationStatement::num_ids(); } |
622 | 618 |
623 private: | 619 private: |
624 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 620 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
625 | 621 |
626 Expression* cond_; | 622 Expression* cond_; |
627 }; | 623 }; |
628 | 624 |
629 | 625 |
630 class WhileStatement final : public IterationStatement { | 626 class WhileStatement final : public IterationStatement { |
631 public: | 627 public: |
632 DECLARE_NODE_TYPE(WhileStatement) | 628 friend class AstNodeFactory; |
633 | 629 |
634 void Initialize(Expression* cond, Statement* body) { | 630 void Initialize(Expression* cond, Statement* body) { |
635 IterationStatement::Initialize(body); | 631 IterationStatement::Initialize(body); |
636 cond_ = cond; | 632 cond_ = cond; |
637 } | 633 } |
638 | 634 |
639 Expression* cond() const { return cond_; } | 635 Expression* cond() const { return cond_; } |
640 void set_cond(Expression* e) { cond_ = e; } | 636 void set_cond(Expression* e) { cond_ = e; } |
641 | 637 |
642 static int num_ids() { return parent_num_ids() + 1; } | 638 static int num_ids() { return parent_num_ids() + 1; } |
643 BailoutId ContinueId() const { return EntryId(); } | 639 BailoutId ContinueId() const { return EntryId(); } |
644 BailoutId StackCheckId() const { return BodyId(); } | 640 BailoutId StackCheckId() const { return BodyId(); } |
645 BailoutId BodyId() const { return BailoutId(local_id(0)); } | 641 BailoutId BodyId() const { return BailoutId(local_id(0)); } |
646 | 642 |
647 protected: | 643 protected: |
648 WhileStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) | 644 WhileStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) |
649 : IterationStatement(zone, labels, pos, kWhileStatement), cond_(NULL) {} | 645 : IterationStatement(zone, labels, pos, kWhileStatement), cond_(NULL) {} |
650 static int parent_num_ids() { return IterationStatement::num_ids(); } | 646 static int parent_num_ids() { return IterationStatement::num_ids(); } |
651 | 647 |
652 private: | 648 private: |
653 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 649 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
654 | 650 |
655 Expression* cond_; | 651 Expression* cond_; |
656 }; | 652 }; |
657 | 653 |
658 | 654 |
659 class ForStatement final : public IterationStatement { | 655 class ForStatement final : public IterationStatement { |
660 public: | 656 public: |
661 DECLARE_NODE_TYPE(ForStatement) | 657 friend class AstNodeFactory; |
662 | 658 |
663 void Initialize(Statement* init, | 659 void Initialize(Statement* init, |
664 Expression* cond, | 660 Expression* cond, |
665 Statement* next, | 661 Statement* next, |
666 Statement* body) { | 662 Statement* body) { |
667 IterationStatement::Initialize(body); | 663 IterationStatement::Initialize(body); |
668 init_ = init; | 664 init_ = init; |
669 cond_ = cond; | 665 cond_ = cond; |
670 next_ = next; | 666 next_ = next; |
671 } | 667 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
715 | 711 |
716 protected: | 712 protected: |
717 ForEachStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, | 713 ForEachStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, |
718 NodeType type) | 714 NodeType type) |
719 : IterationStatement(zone, labels, pos, type) {} | 715 : IterationStatement(zone, labels, pos, type) {} |
720 }; | 716 }; |
721 | 717 |
722 | 718 |
723 class ForInStatement final : public ForEachStatement { | 719 class ForInStatement final : public ForEachStatement { |
724 public: | 720 public: |
725 DECLARE_NODE_TYPE(ForInStatement) | 721 friend class AstNodeFactory; |
726 | 722 |
727 void Initialize(Expression* each, Expression* subject, Statement* body) { | 723 void Initialize(Expression* each, Expression* subject, Statement* body) { |
728 ForEachStatement::Initialize(body); | 724 ForEachStatement::Initialize(body); |
729 each_ = each; | 725 each_ = each; |
730 subject_ = subject; | 726 subject_ = subject; |
731 } | 727 } |
732 | 728 |
733 Expression* enumerable() const { | 729 Expression* enumerable() const { |
734 return subject(); | 730 return subject(); |
735 } | 731 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
777 Expression* each_; | 773 Expression* each_; |
778 Expression* subject_; | 774 Expression* subject_; |
779 ForInType for_in_type_; | 775 ForInType for_in_type_; |
780 FeedbackVectorSlot each_slot_; | 776 FeedbackVectorSlot each_slot_; |
781 FeedbackVectorSlot for_in_feedback_slot_; | 777 FeedbackVectorSlot for_in_feedback_slot_; |
782 }; | 778 }; |
783 | 779 |
784 | 780 |
785 class ForOfStatement final : public ForEachStatement { | 781 class ForOfStatement final : public ForEachStatement { |
786 public: | 782 public: |
787 DECLARE_NODE_TYPE(ForOfStatement) | 783 friend class AstNodeFactory; |
788 | 784 |
789 void Initialize(Statement* body, Variable* iterator, | 785 void Initialize(Statement* body, Variable* iterator, |
790 Expression* assign_iterator, Expression* next_result, | 786 Expression* assign_iterator, Expression* next_result, |
791 Expression* result_done, Expression* assign_each) { | 787 Expression* result_done, Expression* assign_each) { |
792 ForEachStatement::Initialize(body); | 788 ForEachStatement::Initialize(body); |
793 iterator_ = iterator; | 789 iterator_ = iterator; |
794 assign_iterator_ = assign_iterator; | 790 assign_iterator_ = assign_iterator; |
795 next_result_ = next_result; | 791 next_result_ = next_result; |
796 result_done_ = result_done; | 792 result_done_ = result_done; |
797 assign_each_ = assign_each; | 793 assign_each_ = assign_each; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
848 Variable* iterator_; | 844 Variable* iterator_; |
849 Expression* assign_iterator_; | 845 Expression* assign_iterator_; |
850 Expression* next_result_; | 846 Expression* next_result_; |
851 Expression* result_done_; | 847 Expression* result_done_; |
852 Expression* assign_each_; | 848 Expression* assign_each_; |
853 }; | 849 }; |
854 | 850 |
855 | 851 |
856 class ExpressionStatement final : public Statement { | 852 class ExpressionStatement final : public Statement { |
857 public: | 853 public: |
858 DECLARE_NODE_TYPE(ExpressionStatement) | 854 friend class AstNodeFactory; |
859 | 855 |
860 void set_expression(Expression* e) { expression_ = e; } | 856 void set_expression(Expression* e) { expression_ = e; } |
861 Expression* expression() const { return expression_; } | 857 Expression* expression() const { return expression_; } |
862 bool IsJump() const { return expression_->IsThrow(); } | 858 bool IsJump() const { return expression_->IsThrow(); } |
863 | 859 |
864 protected: | 860 protected: |
865 ExpressionStatement(Zone* zone, Expression* expression, int pos) | 861 ExpressionStatement(Zone* zone, Expression* expression, int pos) |
866 : Statement(zone, pos, kExpressionStatement), expression_(expression) {} | 862 : Statement(zone, pos, kExpressionStatement), expression_(expression) {} |
867 | 863 |
868 private: | 864 private: |
869 Expression* expression_; | 865 Expression* expression_; |
870 }; | 866 }; |
871 | 867 |
872 | 868 |
873 class JumpStatement : public Statement { | 869 class JumpStatement : public Statement { |
874 public: | 870 public: |
875 bool IsJump() const { return true; } | 871 bool IsJump() const { return true; } |
876 | 872 |
877 protected: | 873 protected: |
878 JumpStatement(Zone* zone, int pos, NodeType type) | 874 JumpStatement(Zone* zone, int pos, NodeType type) |
879 : Statement(zone, pos, type) {} | 875 : Statement(zone, pos, type) {} |
880 }; | 876 }; |
881 | 877 |
882 | 878 |
883 class ContinueStatement final : public JumpStatement { | 879 class ContinueStatement final : public JumpStatement { |
884 public: | 880 public: |
885 DECLARE_NODE_TYPE(ContinueStatement) | 881 friend class AstNodeFactory; |
886 | 882 |
887 IterationStatement* target() const { return target_; } | 883 IterationStatement* target() const { return target_; } |
888 | 884 |
889 protected: | 885 protected: |
890 ContinueStatement(Zone* zone, IterationStatement* target, int pos) | 886 ContinueStatement(Zone* zone, IterationStatement* target, int pos) |
891 : JumpStatement(zone, pos, kContinueStatement), target_(target) {} | 887 : JumpStatement(zone, pos, kContinueStatement), target_(target) {} |
892 | 888 |
893 private: | 889 private: |
894 IterationStatement* target_; | 890 IterationStatement* target_; |
895 }; | 891 }; |
896 | 892 |
897 | 893 |
898 class BreakStatement final : public JumpStatement { | 894 class BreakStatement final : public JumpStatement { |
899 public: | 895 public: |
900 DECLARE_NODE_TYPE(BreakStatement) | 896 friend class AstNodeFactory; |
901 | 897 |
902 BreakableStatement* target() const { return target_; } | 898 BreakableStatement* target() const { return target_; } |
903 | 899 |
904 protected: | 900 protected: |
905 BreakStatement(Zone* zone, BreakableStatement* target, int pos) | 901 BreakStatement(Zone* zone, BreakableStatement* target, int pos) |
906 : JumpStatement(zone, pos, kBreakStatement), target_(target) {} | 902 : JumpStatement(zone, pos, kBreakStatement), target_(target) {} |
907 | 903 |
908 private: | 904 private: |
909 BreakableStatement* target_; | 905 BreakableStatement* target_; |
910 }; | 906 }; |
911 | 907 |
912 | 908 |
913 class ReturnStatement final : public JumpStatement { | 909 class ReturnStatement final : public JumpStatement { |
914 public: | 910 public: |
915 DECLARE_NODE_TYPE(ReturnStatement) | 911 friend class AstNodeFactory; |
916 | 912 |
917 Expression* expression() const { return expression_; } | 913 Expression* expression() const { return expression_; } |
918 | 914 |
919 void set_expression(Expression* e) { expression_ = e; } | 915 void set_expression(Expression* e) { expression_ = e; } |
920 | 916 |
921 protected: | 917 protected: |
922 ReturnStatement(Zone* zone, Expression* expression, int pos) | 918 ReturnStatement(Zone* zone, Expression* expression, int pos) |
923 : JumpStatement(zone, pos, kReturnStatement), expression_(expression) {} | 919 : JumpStatement(zone, pos, kReturnStatement), expression_(expression) {} |
924 | 920 |
925 private: | 921 private: |
926 Expression* expression_; | 922 Expression* expression_; |
927 }; | 923 }; |
928 | 924 |
929 | 925 |
930 class WithStatement final : public Statement { | 926 class WithStatement final : public Statement { |
931 public: | 927 public: |
932 DECLARE_NODE_TYPE(WithStatement) | 928 friend class AstNodeFactory; |
933 | 929 |
934 Scope* scope() { return scope_; } | 930 Scope* scope() { return scope_; } |
935 Expression* expression() const { return expression_; } | 931 Expression* expression() const { return expression_; } |
936 void set_expression(Expression* e) { expression_ = e; } | 932 void set_expression(Expression* e) { expression_ = e; } |
937 Statement* statement() const { return statement_; } | 933 Statement* statement() const { return statement_; } |
938 void set_statement(Statement* s) { statement_ = s; } | 934 void set_statement(Statement* s) { statement_ = s; } |
939 | 935 |
940 void set_base_id(int id) { base_id_ = id; } | 936 void set_base_id(int id) { base_id_ = id; } |
941 static int num_ids() { return parent_num_ids() + 2; } | 937 static int num_ids() { return parent_num_ids() + 2; } |
942 BailoutId ToObjectId() const { return BailoutId(local_id(0)); } | 938 BailoutId ToObjectId() const { return BailoutId(local_id(0)); } |
(...skipping 19 matching lines...) Expand all Loading... | |
962 | 958 |
963 int base_id_; | 959 int base_id_; |
964 Scope* scope_; | 960 Scope* scope_; |
965 Expression* expression_; | 961 Expression* expression_; |
966 Statement* statement_; | 962 Statement* statement_; |
967 }; | 963 }; |
968 | 964 |
969 | 965 |
970 class CaseClause final : public Expression { | 966 class CaseClause final : public Expression { |
971 public: | 967 public: |
972 DECLARE_NODE_TYPE(CaseClause) | 968 friend class AstNodeFactory; |
973 | 969 |
974 bool is_default() const { return label_ == NULL; } | 970 bool is_default() const { return label_ == NULL; } |
975 Expression* label() const { | 971 Expression* label() const { |
976 CHECK(!is_default()); | 972 CHECK(!is_default()); |
977 return label_; | 973 return label_; |
978 } | 974 } |
979 void set_label(Expression* e) { label_ = e; } | 975 void set_label(Expression* e) { label_ = e; } |
980 Label* body_target() { return &body_target_; } | 976 Label* body_target() { return &body_target_; } |
981 ZoneList<Statement*>* statements() const { return statements_; } | 977 ZoneList<Statement*>* statements() const { return statements_; } |
982 | 978 |
(...skipping 14 matching lines...) Expand all Loading... | |
997 | 993 |
998 Expression* label_; | 994 Expression* label_; |
999 Label body_target_; | 995 Label body_target_; |
1000 ZoneList<Statement*>* statements_; | 996 ZoneList<Statement*>* statements_; |
1001 Type* compare_type_; | 997 Type* compare_type_; |
1002 }; | 998 }; |
1003 | 999 |
1004 | 1000 |
1005 class SwitchStatement final : public BreakableStatement { | 1001 class SwitchStatement final : public BreakableStatement { |
1006 public: | 1002 public: |
1007 DECLARE_NODE_TYPE(SwitchStatement) | 1003 friend class AstNodeFactory; |
1008 | 1004 |
1009 void Initialize(Expression* tag, ZoneList<CaseClause*>* cases) { | 1005 void Initialize(Expression* tag, ZoneList<CaseClause*>* cases) { |
1010 tag_ = tag; | 1006 tag_ = tag; |
1011 cases_ = cases; | 1007 cases_ = cases; |
1012 } | 1008 } |
1013 | 1009 |
1014 Expression* tag() const { return tag_; } | 1010 Expression* tag() const { return tag_; } |
1015 ZoneList<CaseClause*>* cases() const { return cases_; } | 1011 ZoneList<CaseClause*>* cases() const { return cases_; } |
1016 | 1012 |
1017 void set_tag(Expression* t) { tag_ = t; } | 1013 void set_tag(Expression* t) { tag_ = t; } |
(...skipping 11 matching lines...) Expand all Loading... | |
1029 }; | 1025 }; |
1030 | 1026 |
1031 | 1027 |
1032 // If-statements always have non-null references to their then- and | 1028 // If-statements always have non-null references to their then- and |
1033 // else-parts. When parsing if-statements with no explicit else-part, | 1029 // else-parts. When parsing if-statements with no explicit else-part, |
1034 // the parser implicitly creates an empty statement. Use the | 1030 // the parser implicitly creates an empty statement. Use the |
1035 // HasThenStatement() and HasElseStatement() functions to check if a | 1031 // HasThenStatement() and HasElseStatement() functions to check if a |
1036 // given if-statement has a then- or an else-part containing code. | 1032 // given if-statement has a then- or an else-part containing code. |
1037 class IfStatement final : public Statement { | 1033 class IfStatement final : public Statement { |
1038 public: | 1034 public: |
1039 DECLARE_NODE_TYPE(IfStatement) | 1035 friend class AstNodeFactory; |
1040 | 1036 |
1041 bool HasThenStatement() const { return !then_statement()->IsEmpty(); } | 1037 bool HasThenStatement() const { return !then_statement()->IsEmpty(); } |
1042 bool HasElseStatement() const { return !else_statement()->IsEmpty(); } | 1038 bool HasElseStatement() const { return !else_statement()->IsEmpty(); } |
1043 | 1039 |
1044 Expression* condition() const { return condition_; } | 1040 Expression* condition() const { return condition_; } |
1045 Statement* then_statement() const { return then_statement_; } | 1041 Statement* then_statement() const { return then_statement_; } |
1046 Statement* else_statement() const { return else_statement_; } | 1042 Statement* else_statement() const { return else_statement_; } |
1047 | 1043 |
1048 void set_condition(Expression* e) { condition_ = e; } | 1044 void set_condition(Expression* e) { condition_ = e; } |
1049 void set_then_statement(Statement* s) { then_statement_ = s; } | 1045 void set_then_statement(Statement* s) { then_statement_ = s; } |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1115 | 1111 |
1116 HandlerTable::CatchPrediction catch_prediction_; | 1112 HandlerTable::CatchPrediction catch_prediction_; |
1117 | 1113 |
1118 private: | 1114 private: |
1119 Block* try_block_; | 1115 Block* try_block_; |
1120 }; | 1116 }; |
1121 | 1117 |
1122 | 1118 |
1123 class TryCatchStatement final : public TryStatement { | 1119 class TryCatchStatement final : public TryStatement { |
1124 public: | 1120 public: |
1125 DECLARE_NODE_TYPE(TryCatchStatement) | 1121 friend class AstNodeFactory; |
1126 | 1122 |
1127 Scope* scope() { return scope_; } | 1123 Scope* scope() { return scope_; } |
1128 Variable* variable() { return variable_; } | 1124 Variable* variable() { return variable_; } |
1129 Block* catch_block() const { return catch_block_; } | 1125 Block* catch_block() const { return catch_block_; } |
1130 void set_catch_block(Block* b) { catch_block_ = b; } | 1126 void set_catch_block(Block* b) { catch_block_ = b; } |
1131 | 1127 |
1132 // The clear_pending_message flag indicates whether or not to clear the | 1128 // The clear_pending_message flag indicates whether or not to clear the |
1133 // isolate's pending exception message before executing the catch_block. In | 1129 // isolate's pending exception message before executing the catch_block. In |
1134 // the normal use case, this flag is always on because the message object | 1130 // the normal use case, this flag is always on because the message object |
1135 // is not needed anymore when entering the catch block and should not be kept | 1131 // is not needed anymore when entering the catch block and should not be kept |
(...skipping 20 matching lines...) Expand all Loading... | |
1156 | 1152 |
1157 private: | 1153 private: |
1158 Scope* scope_; | 1154 Scope* scope_; |
1159 Variable* variable_; | 1155 Variable* variable_; |
1160 Block* catch_block_; | 1156 Block* catch_block_; |
1161 }; | 1157 }; |
1162 | 1158 |
1163 | 1159 |
1164 class TryFinallyStatement final : public TryStatement { | 1160 class TryFinallyStatement final : public TryStatement { |
1165 public: | 1161 public: |
1166 DECLARE_NODE_TYPE(TryFinallyStatement) | 1162 friend class AstNodeFactory; |
1167 | 1163 |
1168 Block* finally_block() const { return finally_block_; } | 1164 Block* finally_block() const { return finally_block_; } |
1169 void set_finally_block(Block* b) { finally_block_ = b; } | 1165 void set_finally_block(Block* b) { finally_block_ = b; } |
1170 | 1166 |
1171 protected: | 1167 protected: |
1172 TryFinallyStatement(Zone* zone, Block* try_block, Block* finally_block, | 1168 TryFinallyStatement(Zone* zone, Block* try_block, Block* finally_block, |
1173 int pos) | 1169 int pos) |
1174 : TryStatement(zone, try_block, pos, kTryFinallyStatement), | 1170 : TryStatement(zone, try_block, pos, kTryFinallyStatement), |
1175 finally_block_(finally_block) {} | 1171 finally_block_(finally_block) {} |
1176 | 1172 |
1177 private: | 1173 private: |
1178 Block* finally_block_; | 1174 Block* finally_block_; |
1179 }; | 1175 }; |
1180 | 1176 |
1181 | 1177 |
1182 class DebuggerStatement final : public Statement { | 1178 class DebuggerStatement final : public Statement { |
1183 public: | 1179 public: |
1184 DECLARE_NODE_TYPE(DebuggerStatement) | 1180 friend class AstNodeFactory; |
1185 | 1181 |
1186 void set_base_id(int id) { base_id_ = id; } | 1182 void set_base_id(int id) { base_id_ = id; } |
1187 static int num_ids() { return parent_num_ids() + 1; } | 1183 static int num_ids() { return parent_num_ids() + 1; } |
1188 BailoutId DebugBreakId() const { return BailoutId(local_id(0)); } | 1184 BailoutId DebugBreakId() const { return BailoutId(local_id(0)); } |
1189 | 1185 |
1190 protected: | 1186 protected: |
1191 DebuggerStatement(Zone* zone, int pos) | 1187 DebuggerStatement(Zone* zone, int pos) |
1192 : Statement(zone, pos, kDebuggerStatement), | 1188 : Statement(zone, pos, kDebuggerStatement), |
1193 base_id_(BailoutId::None().ToInt()) {} | 1189 base_id_(BailoutId::None().ToInt()) {} |
1194 static int parent_num_ids() { return 0; } | 1190 static int parent_num_ids() { return 0; } |
1195 | 1191 |
1196 int base_id() const { | 1192 int base_id() const { |
1197 DCHECK(!BailoutId(base_id_).IsNone()); | 1193 DCHECK(!BailoutId(base_id_).IsNone()); |
1198 return base_id_; | 1194 return base_id_; |
1199 } | 1195 } |
1200 | 1196 |
1201 private: | 1197 private: |
1202 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 1198 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
1203 | 1199 |
1204 int base_id_; | 1200 int base_id_; |
1205 }; | 1201 }; |
1206 | 1202 |
1207 | 1203 |
1208 class EmptyStatement final : public Statement { | 1204 class EmptyStatement final : public Statement { |
1209 public: | 1205 public: |
1210 DECLARE_NODE_TYPE(EmptyStatement) | 1206 friend class AstNodeFactory; |
1211 | 1207 |
1212 protected: | 1208 protected: |
1213 EmptyStatement(Zone* zone, int pos) : Statement(zone, pos, kEmptyStatement) {} | 1209 EmptyStatement(Zone* zone, int pos) : Statement(zone, pos, kEmptyStatement) {} |
1214 }; | 1210 }; |
1215 | 1211 |
1216 | 1212 |
1217 // Delegates to another statement, which may be overwritten. | 1213 // Delegates to another statement, which may be overwritten. |
1218 // This was introduced to implement ES2015 Annex B3.3 for conditionally making | 1214 // This was introduced to implement ES2015 Annex B3.3 for conditionally making |
1219 // sloppy-mode block-scoped functions have a var binding, which is changed | 1215 // sloppy-mode block-scoped functions have a var binding, which is changed |
1220 // from one statement to another during parsing. | 1216 // from one statement to another during parsing. |
1221 class SloppyBlockFunctionStatement final : public Statement { | 1217 class SloppyBlockFunctionStatement final : public Statement { |
1222 public: | 1218 public: |
1223 DECLARE_NODE_TYPE(SloppyBlockFunctionStatement) | 1219 friend class AstNodeFactory; |
1224 | 1220 |
1225 Statement* statement() const { return statement_; } | 1221 Statement* statement() const { return statement_; } |
1226 void set_statement(Statement* statement) { statement_ = statement; } | 1222 void set_statement(Statement* statement) { statement_ = statement; } |
1227 Scope* scope() const { return scope_; } | 1223 Scope* scope() const { return scope_; } |
1228 | 1224 |
1229 private: | 1225 private: |
1230 SloppyBlockFunctionStatement(Zone* zone, Statement* statement, Scope* scope) | 1226 SloppyBlockFunctionStatement(Zone* zone, Statement* statement, Scope* scope) |
1231 : Statement(zone, kNoSourcePosition, kSloppyBlockFunctionStatement), | 1227 : Statement(zone, kNoSourcePosition, kSloppyBlockFunctionStatement), |
1232 statement_(statement), | 1228 statement_(statement), |
1233 scope_(scope) {} | 1229 scope_(scope) {} |
1234 | 1230 |
1235 Statement* statement_; | 1231 Statement* statement_; |
1236 Scope* const scope_; | 1232 Scope* const scope_; |
1237 }; | 1233 }; |
1238 | 1234 |
1239 | 1235 |
1240 class Literal final : public Expression { | 1236 class Literal final : public Expression { |
1241 public: | 1237 public: |
1242 DECLARE_NODE_TYPE(Literal) | 1238 friend class AstNodeFactory; |
1243 | 1239 |
1244 bool IsPropertyName() const { return value_->IsPropertyName(); } | 1240 bool IsPropertyName() const { return value_->IsPropertyName(); } |
1245 | 1241 |
1246 Handle<String> AsPropertyName() { | 1242 Handle<String> AsPropertyName() { |
1247 DCHECK(IsPropertyName()); | 1243 DCHECK(IsPropertyName()); |
1248 return Handle<String>::cast(value()); | 1244 return Handle<String>::cast(value()); |
1249 } | 1245 } |
1250 | 1246 |
1251 const AstRawString* AsRawPropertyName() { | 1247 const AstRawString* AsRawPropertyName() { |
1252 DCHECK(IsPropertyName()); | 1248 DCHECK(IsPropertyName()); |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1399 Handle<Map> receiver_type_; | 1395 Handle<Map> receiver_type_; |
1400 }; | 1396 }; |
1401 | 1397 |
1402 | 1398 |
1403 // An object literal has a boilerplate object that is used | 1399 // An object literal has a boilerplate object that is used |
1404 // for minimizing the work when constructing it at runtime. | 1400 // for minimizing the work when constructing it at runtime. |
1405 class ObjectLiteral final : public MaterializedLiteral { | 1401 class ObjectLiteral final : public MaterializedLiteral { |
1406 public: | 1402 public: |
1407 typedef ObjectLiteralProperty Property; | 1403 typedef ObjectLiteralProperty Property; |
1408 | 1404 |
1409 DECLARE_NODE_TYPE(ObjectLiteral) | 1405 friend class AstNodeFactory; |
1410 | 1406 |
1411 Handle<FixedArray> constant_properties() const { | 1407 Handle<FixedArray> constant_properties() const { |
1412 return constant_properties_; | 1408 return constant_properties_; |
1413 } | 1409 } |
1414 int properties_count() const { return constant_properties_->length() / 2; } | 1410 int properties_count() const { return constant_properties_->length() / 2; } |
1415 ZoneList<Property*>* properties() const { return properties_; } | 1411 ZoneList<Property*>* properties() const { return properties_; } |
1416 bool fast_elements() const { return fast_elements_; } | 1412 bool fast_elements() const { return fast_elements_; } |
1417 bool may_store_doubles() const { return may_store_doubles_; } | 1413 bool may_store_doubles() const { return may_store_doubles_; } |
1418 bool has_elements() const { return has_elements_; } | 1414 bool has_elements() const { return has_elements_; } |
1419 bool has_shallow_properties() const { | 1415 bool has_shallow_properties() const { |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1519 } | 1515 } |
1520 | 1516 |
1521 private: | 1517 private: |
1522 Zone* zone_; | 1518 Zone* zone_; |
1523 }; | 1519 }; |
1524 | 1520 |
1525 | 1521 |
1526 // Node for capturing a regexp literal. | 1522 // Node for capturing a regexp literal. |
1527 class RegExpLiteral final : public MaterializedLiteral { | 1523 class RegExpLiteral final : public MaterializedLiteral { |
1528 public: | 1524 public: |
1529 DECLARE_NODE_TYPE(RegExpLiteral) | 1525 friend class AstNodeFactory; |
1530 | 1526 |
1531 Handle<String> pattern() const { return pattern_->string(); } | 1527 Handle<String> pattern() const { return pattern_->string(); } |
1532 int flags() const { return flags_; } | 1528 int flags() const { return flags_; } |
1533 | 1529 |
1534 protected: | 1530 protected: |
1535 RegExpLiteral(Zone* zone, const AstRawString* pattern, int flags, | 1531 RegExpLiteral(Zone* zone, const AstRawString* pattern, int flags, |
1536 int literal_index, int pos) | 1532 int literal_index, int pos) |
1537 : MaterializedLiteral(zone, literal_index, pos, kRegExpLiteral), | 1533 : MaterializedLiteral(zone, literal_index, pos, kRegExpLiteral), |
1538 flags_(flags), | 1534 flags_(flags), |
1539 pattern_(pattern) { | 1535 pattern_(pattern) { |
1540 set_depth(1); | 1536 set_depth(1); |
1541 } | 1537 } |
1542 | 1538 |
1543 private: | 1539 private: |
1544 int const flags_; | 1540 int const flags_; |
1545 const AstRawString* const pattern_; | 1541 const AstRawString* const pattern_; |
1546 }; | 1542 }; |
1547 | 1543 |
1548 | 1544 |
1549 // An array literal has a literals object that is used | 1545 // An array literal has a literals object that is used |
1550 // for minimizing the work when constructing it at runtime. | 1546 // for minimizing the work when constructing it at runtime. |
1551 class ArrayLiteral final : public MaterializedLiteral { | 1547 class ArrayLiteral final : public MaterializedLiteral { |
1552 public: | 1548 public: |
1553 DECLARE_NODE_TYPE(ArrayLiteral) | 1549 friend class AstNodeFactory; |
1554 | 1550 |
1555 Handle<FixedArray> constant_elements() const { return constant_elements_; } | 1551 Handle<FixedArray> constant_elements() const { return constant_elements_; } |
1556 ElementsKind constant_elements_kind() const { | 1552 ElementsKind constant_elements_kind() const { |
1557 DCHECK_EQ(2, constant_elements_->length()); | 1553 DCHECK_EQ(2, constant_elements_->length()); |
1558 return static_cast<ElementsKind>( | 1554 return static_cast<ElementsKind>( |
1559 Smi::cast(constant_elements_->get(0))->value()); | 1555 Smi::cast(constant_elements_->get(0))->value()); |
1560 } | 1556 } |
1561 | 1557 |
1562 ZoneList<Expression*>* values() const { return values_; } | 1558 ZoneList<Expression*>* values() const { return values_; } |
1563 | 1559 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1618 | 1614 |
1619 int first_spread_index_; | 1615 int first_spread_index_; |
1620 FeedbackVectorSlot literal_slot_; | 1616 FeedbackVectorSlot literal_slot_; |
1621 Handle<FixedArray> constant_elements_; | 1617 Handle<FixedArray> constant_elements_; |
1622 ZoneList<Expression*>* values_; | 1618 ZoneList<Expression*>* values_; |
1623 }; | 1619 }; |
1624 | 1620 |
1625 | 1621 |
1626 class VariableProxy final : public Expression { | 1622 class VariableProxy final : public Expression { |
1627 public: | 1623 public: |
1628 DECLARE_NODE_TYPE(VariableProxy) | 1624 friend class AstNodeFactory; |
1629 | 1625 |
1630 bool IsValidReferenceExpression() const { | 1626 bool IsValidReferenceExpression() const { |
1631 return !is_this() && !is_new_target(); | 1627 return !is_this() && !is_new_target(); |
1632 } | 1628 } |
1633 | 1629 |
1634 bool IsArguments() const { return is_resolved() && var()->is_arguments(); } | 1630 bool IsArguments() const { return is_resolved() && var()->is_arguments(); } |
1635 | 1631 |
1636 Handle<String> name() const { return raw_name()->string(); } | 1632 Handle<String> name() const { return raw_name()->string(); } |
1637 const AstRawString* raw_name() const { | 1633 const AstRawString* raw_name() const { |
1638 return is_resolved() ? var_->raw_name() : raw_name_; | 1634 return is_resolved() ? var_->raw_name() : raw_name_; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1722 VARIABLE, | 1718 VARIABLE, |
1723 NAMED_PROPERTY, | 1719 NAMED_PROPERTY, |
1724 KEYED_PROPERTY, | 1720 KEYED_PROPERTY, |
1725 NAMED_SUPER_PROPERTY, | 1721 NAMED_SUPER_PROPERTY, |
1726 KEYED_SUPER_PROPERTY | 1722 KEYED_SUPER_PROPERTY |
1727 }; | 1723 }; |
1728 | 1724 |
1729 | 1725 |
1730 class Property final : public Expression { | 1726 class Property final : public Expression { |
1731 public: | 1727 public: |
1732 DECLARE_NODE_TYPE(Property) | 1728 friend class AstNodeFactory; |
1733 | 1729 |
1734 bool IsValidReferenceExpression() const { return true; } | 1730 bool IsValidReferenceExpression() const { return true; } |
1735 | 1731 |
1736 Expression* obj() const { return obj_; } | 1732 Expression* obj() const { return obj_; } |
1737 Expression* key() const { return key_; } | 1733 Expression* key() const { return key_; } |
1738 | 1734 |
1739 void set_obj(Expression* e) { obj_ = e; } | 1735 void set_obj(Expression* e) { obj_ = e; } |
1740 void set_key(Expression* e) { key_ = e; } | 1736 void set_key(Expression* e) { key_ = e; } |
1741 | 1737 |
1742 static int num_ids() { return parent_num_ids() + 1; } | 1738 static int num_ids() { return parent_num_ids() + 1; } |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1816 uint8_t bit_field_; | 1812 uint8_t bit_field_; |
1817 FeedbackVectorSlot property_feedback_slot_; | 1813 FeedbackVectorSlot property_feedback_slot_; |
1818 Expression* obj_; | 1814 Expression* obj_; |
1819 Expression* key_; | 1815 Expression* key_; |
1820 SmallMapList receiver_types_; | 1816 SmallMapList receiver_types_; |
1821 }; | 1817 }; |
1822 | 1818 |
1823 | 1819 |
1824 class Call final : public Expression { | 1820 class Call final : public Expression { |
1825 public: | 1821 public: |
1826 DECLARE_NODE_TYPE(Call) | 1822 friend class AstNodeFactory; |
1827 | 1823 |
1828 Expression* expression() const { return expression_; } | 1824 Expression* expression() const { return expression_; } |
1829 ZoneList<Expression*>* arguments() const { return arguments_; } | 1825 ZoneList<Expression*>* arguments() const { return arguments_; } |
1830 | 1826 |
1831 void set_expression(Expression* e) { expression_ = e; } | 1827 void set_expression(Expression* e) { expression_ = e; } |
1832 | 1828 |
1833 // Type feedback information. | 1829 // Type feedback information. |
1834 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, | 1830 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, |
1835 FeedbackVectorSlotCache* cache); | 1831 FeedbackVectorSlotCache* cache); |
1836 | 1832 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1938 FeedbackVectorSlot stub_slot_; | 1934 FeedbackVectorSlot stub_slot_; |
1939 Expression* expression_; | 1935 Expression* expression_; |
1940 ZoneList<Expression*>* arguments_; | 1936 ZoneList<Expression*>* arguments_; |
1941 Handle<JSFunction> target_; | 1937 Handle<JSFunction> target_; |
1942 Handle<AllocationSite> allocation_site_; | 1938 Handle<AllocationSite> allocation_site_; |
1943 }; | 1939 }; |
1944 | 1940 |
1945 | 1941 |
1946 class CallNew final : public Expression { | 1942 class CallNew final : public Expression { |
1947 public: | 1943 public: |
1948 DECLARE_NODE_TYPE(CallNew) | 1944 friend class AstNodeFactory; |
1949 | 1945 |
1950 Expression* expression() const { return expression_; } | 1946 Expression* expression() const { return expression_; } |
1951 ZoneList<Expression*>* arguments() const { return arguments_; } | 1947 ZoneList<Expression*>* arguments() const { return arguments_; } |
1952 | 1948 |
1953 void set_expression(Expression* e) { expression_ = e; } | 1949 void set_expression(Expression* e) { expression_ = e; } |
1954 | 1950 |
1955 // Type feedback information. | 1951 // Type feedback information. |
1956 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, | 1952 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, |
1957 FeedbackVectorSlotCache* cache) { | 1953 FeedbackVectorSlotCache* cache) { |
1958 callnew_feedback_slot_ = spec->AddGeneralSlot(); | 1954 callnew_feedback_slot_ = spec->AddGeneralSlot(); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2007 Handle<AllocationSite> allocation_site_; | 2003 Handle<AllocationSite> allocation_site_; |
2008 }; | 2004 }; |
2009 | 2005 |
2010 | 2006 |
2011 // The CallRuntime class does not represent any official JavaScript | 2007 // The CallRuntime class does not represent any official JavaScript |
2012 // language construct. Instead it is used to call a C or JS function | 2008 // language construct. Instead it is used to call a C or JS function |
2013 // with a set of arguments. This is used from the builtins that are | 2009 // with a set of arguments. This is used from the builtins that are |
2014 // implemented in JavaScript (see "v8natives.js"). | 2010 // implemented in JavaScript (see "v8natives.js"). |
2015 class CallRuntime final : public Expression { | 2011 class CallRuntime final : public Expression { |
2016 public: | 2012 public: |
2017 DECLARE_NODE_TYPE(CallRuntime) | 2013 friend class AstNodeFactory; |
2018 | 2014 |
2019 ZoneList<Expression*>* arguments() const { return arguments_; } | 2015 ZoneList<Expression*>* arguments() const { return arguments_; } |
2020 bool is_jsruntime() const { return function_ == NULL; } | 2016 bool is_jsruntime() const { return function_ == NULL; } |
2021 | 2017 |
2022 int context_index() const { | 2018 int context_index() const { |
2023 DCHECK(is_jsruntime()); | 2019 DCHECK(is_jsruntime()); |
2024 return context_index_; | 2020 return context_index_; |
2025 } | 2021 } |
2026 const Runtime::Function* function() const { | 2022 const Runtime::Function* function() const { |
2027 DCHECK(!is_jsruntime()); | 2023 DCHECK(!is_jsruntime()); |
(...skipping 27 matching lines...) Expand all Loading... | |
2055 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 2051 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
2056 | 2052 |
2057 int context_index_; | 2053 int context_index_; |
2058 const Runtime::Function* function_; | 2054 const Runtime::Function* function_; |
2059 ZoneList<Expression*>* arguments_; | 2055 ZoneList<Expression*>* arguments_; |
2060 }; | 2056 }; |
2061 | 2057 |
2062 | 2058 |
2063 class UnaryOperation final : public Expression { | 2059 class UnaryOperation final : public Expression { |
2064 public: | 2060 public: |
2065 DECLARE_NODE_TYPE(UnaryOperation) | 2061 friend class AstNodeFactory; |
2066 | 2062 |
2067 Token::Value op() const { return op_; } | 2063 Token::Value op() const { return op_; } |
2068 Expression* expression() const { return expression_; } | 2064 Expression* expression() const { return expression_; } |
2069 void set_expression(Expression* e) { expression_ = e; } | 2065 void set_expression(Expression* e) { expression_ = e; } |
2070 | 2066 |
2071 // For unary not (Token::NOT), the AST ids where true and false will | 2067 // For unary not (Token::NOT), the AST ids where true and false will |
2072 // actually be materialized, respectively. | 2068 // actually be materialized, respectively. |
2073 static int num_ids() { return parent_num_ids() + 2; } | 2069 static int num_ids() { return parent_num_ids() + 2; } |
2074 BailoutId MaterializeTrueId() const { return BailoutId(local_id(0)); } | 2070 BailoutId MaterializeTrueId() const { return BailoutId(local_id(0)); } |
2075 BailoutId MaterializeFalseId() const { return BailoutId(local_id(1)); } | 2071 BailoutId MaterializeFalseId() const { return BailoutId(local_id(1)); } |
(...skipping 12 matching lines...) Expand all Loading... | |
2088 private: | 2084 private: |
2089 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 2085 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
2090 | 2086 |
2091 Token::Value op_; | 2087 Token::Value op_; |
2092 Expression* expression_; | 2088 Expression* expression_; |
2093 }; | 2089 }; |
2094 | 2090 |
2095 | 2091 |
2096 class BinaryOperation final : public Expression { | 2092 class BinaryOperation final : public Expression { |
2097 public: | 2093 public: |
2098 DECLARE_NODE_TYPE(BinaryOperation) | 2094 friend class AstNodeFactory; |
2099 | 2095 |
2100 Token::Value op() const { return static_cast<Token::Value>(op_); } | 2096 Token::Value op() const { return static_cast<Token::Value>(op_); } |
2101 Expression* left() const { return left_; } | 2097 Expression* left() const { return left_; } |
2102 void set_left(Expression* e) { left_ = e; } | 2098 void set_left(Expression* e) { left_ = e; } |
2103 Expression* right() const { return right_; } | 2099 Expression* right() const { return right_; } |
2104 void set_right(Expression* e) { right_ = e; } | 2100 void set_right(Expression* e) { right_ = e; } |
2105 Handle<AllocationSite> allocation_site() const { return allocation_site_; } | 2101 Handle<AllocationSite> allocation_site() const { return allocation_site_; } |
2106 void set_allocation_site(Handle<AllocationSite> allocation_site) { | 2102 void set_allocation_site(Handle<AllocationSite> allocation_site) { |
2107 allocation_site_ = allocation_site; | 2103 allocation_site_ = allocation_site; |
2108 } | 2104 } |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2158 bool has_fixed_right_arg_; | 2154 bool has_fixed_right_arg_; |
2159 int fixed_right_arg_value_; | 2155 int fixed_right_arg_value_; |
2160 Expression* left_; | 2156 Expression* left_; |
2161 Expression* right_; | 2157 Expression* right_; |
2162 Handle<AllocationSite> allocation_site_; | 2158 Handle<AllocationSite> allocation_site_; |
2163 }; | 2159 }; |
2164 | 2160 |
2165 | 2161 |
2166 class CountOperation final : public Expression { | 2162 class CountOperation final : public Expression { |
2167 public: | 2163 public: |
2168 DECLARE_NODE_TYPE(CountOperation) | 2164 friend class AstNodeFactory; |
2169 | 2165 |
2170 bool is_prefix() const { return IsPrefixField::decode(bit_field_); } | 2166 bool is_prefix() const { return IsPrefixField::decode(bit_field_); } |
2171 bool is_postfix() const { return !is_prefix(); } | 2167 bool is_postfix() const { return !is_prefix(); } |
2172 | 2168 |
2173 Token::Value op() const { return TokenField::decode(bit_field_); } | 2169 Token::Value op() const { return TokenField::decode(bit_field_); } |
2174 Token::Value binary_op() { | 2170 Token::Value binary_op() { |
2175 return (op() == Token::INC) ? Token::ADD : Token::SUB; | 2171 return (op() == Token::INC) ? Token::ADD : Token::SUB; |
2176 } | 2172 } |
2177 | 2173 |
2178 Expression* expression() const { return expression_; } | 2174 Expression* expression() const { return expression_; } |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2231 uint16_t bit_field_; | 2227 uint16_t bit_field_; |
2232 FeedbackVectorSlot slot_; | 2228 FeedbackVectorSlot slot_; |
2233 Type* type_; | 2229 Type* type_; |
2234 Expression* expression_; | 2230 Expression* expression_; |
2235 SmallMapList receiver_types_; | 2231 SmallMapList receiver_types_; |
2236 }; | 2232 }; |
2237 | 2233 |
2238 | 2234 |
2239 class CompareOperation final : public Expression { | 2235 class CompareOperation final : public Expression { |
2240 public: | 2236 public: |
2241 DECLARE_NODE_TYPE(CompareOperation) | 2237 friend class AstNodeFactory; |
2242 | 2238 |
2243 Token::Value op() const { return op_; } | 2239 Token::Value op() const { return op_; } |
2244 Expression* left() const { return left_; } | 2240 Expression* left() const { return left_; } |
2245 Expression* right() const { return right_; } | 2241 Expression* right() const { return right_; } |
2246 | 2242 |
2247 void set_left(Expression* e) { left_ = e; } | 2243 void set_left(Expression* e) { left_ = e; } |
2248 void set_right(Expression* e) { right_ = e; } | 2244 void set_right(Expression* e) { right_ = e; } |
2249 | 2245 |
2250 // Type feedback information. | 2246 // Type feedback information. |
2251 static int num_ids() { return parent_num_ids() + 1; } | 2247 static int num_ids() { return parent_num_ids() + 1; } |
(...skipping 26 matching lines...) Expand all Loading... | |
2278 Token::Value op_; | 2274 Token::Value op_; |
2279 Expression* left_; | 2275 Expression* left_; |
2280 Expression* right_; | 2276 Expression* right_; |
2281 | 2277 |
2282 Type* combined_type_; | 2278 Type* combined_type_; |
2283 }; | 2279 }; |
2284 | 2280 |
2285 | 2281 |
2286 class Spread final : public Expression { | 2282 class Spread final : public Expression { |
2287 public: | 2283 public: |
2288 DECLARE_NODE_TYPE(Spread) | 2284 friend class AstNodeFactory; |
2289 | 2285 |
2290 Expression* expression() const { return expression_; } | 2286 Expression* expression() const { return expression_; } |
2291 void set_expression(Expression* e) { expression_ = e; } | 2287 void set_expression(Expression* e) { expression_ = e; } |
2292 | 2288 |
2293 int expression_position() const { return expr_pos_; } | 2289 int expression_position() const { return expr_pos_; } |
2294 | 2290 |
2295 static int num_ids() { return parent_num_ids(); } | 2291 static int num_ids() { return parent_num_ids(); } |
2296 | 2292 |
2297 protected: | 2293 protected: |
2298 Spread(Zone* zone, Expression* expression, int pos, int expr_pos) | 2294 Spread(Zone* zone, Expression* expression, int pos, int expr_pos) |
2299 : Expression(zone, pos, kSpread), | 2295 : Expression(zone, pos, kSpread), |
2300 expr_pos_(expr_pos), | 2296 expr_pos_(expr_pos), |
2301 expression_(expression) {} | 2297 expression_(expression) {} |
2302 static int parent_num_ids() { return Expression::num_ids(); } | 2298 static int parent_num_ids() { return Expression::num_ids(); } |
2303 | 2299 |
2304 private: | 2300 private: |
2305 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 2301 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
2306 | 2302 |
2307 int expr_pos_; | 2303 int expr_pos_; |
2308 Expression* expression_; | 2304 Expression* expression_; |
2309 }; | 2305 }; |
2310 | 2306 |
2311 | 2307 |
2312 class Conditional final : public Expression { | 2308 class Conditional final : public Expression { |
2313 public: | 2309 public: |
2314 DECLARE_NODE_TYPE(Conditional) | 2310 friend class AstNodeFactory; |
2315 | 2311 |
2316 Expression* condition() const { return condition_; } | 2312 Expression* condition() const { return condition_; } |
2317 Expression* then_expression() const { return then_expression_; } | 2313 Expression* then_expression() const { return then_expression_; } |
2318 Expression* else_expression() const { return else_expression_; } | 2314 Expression* else_expression() const { return else_expression_; } |
2319 | 2315 |
2320 void set_condition(Expression* e) { condition_ = e; } | 2316 void set_condition(Expression* e) { condition_ = e; } |
2321 void set_then_expression(Expression* e) { then_expression_ = e; } | 2317 void set_then_expression(Expression* e) { then_expression_ = e; } |
2322 void set_else_expression(Expression* e) { else_expression_ = e; } | 2318 void set_else_expression(Expression* e) { else_expression_ = e; } |
2323 | 2319 |
2324 void MarkTail() { | 2320 void MarkTail() { |
(...skipping 18 matching lines...) Expand all Loading... | |
2343 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 2339 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
2344 | 2340 |
2345 Expression* condition_; | 2341 Expression* condition_; |
2346 Expression* then_expression_; | 2342 Expression* then_expression_; |
2347 Expression* else_expression_; | 2343 Expression* else_expression_; |
2348 }; | 2344 }; |
2349 | 2345 |
2350 | 2346 |
2351 class Assignment final : public Expression { | 2347 class Assignment final : public Expression { |
2352 public: | 2348 public: |
2353 DECLARE_NODE_TYPE(Assignment) | 2349 friend class AstNodeFactory; |
2354 | 2350 |
2355 Assignment* AsSimpleAssignment() { return !is_compound() ? this : NULL; } | 2351 Assignment* AsSimpleAssignment() { return !is_compound() ? this : NULL; } |
2356 | 2352 |
2357 Token::Value binary_op() const; | 2353 Token::Value binary_op() const; |
2358 | 2354 |
2359 Token::Value op() const { return TokenField::decode(bit_field_); } | 2355 Token::Value op() const { return TokenField::decode(bit_field_); } |
2360 Expression* target() const { return target_; } | 2356 Expression* target() const { return target_; } |
2361 Expression* value() const { return value_; } | 2357 Expression* value() const { return value_; } |
2362 | 2358 |
2363 void set_target(Expression* e) { target_ = e; } | 2359 void set_target(Expression* e) { target_ = e; } |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2436 // | 2432 // |
2437 // 1. IsRewritableExpression and AsRewritableExpression behave as usual. | 2433 // 1. IsRewritableExpression and AsRewritableExpression behave as usual. |
2438 // 2. All other Is* and As* methods are practically delegated to the | 2434 // 2. All other Is* and As* methods are practically delegated to the |
2439 // wrapped node, i.e. IsArrayLiteral() will return true iff the | 2435 // wrapped node, i.e. IsArrayLiteral() will return true iff the |
2440 // wrapped node is an array literal. | 2436 // wrapped node is an array literal. |
2441 // | 2437 // |
2442 // Furthermore, an invariant that should be respected is that the wrapped | 2438 // Furthermore, an invariant that should be respected is that the wrapped |
2443 // node is not a RewritableExpression. | 2439 // node is not a RewritableExpression. |
2444 class RewritableExpression : public Expression { | 2440 class RewritableExpression : public Expression { |
2445 public: | 2441 public: |
2446 DECLARE_NODE_TYPE(RewritableExpression) | 2442 friend class AstNodeFactory; |
2447 | 2443 |
2448 Expression* expression() const { return expr_; } | 2444 Expression* expression() const { return expr_; } |
2449 bool is_rewritten() const { return is_rewritten_; } | 2445 bool is_rewritten() const { return is_rewritten_; } |
2450 | 2446 |
2451 void Rewrite(Expression* new_expression) { | 2447 void Rewrite(Expression* new_expression) { |
2452 DCHECK(!is_rewritten()); | 2448 DCHECK(!is_rewritten()); |
2453 DCHECK_NOT_NULL(new_expression); | 2449 DCHECK_NOT_NULL(new_expression); |
2454 DCHECK(!new_expression->IsRewritableExpression()); | 2450 DCHECK(!new_expression->IsRewritableExpression()); |
2455 expr_ = new_expression; | 2451 expr_ = new_expression; |
2456 is_rewritten_ = true; | 2452 is_rewritten_ = true; |
(...skipping 14 matching lines...) Expand all Loading... | |
2471 | 2467 |
2472 bool is_rewritten_; | 2468 bool is_rewritten_; |
2473 Expression* expr_; | 2469 Expression* expr_; |
2474 }; | 2470 }; |
2475 | 2471 |
2476 // Our Yield is different from the JS yield in that it "returns" its argument as | 2472 // Our Yield is different from the JS yield in that it "returns" its argument as |
2477 // is, without wrapping it in an iterator result object. Such wrapping, if | 2473 // is, without wrapping it in an iterator result object. Such wrapping, if |
2478 // desired, must be done beforehand (see the parser). | 2474 // desired, must be done beforehand (see the parser). |
2479 class Yield final : public Expression { | 2475 class Yield final : public Expression { |
2480 public: | 2476 public: |
2481 DECLARE_NODE_TYPE(Yield) | 2477 friend class AstNodeFactory; |
2482 | 2478 |
2483 enum OnException { kOnExceptionThrow, kOnExceptionRethrow }; | 2479 enum OnException { kOnExceptionThrow, kOnExceptionRethrow }; |
2484 | 2480 |
2485 Expression* generator_object() const { return generator_object_; } | 2481 Expression* generator_object() const { return generator_object_; } |
2486 Expression* expression() const { return expression_; } | 2482 Expression* expression() const { return expression_; } |
2487 bool rethrow_on_exception() const { | 2483 bool rethrow_on_exception() const { |
2488 return on_exception_ == kOnExceptionRethrow; | 2484 return on_exception_ == kOnExceptionRethrow; |
2489 } | 2485 } |
2490 int yield_id() const { return yield_id_; } | 2486 int yield_id() const { return yield_id_; } |
2491 | 2487 |
(...skipping 13 matching lines...) Expand all Loading... | |
2505 private: | 2501 private: |
2506 OnException on_exception_; | 2502 OnException on_exception_; |
2507 int yield_id_; | 2503 int yield_id_; |
2508 Expression* generator_object_; | 2504 Expression* generator_object_; |
2509 Expression* expression_; | 2505 Expression* expression_; |
2510 }; | 2506 }; |
2511 | 2507 |
2512 | 2508 |
2513 class Throw final : public Expression { | 2509 class Throw final : public Expression { |
2514 public: | 2510 public: |
2515 DECLARE_NODE_TYPE(Throw) | 2511 friend class AstNodeFactory; |
2516 | 2512 |
2517 Expression* exception() const { return exception_; } | 2513 Expression* exception() const { return exception_; } |
2518 void set_exception(Expression* e) { exception_ = e; } | 2514 void set_exception(Expression* e) { exception_ = e; } |
2519 | 2515 |
2520 protected: | 2516 protected: |
2521 Throw(Zone* zone, Expression* exception, int pos) | 2517 Throw(Zone* zone, Expression* exception, int pos) |
2522 : Expression(zone, pos, kThrow), exception_(exception) {} | 2518 : Expression(zone, pos, kThrow), exception_(exception) {} |
2523 | 2519 |
2524 private: | 2520 private: |
2525 Expression* exception_; | 2521 Expression* exception_; |
2526 }; | 2522 }; |
2527 | 2523 |
2528 | 2524 |
2529 class FunctionLiteral final : public Expression { | 2525 class FunctionLiteral final : public Expression { |
2530 public: | 2526 public: |
2531 enum FunctionType { | 2527 enum FunctionType { |
2532 kAnonymousExpression, | 2528 kAnonymousExpression, |
2533 kNamedExpression, | 2529 kNamedExpression, |
2534 kDeclaration, | 2530 kDeclaration, |
2535 kAccessorOrMethod | 2531 kAccessorOrMethod |
2536 }; | 2532 }; |
2537 | 2533 |
2538 enum ParameterFlag { kNoDuplicateParameters, kHasDuplicateParameters }; | 2534 enum ParameterFlag { kNoDuplicateParameters, kHasDuplicateParameters }; |
2539 | 2535 |
2540 enum EagerCompileHint { kShouldEagerCompile, kShouldLazyCompile }; | 2536 enum EagerCompileHint { kShouldEagerCompile, kShouldLazyCompile }; |
2541 | 2537 |
2542 DECLARE_NODE_TYPE(FunctionLiteral) | 2538 friend class AstNodeFactory; |
2543 | 2539 |
2544 Handle<String> name() const { return raw_name_->string(); } | 2540 Handle<String> name() const { return raw_name_->string(); } |
2545 const AstString* raw_name() const { return raw_name_; } | 2541 const AstString* raw_name() const { return raw_name_; } |
2546 void set_raw_name(const AstString* name) { raw_name_ = name; } | 2542 void set_raw_name(const AstString* name) { raw_name_ = name; } |
2547 Scope* scope() const { return scope_; } | 2543 Scope* scope() const { return scope_; } |
2548 ZoneList<Statement*>* body() const { return body_; } | 2544 ZoneList<Statement*>* body() const { return body_; } |
2549 void set_function_token_position(int pos) { function_token_position_ = pos; } | 2545 void set_function_token_position(int pos) { function_token_position_ = pos; } |
2550 int function_token_position() const { return function_token_position_; } | 2546 int function_token_position() const { return function_token_position_; } |
2551 int start_position() const; | 2547 int start_position() const; |
2552 int end_position() const; | 2548 int end_position() const; |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2717 const AstString* raw_inferred_name_; | 2713 const AstString* raw_inferred_name_; |
2718 Handle<String> inferred_name_; | 2714 Handle<String> inferred_name_; |
2719 AstProperties ast_properties_; | 2715 AstProperties ast_properties_; |
2720 }; | 2716 }; |
2721 | 2717 |
2722 | 2718 |
2723 class ClassLiteral final : public Expression { | 2719 class ClassLiteral final : public Expression { |
2724 public: | 2720 public: |
2725 typedef ObjectLiteralProperty Property; | 2721 typedef ObjectLiteralProperty Property; |
2726 | 2722 |
2727 DECLARE_NODE_TYPE(ClassLiteral) | 2723 friend class AstNodeFactory; |
2728 | 2724 |
2729 VariableProxy* class_variable_proxy() const { return class_variable_proxy_; } | 2725 VariableProxy* class_variable_proxy() const { return class_variable_proxy_; } |
2730 Expression* extends() const { return extends_; } | 2726 Expression* extends() const { return extends_; } |
2731 void set_extends(Expression* e) { extends_ = e; } | 2727 void set_extends(Expression* e) { extends_ = e; } |
2732 FunctionLiteral* constructor() const { return constructor_; } | 2728 FunctionLiteral* constructor() const { return constructor_; } |
2733 void set_constructor(FunctionLiteral* f) { constructor_ = f; } | 2729 void set_constructor(FunctionLiteral* f) { constructor_ = f; } |
2734 ZoneList<Property*>* properties() const { return properties_; } | 2730 ZoneList<Property*>* properties() const { return properties_; } |
2735 int start_position() const { return position(); } | 2731 int start_position() const { return position(); } |
2736 int end_position() const { return end_position_; } | 2732 int end_position() const { return end_position_; } |
2737 | 2733 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2781 FeedbackVectorSlot proxy_slot_; | 2777 FeedbackVectorSlot proxy_slot_; |
2782 VariableProxy* class_variable_proxy_; | 2778 VariableProxy* class_variable_proxy_; |
2783 Expression* extends_; | 2779 Expression* extends_; |
2784 FunctionLiteral* constructor_; | 2780 FunctionLiteral* constructor_; |
2785 ZoneList<Property*>* properties_; | 2781 ZoneList<Property*>* properties_; |
2786 }; | 2782 }; |
2787 | 2783 |
2788 | 2784 |
2789 class NativeFunctionLiteral final : public Expression { | 2785 class NativeFunctionLiteral final : public Expression { |
2790 public: | 2786 public: |
2791 DECLARE_NODE_TYPE(NativeFunctionLiteral) | 2787 friend class AstNodeFactory; |
2792 | 2788 |
2793 Handle<String> name() const { return name_->string(); } | 2789 Handle<String> name() const { return name_->string(); } |
2794 v8::Extension* extension() const { return extension_; } | 2790 v8::Extension* extension() const { return extension_; } |
2795 | 2791 |
2796 protected: | 2792 protected: |
2797 NativeFunctionLiteral(Zone* zone, const AstRawString* name, | 2793 NativeFunctionLiteral(Zone* zone, const AstRawString* name, |
2798 v8::Extension* extension, int pos) | 2794 v8::Extension* extension, int pos) |
2799 : Expression(zone, pos, kNativeFunctionLiteral), | 2795 : Expression(zone, pos, kNativeFunctionLiteral), |
2800 name_(name), | 2796 name_(name), |
2801 extension_(extension) {} | 2797 extension_(extension) {} |
2802 | 2798 |
2803 private: | 2799 private: |
2804 const AstRawString* name_; | 2800 const AstRawString* name_; |
2805 v8::Extension* extension_; | 2801 v8::Extension* extension_; |
2806 }; | 2802 }; |
2807 | 2803 |
2808 | 2804 |
2809 class ThisFunction final : public Expression { | 2805 class ThisFunction final : public Expression { |
2810 public: | 2806 public: |
2811 DECLARE_NODE_TYPE(ThisFunction) | 2807 friend class AstNodeFactory; |
2812 | 2808 |
2813 protected: | 2809 protected: |
2814 ThisFunction(Zone* zone, int pos) : Expression(zone, pos, kThisFunction) {} | 2810 ThisFunction(Zone* zone, int pos) : Expression(zone, pos, kThisFunction) {} |
2815 }; | 2811 }; |
2816 | 2812 |
2817 | 2813 |
2818 class SuperPropertyReference final : public Expression { | 2814 class SuperPropertyReference final : public Expression { |
2819 public: | 2815 public: |
2820 DECLARE_NODE_TYPE(SuperPropertyReference) | 2816 friend class AstNodeFactory; |
2821 | 2817 |
2822 VariableProxy* this_var() const { return this_var_; } | 2818 VariableProxy* this_var() const { return this_var_; } |
2823 void set_this_var(VariableProxy* v) { this_var_ = v; } | 2819 void set_this_var(VariableProxy* v) { this_var_ = v; } |
2824 Expression* home_object() const { return home_object_; } | 2820 Expression* home_object() const { return home_object_; } |
2825 void set_home_object(Expression* e) { home_object_ = e; } | 2821 void set_home_object(Expression* e) { home_object_ = e; } |
2826 | 2822 |
2827 protected: | 2823 protected: |
2828 SuperPropertyReference(Zone* zone, VariableProxy* this_var, | 2824 SuperPropertyReference(Zone* zone, VariableProxy* this_var, |
2829 Expression* home_object, int pos) | 2825 Expression* home_object, int pos) |
2830 : Expression(zone, pos, kSuperPropertyReference), | 2826 : Expression(zone, pos, kSuperPropertyReference), |
2831 this_var_(this_var), | 2827 this_var_(this_var), |
2832 home_object_(home_object) { | 2828 home_object_(home_object) { |
2833 DCHECK(this_var->is_this()); | 2829 DCHECK(this_var->is_this()); |
2834 DCHECK(home_object->IsProperty()); | 2830 DCHECK(home_object->IsProperty()); |
2835 } | 2831 } |
2836 | 2832 |
2837 private: | 2833 private: |
2838 VariableProxy* this_var_; | 2834 VariableProxy* this_var_; |
2839 Expression* home_object_; | 2835 Expression* home_object_; |
2840 }; | 2836 }; |
2841 | 2837 |
2842 | 2838 |
2843 class SuperCallReference final : public Expression { | 2839 class SuperCallReference final : public Expression { |
2844 public: | 2840 public: |
2845 DECLARE_NODE_TYPE(SuperCallReference) | 2841 friend class AstNodeFactory; |
2846 | 2842 |
2847 VariableProxy* this_var() const { return this_var_; } | 2843 VariableProxy* this_var() const { return this_var_; } |
2848 void set_this_var(VariableProxy* v) { this_var_ = v; } | 2844 void set_this_var(VariableProxy* v) { this_var_ = v; } |
2849 VariableProxy* new_target_var() const { return new_target_var_; } | 2845 VariableProxy* new_target_var() const { return new_target_var_; } |
2850 void set_new_target_var(VariableProxy* v) { new_target_var_ = v; } | 2846 void set_new_target_var(VariableProxy* v) { new_target_var_ = v; } |
2851 VariableProxy* this_function_var() const { return this_function_var_; } | 2847 VariableProxy* this_function_var() const { return this_function_var_; } |
2852 void set_this_function_var(VariableProxy* v) { this_function_var_ = v; } | 2848 void set_this_function_var(VariableProxy* v) { this_function_var_ = v; } |
2853 | 2849 |
2854 protected: | 2850 protected: |
2855 SuperCallReference(Zone* zone, VariableProxy* this_var, | 2851 SuperCallReference(Zone* zone, VariableProxy* this_var, |
(...skipping 12 matching lines...) Expand all Loading... | |
2868 VariableProxy* this_var_; | 2864 VariableProxy* this_var_; |
2869 VariableProxy* new_target_var_; | 2865 VariableProxy* new_target_var_; |
2870 VariableProxy* this_function_var_; | 2866 VariableProxy* this_function_var_; |
2871 }; | 2867 }; |
2872 | 2868 |
2873 | 2869 |
2874 // This class is produced when parsing the () in arrow functions without any | 2870 // This class is produced when parsing the () in arrow functions without any |
2875 // arguments and is not actually a valid expression. | 2871 // arguments and is not actually a valid expression. |
2876 class EmptyParentheses final : public Expression { | 2872 class EmptyParentheses final : public Expression { |
2877 public: | 2873 public: |
2878 DECLARE_NODE_TYPE(EmptyParentheses) | 2874 friend class AstNodeFactory; |
2879 | 2875 |
2880 private: | 2876 private: |
2881 EmptyParentheses(Zone* zone, int pos) | 2877 EmptyParentheses(Zone* zone, int pos) |
2882 : Expression(zone, pos, kEmptyParentheses) {} | 2878 : Expression(zone, pos, kEmptyParentheses) {} |
2883 }; | 2879 }; |
2884 | 2880 |
2885 | 2881 |
2886 #undef DECLARE_NODE_TYPE | |
2887 | |
2888 | 2882 |
2889 // ---------------------------------------------------------------------------- | 2883 // ---------------------------------------------------------------------------- |
2890 // Basic visitor | 2884 // Basic visitor |
2891 // Sub-class should parametrize AstVisitor with itself, e.g.: | 2885 // Sub-class should parametrize AstVisitor with itself, e.g.: |
2892 // class SpecificVisitor : public AstVisitor<SpecificVisitor> { ... } | 2886 // class SpecificVisitor : public AstVisitor<SpecificVisitor> { ... } |
2893 | 2887 |
2894 template <class Subclass> | 2888 template <class Subclass> |
2895 class AstVisitor BASE_EMBEDDED { | 2889 class AstVisitor BASE_EMBEDDED { |
2896 public: | 2890 public: |
2897 void Visit(AstNode* node) { impl()->Visit(node); } | 2891 void Visit(AstNode* node) { impl()->Visit(node); } |
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3530 : NULL; \ | 3524 : NULL; \ |
3531 } | 3525 } |
3532 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) | 3526 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) |
3533 #undef DECLARE_NODE_FUNCTIONS | 3527 #undef DECLARE_NODE_FUNCTIONS |
3534 | 3528 |
3535 | 3529 |
3536 } // namespace internal | 3530 } // namespace internal |
3537 } // namespace v8 | 3531 } // namespace v8 |
3538 | 3532 |
3539 #endif // V8_AST_AST_H_ | 3533 #endif // V8_AST_AST_H_ |
OLD | NEW |