| 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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 | 252 |
| 253 friend class CaseClause; // Generates AST IDs. | 253 friend class CaseClause; // Generates AST IDs. |
| 254 }; | 254 }; |
| 255 | 255 |
| 256 | 256 |
| 257 class Statement: public AstNode { | 257 class Statement: public AstNode { |
| 258 public: | 258 public: |
| 259 Statement() : statement_pos_(RelocInfo::kNoPosition) {} | 259 Statement() : statement_pos_(RelocInfo::kNoPosition) {} |
| 260 | 260 |
| 261 bool IsEmpty() { return AsEmptyStatement() != NULL; } | 261 bool IsEmpty() { return AsEmptyStatement() != NULL; } |
| 262 virtual bool IsJump() const { return false; } |
| 262 | 263 |
| 263 void set_statement_pos(int statement_pos) { statement_pos_ = statement_pos; } | 264 void set_statement_pos(int statement_pos) { statement_pos_ = statement_pos; } |
| 264 int statement_pos() const { return statement_pos_; } | 265 int statement_pos() const { return statement_pos_; } |
| 265 | 266 |
| 266 private: | 267 private: |
| 267 int statement_pos_; | 268 int statement_pos_; |
| 268 }; | 269 }; |
| 269 | 270 |
| 270 | 271 |
| 271 class SmallMapList { | 272 class SmallMapList { |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 | 382 |
| 382 // TODO(rossberg): this should move to its own AST node eventually. | 383 // TODO(rossberg): this should move to its own AST node eventually. |
| 383 virtual void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle); | 384 virtual void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle); |
| 384 byte to_boolean_types() const { return to_boolean_types_; } | 385 byte to_boolean_types() const { return to_boolean_types_; } |
| 385 | 386 |
| 386 BailoutId id() const { return id_; } | 387 BailoutId id() const { return id_; } |
| 387 TypeFeedbackId test_id() const { return test_id_; } | 388 TypeFeedbackId test_id() const { return test_id_; } |
| 388 | 389 |
| 389 protected: | 390 protected: |
| 390 explicit Expression(Isolate* isolate) | 391 explicit Expression(Isolate* isolate) |
| 391 : bounds_(Type::None(), Type::Any(), isolate), | 392 : bounds_(Bounds::Unbounded(isolate)), |
| 392 id_(GetNextId(isolate)), | 393 id_(GetNextId(isolate)), |
| 393 test_id_(GetNextId(isolate)) {} | 394 test_id_(GetNextId(isolate)) {} |
| 394 void set_to_boolean_types(byte types) { to_boolean_types_ = types; } | 395 void set_to_boolean_types(byte types) { to_boolean_types_ = types; } |
| 395 | 396 |
| 396 private: | 397 private: |
| 397 Bounds bounds_; | 398 Bounds bounds_; |
| 398 byte to_boolean_types_; | 399 byte to_boolean_types_; |
| 399 | 400 |
| 400 const BailoutId id_; | 401 const BailoutId id_; |
| 401 const TypeFeedbackId test_id_; | 402 const TypeFeedbackId test_id_; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 public: | 452 public: |
| 452 DECLARE_NODE_TYPE(Block) | 453 DECLARE_NODE_TYPE(Block) |
| 453 | 454 |
| 454 void AddStatement(Statement* statement, Zone* zone) { | 455 void AddStatement(Statement* statement, Zone* zone) { |
| 455 statements_.Add(statement, zone); | 456 statements_.Add(statement, zone); |
| 456 } | 457 } |
| 457 | 458 |
| 458 ZoneList<Statement*>* statements() { return &statements_; } | 459 ZoneList<Statement*>* statements() { return &statements_; } |
| 459 bool is_initializer_block() const { return is_initializer_block_; } | 460 bool is_initializer_block() const { return is_initializer_block_; } |
| 460 | 461 |
| 462 virtual bool IsJump() const { |
| 463 return !statements_.is_empty() && statements_.last()->IsJump() |
| 464 && labels() == NULL; // Good enough as an approximation... |
| 465 } |
| 466 |
| 461 Scope* scope() const { return scope_; } | 467 Scope* scope() const { return scope_; } |
| 462 void set_scope(Scope* scope) { scope_ = scope; } | 468 void set_scope(Scope* scope) { scope_ = scope; } |
| 463 | 469 |
| 464 protected: | 470 protected: |
| 465 Block(Isolate* isolate, | 471 Block(Isolate* isolate, |
| 466 ZoneStringList* labels, | 472 ZoneStringList* labels, |
| 467 int capacity, | 473 int capacity, |
| 468 bool is_initializer_block, | 474 bool is_initializer_block, |
| 469 Zone* zone) | 475 Zone* zone) |
| 470 : BreakableStatement(isolate, labels, TARGET_FOR_NAMED_ONLY), | 476 : BreakableStatement(isolate, labels, TARGET_FOR_NAMED_ONLY), |
| (...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1001 const BailoutId back_edge_id_; | 1007 const BailoutId back_edge_id_; |
| 1002 }; | 1008 }; |
| 1003 | 1009 |
| 1004 | 1010 |
| 1005 class ExpressionStatement: public Statement { | 1011 class ExpressionStatement: public Statement { |
| 1006 public: | 1012 public: |
| 1007 DECLARE_NODE_TYPE(ExpressionStatement) | 1013 DECLARE_NODE_TYPE(ExpressionStatement) |
| 1008 | 1014 |
| 1009 void set_expression(Expression* e) { expression_ = e; } | 1015 void set_expression(Expression* e) { expression_ = e; } |
| 1010 Expression* expression() const { return expression_; } | 1016 Expression* expression() const { return expression_; } |
| 1017 virtual bool IsJump() const { return expression_->IsThrow(); } |
| 1011 | 1018 |
| 1012 protected: | 1019 protected: |
| 1013 explicit ExpressionStatement(Expression* expression) | 1020 explicit ExpressionStatement(Expression* expression) |
| 1014 : expression_(expression) { } | 1021 : expression_(expression) { } |
| 1015 | 1022 |
| 1016 private: | 1023 private: |
| 1017 Expression* expression_; | 1024 Expression* expression_; |
| 1018 }; | 1025 }; |
| 1019 | 1026 |
| 1020 | 1027 |
| 1021 class ContinueStatement: public Statement { | 1028 class JumpStatement: public Statement { |
| 1029 public: |
| 1030 virtual bool IsJump() const { return true; } |
| 1031 |
| 1032 protected: |
| 1033 JumpStatement() {} |
| 1034 }; |
| 1035 |
| 1036 |
| 1037 class ContinueStatement: public JumpStatement { |
| 1022 public: | 1038 public: |
| 1023 DECLARE_NODE_TYPE(ContinueStatement) | 1039 DECLARE_NODE_TYPE(ContinueStatement) |
| 1024 | 1040 |
| 1025 IterationStatement* target() const { return target_; } | 1041 IterationStatement* target() const { return target_; } |
| 1026 | 1042 |
| 1027 protected: | 1043 protected: |
| 1028 explicit ContinueStatement(IterationStatement* target) | 1044 explicit ContinueStatement(IterationStatement* target) |
| 1029 : target_(target) { } | 1045 : target_(target) { } |
| 1030 | 1046 |
| 1031 private: | 1047 private: |
| 1032 IterationStatement* target_; | 1048 IterationStatement* target_; |
| 1033 }; | 1049 }; |
| 1034 | 1050 |
| 1035 | 1051 |
| 1036 class BreakStatement: public Statement { | 1052 class BreakStatement: public JumpStatement { |
| 1037 public: | 1053 public: |
| 1038 DECLARE_NODE_TYPE(BreakStatement) | 1054 DECLARE_NODE_TYPE(BreakStatement) |
| 1039 | 1055 |
| 1040 BreakableStatement* target() const { return target_; } | 1056 BreakableStatement* target() const { return target_; } |
| 1041 | 1057 |
| 1042 protected: | 1058 protected: |
| 1043 explicit BreakStatement(BreakableStatement* target) | 1059 explicit BreakStatement(BreakableStatement* target) |
| 1044 : target_(target) { } | 1060 : target_(target) { } |
| 1045 | 1061 |
| 1046 private: | 1062 private: |
| 1047 BreakableStatement* target_; | 1063 BreakableStatement* target_; |
| 1048 }; | 1064 }; |
| 1049 | 1065 |
| 1050 | 1066 |
| 1051 class ReturnStatement: public Statement { | 1067 class ReturnStatement: public JumpStatement { |
| 1052 public: | 1068 public: |
| 1053 DECLARE_NODE_TYPE(ReturnStatement) | 1069 DECLARE_NODE_TYPE(ReturnStatement) |
| 1054 | 1070 |
| 1055 Expression* expression() const { return expression_; } | 1071 Expression* expression() const { return expression_; } |
| 1056 | 1072 |
| 1057 protected: | 1073 protected: |
| 1058 explicit ReturnStatement(Expression* expression) | 1074 explicit ReturnStatement(Expression* expression) |
| 1059 : expression_(expression) { } | 1075 : expression_(expression) { } |
| 1060 | 1076 |
| 1061 private: | 1077 private: |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1160 public: | 1176 public: |
| 1161 DECLARE_NODE_TYPE(IfStatement) | 1177 DECLARE_NODE_TYPE(IfStatement) |
| 1162 | 1178 |
| 1163 bool HasThenStatement() const { return !then_statement()->IsEmpty(); } | 1179 bool HasThenStatement() const { return !then_statement()->IsEmpty(); } |
| 1164 bool HasElseStatement() const { return !else_statement()->IsEmpty(); } | 1180 bool HasElseStatement() const { return !else_statement()->IsEmpty(); } |
| 1165 | 1181 |
| 1166 Expression* condition() const { return condition_; } | 1182 Expression* condition() const { return condition_; } |
| 1167 Statement* then_statement() const { return then_statement_; } | 1183 Statement* then_statement() const { return then_statement_; } |
| 1168 Statement* else_statement() const { return else_statement_; } | 1184 Statement* else_statement() const { return else_statement_; } |
| 1169 | 1185 |
| 1186 virtual bool IsJump() const { |
| 1187 return HasThenStatement() && then_statement()->IsJump() |
| 1188 && HasElseStatement() && else_statement()->IsJump(); |
| 1189 } |
| 1190 |
| 1170 BailoutId IfId() const { return if_id_; } | 1191 BailoutId IfId() const { return if_id_; } |
| 1171 BailoutId ThenId() const { return then_id_; } | 1192 BailoutId ThenId() const { return then_id_; } |
| 1172 BailoutId ElseId() const { return else_id_; } | 1193 BailoutId ElseId() const { return else_id_; } |
| 1173 | 1194 |
| 1174 protected: | 1195 protected: |
| 1175 IfStatement(Isolate* isolate, | 1196 IfStatement(Isolate* isolate, |
| 1176 Expression* condition, | 1197 Expression* condition, |
| 1177 Statement* then_statement, | 1198 Statement* then_statement, |
| 1178 Statement* else_statement) | 1199 Statement* else_statement) |
| 1179 : condition_(condition), | 1200 : condition_(condition), |
| (...skipping 2028 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3208 private: | 3229 private: |
| 3209 Isolate* isolate_; | 3230 Isolate* isolate_; |
| 3210 Zone* zone_; | 3231 Zone* zone_; |
| 3211 Visitor visitor_; | 3232 Visitor visitor_; |
| 3212 }; | 3233 }; |
| 3213 | 3234 |
| 3214 | 3235 |
| 3215 } } // namespace v8::internal | 3236 } } // namespace v8::internal |
| 3216 | 3237 |
| 3217 #endif // V8_AST_H_ | 3238 #endif // V8_AST_H_ |
| OLD | NEW |