Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(172)

Side by Side Diff: src/ast.h

Issue 18926004: Handle switch effects (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/typing.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 public: 453 public:
453 DECLARE_NODE_TYPE(Block) 454 DECLARE_NODE_TYPE(Block)
454 455
455 void AddStatement(Statement* statement, Zone* zone) { 456 void AddStatement(Statement* statement, Zone* zone) {
456 statements_.Add(statement, zone); 457 statements_.Add(statement, zone);
457 } 458 }
458 459
459 ZoneList<Statement*>* statements() { return &statements_; } 460 ZoneList<Statement*>* statements() { return &statements_; }
460 bool is_initializer_block() const { return is_initializer_block_; } 461 bool is_initializer_block() const { return is_initializer_block_; }
461 462
463 virtual bool IsJump() const {
464 return !statements_.is_empty() && statements_.last()->IsJump()
465 && labels() == NULL; // Good enough as an approximation...
466 }
467
462 Scope* scope() const { return scope_; } 468 Scope* scope() const { return scope_; }
463 void set_scope(Scope* scope) { scope_ = scope; } 469 void set_scope(Scope* scope) { scope_ = scope; }
464 470
465 protected: 471 protected:
466 Block(Isolate* isolate, 472 Block(Isolate* isolate,
467 ZoneStringList* labels, 473 ZoneStringList* labels,
468 int capacity, 474 int capacity,
469 bool is_initializer_block, 475 bool is_initializer_block,
470 Zone* zone) 476 Zone* zone)
471 : BreakableStatement(isolate, labels, TARGET_FOR_NAMED_ONLY), 477 : BreakableStatement(isolate, labels, TARGET_FOR_NAMED_ONLY),
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
1002 const BailoutId back_edge_id_; 1008 const BailoutId back_edge_id_;
1003 }; 1009 };
1004 1010
1005 1011
1006 class ExpressionStatement: public Statement { 1012 class ExpressionStatement: public Statement {
1007 public: 1013 public:
1008 DECLARE_NODE_TYPE(ExpressionStatement) 1014 DECLARE_NODE_TYPE(ExpressionStatement)
1009 1015
1010 void set_expression(Expression* e) { expression_ = e; } 1016 void set_expression(Expression* e) { expression_ = e; }
1011 Expression* expression() const { return expression_; } 1017 Expression* expression() const { return expression_; }
1018 virtual bool IsJump() const { return expression_->IsThrow(); }
1012 1019
1013 protected: 1020 protected:
1014 explicit ExpressionStatement(Expression* expression) 1021 explicit ExpressionStatement(Expression* expression)
1015 : expression_(expression) { } 1022 : expression_(expression) { }
1016 1023
1017 private: 1024 private:
1018 Expression* expression_; 1025 Expression* expression_;
1019 }; 1026 };
1020 1027
1021 1028
1022 class ContinueStatement: public Statement { 1029 class JumpStatement: public Statement {
1030 public:
1031 virtual bool IsJump() const { return true; }
1032
1033 protected:
1034 JumpStatement() {}
1035 };
1036
1037
1038 class ContinueStatement: public JumpStatement {
1023 public: 1039 public:
1024 DECLARE_NODE_TYPE(ContinueStatement) 1040 DECLARE_NODE_TYPE(ContinueStatement)
1025 1041
1026 IterationStatement* target() const { return target_; } 1042 IterationStatement* target() const { return target_; }
1027 1043
1028 protected: 1044 protected:
1029 explicit ContinueStatement(IterationStatement* target) 1045 explicit ContinueStatement(IterationStatement* target)
1030 : target_(target) { } 1046 : target_(target) { }
1031 1047
1032 private: 1048 private:
1033 IterationStatement* target_; 1049 IterationStatement* target_;
1034 }; 1050 };
1035 1051
1036 1052
1037 class BreakStatement: public Statement { 1053 class BreakStatement: public JumpStatement {
1038 public: 1054 public:
1039 DECLARE_NODE_TYPE(BreakStatement) 1055 DECLARE_NODE_TYPE(BreakStatement)
1040 1056
1041 BreakableStatement* target() const { return target_; } 1057 BreakableStatement* target() const { return target_; }
1042 1058
1043 protected: 1059 protected:
1044 explicit BreakStatement(BreakableStatement* target) 1060 explicit BreakStatement(BreakableStatement* target)
1045 : target_(target) { } 1061 : target_(target) { }
1046 1062
1047 private: 1063 private:
1048 BreakableStatement* target_; 1064 BreakableStatement* target_;
1049 }; 1065 };
1050 1066
1051 1067
1052 class ReturnStatement: public Statement { 1068 class ReturnStatement: public JumpStatement {
1053 public: 1069 public:
1054 DECLARE_NODE_TYPE(ReturnStatement) 1070 DECLARE_NODE_TYPE(ReturnStatement)
1055 1071
1056 Expression* expression() const { return expression_; } 1072 Expression* expression() const { return expression_; }
1057 1073
1058 protected: 1074 protected:
1059 explicit ReturnStatement(Expression* expression) 1075 explicit ReturnStatement(Expression* expression)
1060 : expression_(expression) { } 1076 : expression_(expression) { }
1061 1077
1062 private: 1078 private:
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1161 public: 1177 public:
1162 DECLARE_NODE_TYPE(IfStatement) 1178 DECLARE_NODE_TYPE(IfStatement)
1163 1179
1164 bool HasThenStatement() const { return !then_statement()->IsEmpty(); } 1180 bool HasThenStatement() const { return !then_statement()->IsEmpty(); }
1165 bool HasElseStatement() const { return !else_statement()->IsEmpty(); } 1181 bool HasElseStatement() const { return !else_statement()->IsEmpty(); }
1166 1182
1167 Expression* condition() const { return condition_; } 1183 Expression* condition() const { return condition_; }
1168 Statement* then_statement() const { return then_statement_; } 1184 Statement* then_statement() const { return then_statement_; }
1169 Statement* else_statement() const { return else_statement_; } 1185 Statement* else_statement() const { return else_statement_; }
1170 1186
1187 virtual bool IsJump() const {
1188 return HasThenStatement() && then_statement()->IsJump()
1189 && HasElseStatement() && else_statement()->IsJump();
1190 }
1191
1171 BailoutId IfId() const { return if_id_; } 1192 BailoutId IfId() const { return if_id_; }
1172 BailoutId ThenId() const { return then_id_; } 1193 BailoutId ThenId() const { return then_id_; }
1173 BailoutId ElseId() const { return else_id_; } 1194 BailoutId ElseId() const { return else_id_; }
1174 1195
1175 protected: 1196 protected:
1176 IfStatement(Isolate* isolate, 1197 IfStatement(Isolate* isolate,
1177 Expression* condition, 1198 Expression* condition,
1178 Statement* then_statement, 1199 Statement* then_statement,
1179 Statement* else_statement) 1200 Statement* else_statement)
1180 : condition_(condition), 1201 : condition_(condition),
(...skipping 2028 matching lines...) Expand 10 before | Expand all | Expand 10 after
3209 private: 3230 private:
3210 Isolate* isolate_; 3231 Isolate* isolate_;
3211 Zone* zone_; 3232 Zone* zone_;
3212 Visitor visitor_; 3233 Visitor visitor_;
3213 }; 3234 };
3214 3235
3215 3236
3216 } } // namespace v8::internal 3237 } } // namespace v8::internal
3217 3238
3218 #endif // V8_AST_H_ 3239 #endif // V8_AST_H_
OLDNEW
« no previous file with comments | « no previous file | src/typing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698