| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_AST_AST_H_ | 5 #ifndef V8_AST_AST_H_ |
| 6 #define V8_AST_AST_H_ | 6 #define V8_AST_AST_H_ |
| 7 | 7 |
| 8 #include "src/assembler.h" | 8 #include "src/assembler.h" |
| 9 #include "src/ast/ast-value-factory.h" | 9 #include "src/ast/ast-value-factory.h" |
| 10 #include "src/ast/modules.h" | 10 #include "src/ast/modules.h" |
| (...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 | 476 |
| 477 static int num_ids() { return parent_num_ids() + 1; } | 477 static int num_ids() { return parent_num_ids() + 1; } |
| 478 BailoutId DeclsId() const { return BailoutId(local_id(0)); } | 478 BailoutId DeclsId() const { return BailoutId(local_id(0)); } |
| 479 | 479 |
| 480 bool IsJump() const override { | 480 bool IsJump() const override { |
| 481 return !statements_.is_empty() && statements_.last()->IsJump() | 481 return !statements_.is_empty() && statements_.last()->IsJump() |
| 482 && labels() == NULL; // Good enough as an approximation... | 482 && labels() == NULL; // Good enough as an approximation... |
| 483 } | 483 } |
| 484 | 484 |
| 485 void MarkTail() override { | 485 void MarkTail() override { |
| 486 if (!statements_.is_empty()) statements_.last()->MarkTail(); | 486 for (int i = 0; i < statements_.length(); i++) { |
| 487 Statement* stmt = statements_.at(i); |
| 488 stmt->MarkTail(); |
| 489 } |
| 487 } | 490 } |
| 488 | 491 |
| 489 Scope* scope() const { return scope_; } | 492 Scope* scope() const { return scope_; } |
| 490 void set_scope(Scope* scope) { scope_ = scope; } | 493 void set_scope(Scope* scope) { scope_ = scope; } |
| 491 | 494 |
| 492 protected: | 495 protected: |
| 493 Block(Zone* zone, ZoneList<const AstRawString*>* labels, int capacity, | 496 Block(Zone* zone, ZoneList<const AstRawString*>* labels, int capacity, |
| 494 bool ignore_completion_value, int pos) | 497 bool ignore_completion_value, int pos) |
| 495 : BreakableStatement(zone, labels, TARGET_FOR_NAMED_ONLY, pos), | 498 : BreakableStatement(zone, labels, TARGET_FOR_NAMED_ONLY, pos), |
| 496 statements_(capacity, zone), | 499 statements_(capacity, zone), |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 961 }; | 964 }; |
| 962 | 965 |
| 963 | 966 |
| 964 class ExpressionStatement final : public Statement { | 967 class ExpressionStatement final : public Statement { |
| 965 public: | 968 public: |
| 966 DECLARE_NODE_TYPE(ExpressionStatement) | 969 DECLARE_NODE_TYPE(ExpressionStatement) |
| 967 | 970 |
| 968 void set_expression(Expression* e) { expression_ = e; } | 971 void set_expression(Expression* e) { expression_ = e; } |
| 969 Expression* expression() const { return expression_; } | 972 Expression* expression() const { return expression_; } |
| 970 bool IsJump() const override { return expression_->IsThrow(); } | 973 bool IsJump() const override { return expression_->IsThrow(); } |
| 971 void MarkTail() override { expression_->MarkTail(); } | |
| 972 | 974 |
| 973 protected: | 975 protected: |
| 974 ExpressionStatement(Zone* zone, Expression* expression, int pos) | 976 ExpressionStatement(Zone* zone, Expression* expression, int pos) |
| 975 : Statement(zone, pos), expression_(expression) { } | 977 : Statement(zone, pos), expression_(expression) { } |
| 976 | 978 |
| 977 private: | 979 private: |
| 978 Expression* expression_; | 980 Expression* expression_; |
| 979 }; | 981 }; |
| 980 | 982 |
| 981 | 983 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1019 | 1021 |
| 1020 | 1022 |
| 1021 class ReturnStatement final : public JumpStatement { | 1023 class ReturnStatement final : public JumpStatement { |
| 1022 public: | 1024 public: |
| 1023 DECLARE_NODE_TYPE(ReturnStatement) | 1025 DECLARE_NODE_TYPE(ReturnStatement) |
| 1024 | 1026 |
| 1025 Expression* expression() const { return expression_; } | 1027 Expression* expression() const { return expression_; } |
| 1026 | 1028 |
| 1027 void set_expression(Expression* e) { expression_ = e; } | 1029 void set_expression(Expression* e) { expression_ = e; } |
| 1028 | 1030 |
| 1031 void MarkTail() override { expression_->MarkTail(); } |
| 1032 |
| 1029 protected: | 1033 protected: |
| 1030 explicit ReturnStatement(Zone* zone, Expression* expression, int pos) | 1034 explicit ReturnStatement(Zone* zone, Expression* expression, int pos) |
| 1031 : JumpStatement(zone, pos), expression_(expression) { } | 1035 : JumpStatement(zone, pos), expression_(expression) { } |
| 1032 | 1036 |
| 1033 private: | 1037 private: |
| 1034 Expression* expression_; | 1038 Expression* expression_; |
| 1035 }; | 1039 }; |
| 1036 | 1040 |
| 1037 | 1041 |
| 1038 class WithStatement final : public Statement { | 1042 class WithStatement final : public Statement { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1088 } | 1092 } |
| 1089 void set_label(Expression* e) { label_ = e; } | 1093 void set_label(Expression* e) { label_ = e; } |
| 1090 Label* body_target() { return &body_target_; } | 1094 Label* body_target() { return &body_target_; } |
| 1091 ZoneList<Statement*>* statements() const { return statements_; } | 1095 ZoneList<Statement*>* statements() const { return statements_; } |
| 1092 | 1096 |
| 1093 static int num_ids() { return parent_num_ids() + 2; } | 1097 static int num_ids() { return parent_num_ids() + 2; } |
| 1094 BailoutId EntryId() const { return BailoutId(local_id(0)); } | 1098 BailoutId EntryId() const { return BailoutId(local_id(0)); } |
| 1095 TypeFeedbackId CompareId() { return TypeFeedbackId(local_id(1)); } | 1099 TypeFeedbackId CompareId() { return TypeFeedbackId(local_id(1)); } |
| 1096 | 1100 |
| 1097 void MarkTail() override { | 1101 void MarkTail() override { |
| 1098 if (!statements_->is_empty()) statements_->last()->MarkTail(); | 1102 for (int i = 0; i < statements_->length(); i++) { |
| 1103 Statement* stmt = statements_->at(i); |
| 1104 stmt->MarkTail(); |
| 1105 } |
| 1099 } | 1106 } |
| 1100 | 1107 |
| 1101 Type* compare_type() { return compare_type_; } | 1108 Type* compare_type() { return compare_type_; } |
| 1102 void set_compare_type(Type* type) { compare_type_ = type; } | 1109 void set_compare_type(Type* type) { compare_type_ = type; } |
| 1103 | 1110 |
| 1104 protected: | 1111 protected: |
| 1105 static int parent_num_ids() { return Expression::num_ids(); } | 1112 static int parent_num_ids() { return Expression::num_ids(); } |
| 1106 | 1113 |
| 1107 private: | 1114 private: |
| 1108 CaseClause(Zone* zone, Expression* label, ZoneList<Statement*>* statements, | 1115 CaseClause(Zone* zone, Expression* label, ZoneList<Statement*>* statements, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1124 tag_ = tag; | 1131 tag_ = tag; |
| 1125 cases_ = cases; | 1132 cases_ = cases; |
| 1126 } | 1133 } |
| 1127 | 1134 |
| 1128 Expression* tag() const { return tag_; } | 1135 Expression* tag() const { return tag_; } |
| 1129 ZoneList<CaseClause*>* cases() const { return cases_; } | 1136 ZoneList<CaseClause*>* cases() const { return cases_; } |
| 1130 | 1137 |
| 1131 void set_tag(Expression* t) { tag_ = t; } | 1138 void set_tag(Expression* t) { tag_ = t; } |
| 1132 | 1139 |
| 1133 void MarkTail() override { | 1140 void MarkTail() override { |
| 1134 if (!cases_->is_empty()) cases_->last()->MarkTail(); | 1141 for (int i = 0; i < cases_->length(); i++) { |
| 1142 CaseClause* clause = cases_->at(i); |
| 1143 clause->MarkTail(); |
| 1144 } |
| 1135 } | 1145 } |
| 1136 | 1146 |
| 1137 protected: | 1147 protected: |
| 1138 SwitchStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) | 1148 SwitchStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) |
| 1139 : BreakableStatement(zone, labels, TARGET_FOR_ANONYMOUS, pos), | 1149 : BreakableStatement(zone, labels, TARGET_FOR_ANONYMOUS, pos), |
| 1140 tag_(NULL), | 1150 tag_(NULL), |
| 1141 cases_(NULL) {} | 1151 cases_(NULL) {} |
| 1142 | 1152 |
| 1143 private: | 1153 private: |
| 1144 Expression* tag_; | 1154 Expression* tag_; |
| (...skipping 2416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3561 // the parser-level zone. | 3571 // the parser-level zone. |
| 3562 Zone* parser_zone_; | 3572 Zone* parser_zone_; |
| 3563 AstValueFactory* ast_value_factory_; | 3573 AstValueFactory* ast_value_factory_; |
| 3564 }; | 3574 }; |
| 3565 | 3575 |
| 3566 | 3576 |
| 3567 } // namespace internal | 3577 } // namespace internal |
| 3568 } // namespace v8 | 3578 } // namespace v8 |
| 3569 | 3579 |
| 3570 #endif // V8_AST_AST_H_ | 3580 #endif // V8_AST_AST_H_ |
| OLD | NEW |