OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
861 Expression* subject, | 861 Expression* subject, |
862 Statement* body) { | 862 Statement* body) { |
863 IterationStatement::Initialize(body); | 863 IterationStatement::Initialize(body); |
864 each_ = each; | 864 each_ = each; |
865 subject_ = subject; | 865 subject_ = subject; |
866 } | 866 } |
867 | 867 |
868 Expression* each() const { return each_; } | 868 Expression* each() const { return each_; } |
869 Expression* subject() const { return subject_; } | 869 Expression* subject() const { return subject_; } |
870 | 870 |
871 virtual BailoutId ContinueId() const { return EntryId(); } | |
872 virtual BailoutId StackCheckId() const { return body_id_; } | |
873 BailoutId BodyId() const { return body_id_; } | |
874 BailoutId PrepareId() const { return prepare_id_; } | |
875 | |
876 protected: | 871 protected: |
877 ForEachStatement(Isolate* isolate, ZoneStringList* labels) | 872 ForEachStatement(Isolate* isolate, ZoneStringList* labels) |
878 : IterationStatement(isolate, labels), | 873 : IterationStatement(isolate, labels), |
879 each_(NULL), | 874 each_(NULL), |
880 subject_(NULL), | 875 subject_(NULL) { |
881 body_id_(GetNextId(isolate)), | |
882 prepare_id_(GetNextId(isolate)) { | |
883 } | 876 } |
884 | 877 |
885 private: | 878 private: |
886 Expression* each_; | 879 Expression* each_; |
887 Expression* subject_; | 880 Expression* subject_; |
888 const BailoutId body_id_; | |
889 const BailoutId prepare_id_; | |
890 }; | 881 }; |
891 | 882 |
892 | 883 |
893 class ForInStatement: public ForEachStatement { | 884 class ForInStatement: public ForEachStatement { |
894 public: | 885 public: |
895 DECLARE_NODE_TYPE(ForInStatement) | 886 DECLARE_NODE_TYPE(ForInStatement) |
896 | 887 |
897 Expression* enumerable() const { | 888 Expression* enumerable() const { |
898 return subject(); | 889 return subject(); |
899 } | 890 } |
900 | 891 |
901 TypeFeedbackId ForInFeedbackId() const { return reuse(PrepareId()); } | 892 TypeFeedbackId ForInFeedbackId() const { return reuse(PrepareId()); } |
| 893 BailoutId BodyId() const { return body_id_; } |
| 894 BailoutId PrepareId() const { return prepare_id_; } |
| 895 virtual BailoutId ContinueId() const { return EntryId(); } |
| 896 virtual BailoutId StackCheckId() const { return body_id_; } |
902 | 897 |
903 protected: | 898 protected: |
904 ForInStatement(Isolate* isolate, ZoneStringList* labels) | 899 ForInStatement(Isolate* isolate, ZoneStringList* labels) |
905 : ForEachStatement(isolate, labels) { | 900 : ForEachStatement(isolate, labels), |
| 901 body_id_(GetNextId(isolate)), |
| 902 prepare_id_(GetNextId(isolate)) { |
906 } | 903 } |
| 904 |
| 905 const BailoutId body_id_; |
| 906 const BailoutId prepare_id_; |
907 }; | 907 }; |
908 | 908 |
909 | 909 |
910 class ForOfStatement: public ForEachStatement { | 910 class ForOfStatement: public ForEachStatement { |
911 public: | 911 public: |
912 DECLARE_NODE_TYPE(ForOfStatement) | 912 DECLARE_NODE_TYPE(ForOfStatement) |
913 | 913 |
| 914 void Initialize(Expression* each, |
| 915 Expression* subject, |
| 916 Statement* body, |
| 917 Expression* assign_iterator, |
| 918 Expression* next_result, |
| 919 Expression* result_done, |
| 920 Expression* assign_each) { |
| 921 ForEachStatement::Initialize(each, subject, body); |
| 922 assign_iterator_ = assign_iterator; |
| 923 next_result_ = next_result; |
| 924 result_done_ = result_done; |
| 925 assign_each_ = assign_each; |
| 926 } |
| 927 |
914 Expression* iterable() const { | 928 Expression* iterable() const { |
915 return subject(); | 929 return subject(); |
916 } | 930 } |
917 | 931 |
| 932 // var iterator = iterable; |
| 933 Expression* assign_iterator() const { |
| 934 return assign_iterator_; |
| 935 } |
| 936 |
| 937 // var result = iterator.next(); |
| 938 Expression* next_result() const { |
| 939 return next_result_; |
| 940 } |
| 941 |
| 942 // result.done |
| 943 Expression* result_done() const { |
| 944 return result_done_; |
| 945 } |
| 946 |
| 947 // each = result.value |
| 948 Expression* assign_each() const { |
| 949 return assign_each_; |
| 950 } |
| 951 |
| 952 virtual BailoutId ContinueId() const { return EntryId(); } |
| 953 virtual BailoutId StackCheckId() const { return BackEdgeId(); } |
| 954 |
| 955 BailoutId BackEdgeId() const { return back_edge_id_; } |
| 956 |
918 protected: | 957 protected: |
919 ForOfStatement(Isolate* isolate, ZoneStringList* labels) | 958 ForOfStatement(Isolate* isolate, ZoneStringList* labels) |
920 : ForEachStatement(isolate, labels) { | 959 : ForEachStatement(isolate, labels), |
| 960 assign_iterator_(NULL), |
| 961 next_result_(NULL), |
| 962 result_done_(NULL), |
| 963 assign_each_(NULL), |
| 964 back_edge_id_(GetNextId(isolate)) { |
921 } | 965 } |
| 966 |
| 967 Expression* assign_iterator_; |
| 968 Expression* next_result_; |
| 969 Expression* result_done_; |
| 970 Expression* assign_each_; |
| 971 const BailoutId back_edge_id_; |
922 }; | 972 }; |
923 | 973 |
924 | 974 |
925 class ExpressionStatement: public Statement { | 975 class ExpressionStatement: public Statement { |
926 public: | 976 public: |
927 DECLARE_NODE_TYPE(ExpressionStatement) | 977 DECLARE_NODE_TYPE(ExpressionStatement) |
928 | 978 |
929 void set_expression(Expression* e) { expression_ = e; } | 979 void set_expression(Expression* e) { expression_ = e; } |
930 Expression* expression() const { return expression_; } | 980 Expression* expression() const { return expression_; } |
931 | 981 |
(...skipping 2184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3116 private: | 3166 private: |
3117 Isolate* isolate_; | 3167 Isolate* isolate_; |
3118 Zone* zone_; | 3168 Zone* zone_; |
3119 Visitor visitor_; | 3169 Visitor visitor_; |
3120 }; | 3170 }; |
3121 | 3171 |
3122 | 3172 |
3123 } } // namespace v8::internal | 3173 } } // namespace v8::internal |
3124 | 3174 |
3125 #endif // V8_AST_H_ | 3175 #endif // V8_AST_H_ |
OLD | NEW |