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