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_H_ | 5 #ifndef V8_AST_H_ |
6 #define V8_AST_H_ | 6 #define V8_AST_H_ |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/assembler.h" | 10 #include "src/assembler.h" |
(...skipping 943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
954 }; | 954 }; |
955 | 955 |
956 | 956 |
957 class ForOfStatement V8_FINAL : public ForEachStatement { | 957 class ForOfStatement V8_FINAL : public ForEachStatement { |
958 public: | 958 public: |
959 DECLARE_NODE_TYPE(ForOfStatement) | 959 DECLARE_NODE_TYPE(ForOfStatement) |
960 | 960 |
961 void Initialize(Expression* each, | 961 void Initialize(Expression* each, |
962 Expression* subject, | 962 Expression* subject, |
963 Statement* body, | 963 Statement* body, |
964 Expression* assign_iterable, | |
965 Expression* assign_iterator, | 964 Expression* assign_iterator, |
966 Expression* next_result, | 965 Expression* next_result, |
967 Expression* result_done, | 966 Expression* result_done, |
968 Expression* assign_each) { | 967 Expression* assign_each) { |
969 ForEachStatement::Initialize(each, subject, body); | 968 ForEachStatement::Initialize(each, subject, body); |
970 assign_iterable_ = assign_iterable; | |
971 assign_iterator_ = assign_iterator; | 969 assign_iterator_ = assign_iterator; |
972 next_result_ = next_result; | 970 next_result_ = next_result; |
973 result_done_ = result_done; | 971 result_done_ = result_done; |
974 assign_each_ = assign_each; | 972 assign_each_ = assign_each; |
975 } | 973 } |
976 | 974 |
977 Expression* iterable() const { | 975 Expression* iterable() const { |
978 return subject(); | 976 return subject(); |
979 } | 977 } |
980 | 978 |
981 // var iterable = subject; | 979 // var iterator = subject[Symbol.iterator](); |
982 Expression* assign_iterable() const { | |
983 return assign_iterable_; | |
984 } | |
985 | |
986 // var iterator = iterable[Symbol.iterator](); | |
987 Expression* assign_iterator() const { | 980 Expression* assign_iterator() const { |
988 return assign_iterator_; | 981 return assign_iterator_; |
989 } | 982 } |
990 | 983 |
991 // var result = iterator.next(); | 984 // var result = iterator.next(); |
992 Expression* next_result() const { | 985 Expression* next_result() const { |
993 return next_result_; | 986 return next_result_; |
994 } | 987 } |
995 | 988 |
996 // result.done | 989 // result.done |
(...skipping 14 matching lines...) Expand all Loading... |
1011 protected: | 1004 protected: |
1012 ForOfStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) | 1005 ForOfStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) |
1013 : ForEachStatement(zone, labels, pos), | 1006 : ForEachStatement(zone, labels, pos), |
1014 assign_iterator_(NULL), | 1007 assign_iterator_(NULL), |
1015 next_result_(NULL), | 1008 next_result_(NULL), |
1016 result_done_(NULL), | 1009 result_done_(NULL), |
1017 assign_each_(NULL), | 1010 assign_each_(NULL), |
1018 back_edge_id_(GetNextId(zone)) { | 1011 back_edge_id_(GetNextId(zone)) { |
1019 } | 1012 } |
1020 | 1013 |
1021 Expression* assign_iterable_; | |
1022 Expression* assign_iterator_; | 1014 Expression* assign_iterator_; |
1023 Expression* next_result_; | 1015 Expression* next_result_; |
1024 Expression* result_done_; | 1016 Expression* result_done_; |
1025 Expression* assign_each_; | 1017 Expression* assign_each_; |
1026 const BailoutId back_edge_id_; | 1018 const BailoutId back_edge_id_; |
1027 }; | 1019 }; |
1028 | 1020 |
1029 | 1021 |
1030 class ExpressionStatement V8_FINAL : public Statement { | 1022 class ExpressionStatement V8_FINAL : public Statement { |
1031 public: | 1023 public: |
(...skipping 2439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3471 private: | 3463 private: |
3472 Zone* zone_; | 3464 Zone* zone_; |
3473 Visitor visitor_; | 3465 Visitor visitor_; |
3474 AstValueFactory* ast_value_factory_; | 3466 AstValueFactory* ast_value_factory_; |
3475 }; | 3467 }; |
3476 | 3468 |
3477 | 3469 |
3478 } } // namespace v8::internal | 3470 } } // namespace v8::internal |
3479 | 3471 |
3480 #endif // V8_AST_H_ | 3472 #endif // V8_AST_H_ |
OLD | NEW |