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 873 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
884 | 884 |
885 void Initialize(Expression* each, Expression* subject, Statement* body) { | 885 void Initialize(Expression* each, Expression* subject, Statement* body) { |
886 IterationStatement::Initialize(body); | 886 IterationStatement::Initialize(body); |
887 each_ = each; | 887 each_ = each; |
888 subject_ = subject; | 888 subject_ = subject; |
889 } | 889 } |
890 | 890 |
891 Expression* each() const { return each_; } | 891 Expression* each() const { return each_; } |
892 Expression* subject() const { return subject_; } | 892 Expression* subject() const { return subject_; } |
893 | 893 |
894 virtual BailoutId ContinueId() const { return EntryId(); } | |
895 virtual BailoutId StackCheckId() const { return body_id_; } | |
896 BailoutId BodyId() const { return body_id_; } | |
897 BailoutId PrepareId() const { return prepare_id_; } | |
898 | |
899 protected: | 894 protected: |
900 ForEachStatement(Isolate* isolate, ZoneStringList* labels) | 895 ForEachStatement(Isolate* isolate, ZoneStringList* labels) |
901 : IterationStatement(isolate, labels), | 896 : IterationStatement(isolate, labels), |
902 each_(NULL), | 897 each_(NULL), |
903 subject_(NULL), | 898 subject_(NULL) { |
904 body_id_(GetNextId(isolate)), | |
905 prepare_id_(GetNextId(isolate)) { | |
906 } | 899 } |
907 | 900 |
908 private: | 901 private: |
909 Expression* each_; | 902 Expression* each_; |
910 Expression* subject_; | 903 Expression* subject_; |
911 const BailoutId body_id_; | |
912 const BailoutId prepare_id_; | |
913 }; | 904 }; |
914 | 905 |
915 | 906 |
916 class ForInStatement: public ForEachStatement { | 907 class ForInStatement: public ForEachStatement { |
917 public: | 908 public: |
918 DECLARE_NODE_TYPE(ForInStatement) | 909 DECLARE_NODE_TYPE(ForInStatement) |
919 | 910 |
920 Expression* enumerable() const { | 911 Expression* enumerable() const { |
921 return subject(); | 912 return subject(); |
922 } | 913 } |
923 | 914 |
924 TypeFeedbackId ForInFeedbackId() const { return reuse(PrepareId()); } | 915 TypeFeedbackId ForInFeedbackId() const { return reuse(PrepareId()); } |
925 void RecordTypeFeedback(TypeFeedbackOracle* oracle); | 916 void RecordTypeFeedback(TypeFeedbackOracle* oracle); |
926 enum ForInType { FAST_FOR_IN, SLOW_FOR_IN }; | 917 enum ForInType { FAST_FOR_IN, SLOW_FOR_IN }; |
927 ForInType for_in_type() const { return for_in_type_; } | 918 ForInType for_in_type() const { return for_in_type_; } |
928 | 919 |
| 920 BailoutId BodyId() const { return body_id_; } |
| 921 BailoutId PrepareId() const { return prepare_id_; } |
| 922 virtual BailoutId ContinueId() const { return EntryId(); } |
| 923 virtual BailoutId StackCheckId() const { return body_id_; } |
| 924 |
929 protected: | 925 protected: |
930 ForInStatement(Isolate* isolate, ZoneStringList* labels) | 926 ForInStatement(Isolate* isolate, ZoneStringList* labels) |
931 : ForEachStatement(isolate, labels), | 927 : ForEachStatement(isolate, labels), |
932 for_in_type_(SLOW_FOR_IN) { | 928 for_in_type_(SLOW_FOR_IN), |
| 929 body_id_(GetNextId(isolate)), |
| 930 prepare_id_(GetNextId(isolate)) { |
933 } | 931 } |
934 | 932 |
935 ForInType for_in_type_; | 933 ForInType for_in_type_; |
| 934 const BailoutId body_id_; |
| 935 const BailoutId prepare_id_; |
936 }; | 936 }; |
937 | 937 |
938 | 938 |
939 class ForOfStatement: public ForEachStatement { | 939 class ForOfStatement: public ForEachStatement { |
940 public: | 940 public: |
941 DECLARE_NODE_TYPE(ForOfStatement) | 941 DECLARE_NODE_TYPE(ForOfStatement) |
942 | 942 |
| 943 void Initialize(Expression* each, |
| 944 Expression* subject, |
| 945 Statement* body, |
| 946 Expression* assign_iterator, |
| 947 Expression* next_result, |
| 948 Expression* result_done, |
| 949 Expression* assign_each) { |
| 950 ForEachStatement::Initialize(each, subject, body); |
| 951 assign_iterator_ = assign_iterator; |
| 952 next_result_ = next_result; |
| 953 result_done_ = result_done; |
| 954 assign_each_ = assign_each; |
| 955 } |
| 956 |
943 Expression* iterable() const { | 957 Expression* iterable() const { |
944 return subject(); | 958 return subject(); |
945 } | 959 } |
946 | 960 |
| 961 // var iterator = iterable; |
| 962 Expression* assign_iterator() const { |
| 963 return assign_iterator_; |
| 964 } |
| 965 |
| 966 // var result = iterator.next(); |
| 967 Expression* next_result() const { |
| 968 return next_result_; |
| 969 } |
| 970 |
| 971 // result.done |
| 972 Expression* result_done() const { |
| 973 return result_done_; |
| 974 } |
| 975 |
| 976 // each = result.value |
| 977 Expression* assign_each() const { |
| 978 return assign_each_; |
| 979 } |
| 980 |
| 981 virtual BailoutId ContinueId() const { return EntryId(); } |
| 982 virtual BailoutId StackCheckId() const { return BackEdgeId(); } |
| 983 |
| 984 BailoutId BackEdgeId() const { return back_edge_id_; } |
| 985 |
947 protected: | 986 protected: |
948 ForOfStatement(Isolate* isolate, ZoneStringList* labels) | 987 ForOfStatement(Isolate* isolate, ZoneStringList* labels) |
949 : ForEachStatement(isolate, labels) { | 988 : ForEachStatement(isolate, labels), |
| 989 assign_iterator_(NULL), |
| 990 next_result_(NULL), |
| 991 result_done_(NULL), |
| 992 assign_each_(NULL), |
| 993 back_edge_id_(GetNextId(isolate)) { |
950 } | 994 } |
| 995 |
| 996 Expression* assign_iterator_; |
| 997 Expression* next_result_; |
| 998 Expression* result_done_; |
| 999 Expression* assign_each_; |
| 1000 const BailoutId back_edge_id_; |
951 }; | 1001 }; |
952 | 1002 |
953 | 1003 |
954 class ExpressionStatement: public Statement { | 1004 class ExpressionStatement: public Statement { |
955 public: | 1005 public: |
956 DECLARE_NODE_TYPE(ExpressionStatement) | 1006 DECLARE_NODE_TYPE(ExpressionStatement) |
957 | 1007 |
958 void set_expression(Expression* e) { expression_ = e; } | 1008 void set_expression(Expression* e) { expression_ = e; } |
959 Expression* expression() const { return expression_; } | 1009 Expression* expression() const { return expression_; } |
960 | 1010 |
(...skipping 2215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3176 private: | 3226 private: |
3177 Isolate* isolate_; | 3227 Isolate* isolate_; |
3178 Zone* zone_; | 3228 Zone* zone_; |
3179 Visitor visitor_; | 3229 Visitor visitor_; |
3180 }; | 3230 }; |
3181 | 3231 |
3182 | 3232 |
3183 } } // namespace v8::internal | 3233 } } // namespace v8::internal |
3184 | 3234 |
3185 #endif // V8_AST_H_ | 3235 #endif // V8_AST_H_ |
OLD | NEW |