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 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
273 int position_; | 273 int position_; |
274 }; | 274 }; |
275 | 275 |
276 | 276 |
277 class Statement : public AstNode { | 277 class Statement : public AstNode { |
278 public: | 278 public: |
279 explicit Statement(Zone* zone, int position) : AstNode(position) {} | 279 explicit Statement(Zone* zone, int position) : AstNode(position) {} |
280 | 280 |
281 bool IsEmpty() { return AsEmptyStatement() != NULL; } | 281 bool IsEmpty() { return AsEmptyStatement() != NULL; } |
282 virtual bool IsJump() const { return false; } | 282 virtual bool IsJump() const { return false; } |
283 virtual bool IsStrongSwitchTerminatingStatement() const { return false; } | |
rossberg
2015/04/14 20:19:49
I'm tempted to get rid of this and just use IsJump
conradw
2015/04/15 11:40:03
Done.
| |
283 }; | 284 }; |
284 | 285 |
285 | 286 |
286 class SmallMapList FINAL { | 287 class SmallMapList FINAL { |
287 public: | 288 public: |
288 SmallMapList() {} | 289 SmallMapList() {} |
289 SmallMapList(int capacity, Zone* zone) : list_(capacity, zone) {} | 290 SmallMapList(int capacity, Zone* zone) : list_(capacity, zone) {} |
290 | 291 |
291 void Reserve(int capacity, Zone* zone) { list_.Reserve(capacity, zone); } | 292 void Reserve(int capacity, Zone* zone) { list_.Reserve(capacity, zone); } |
292 void Clear() { list_.Clear(); } | 293 void Clear() { list_.Clear(); } |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
507 ZoneList<Statement*>* statements() { return &statements_; } | 508 ZoneList<Statement*>* statements() { return &statements_; } |
508 bool is_initializer_block() const { return is_initializer_block_; } | 509 bool is_initializer_block() const { return is_initializer_block_; } |
509 | 510 |
510 static int num_ids() { return parent_num_ids() + 1; } | 511 static int num_ids() { return parent_num_ids() + 1; } |
511 BailoutId DeclsId() const { return BailoutId(local_id(0)); } | 512 BailoutId DeclsId() const { return BailoutId(local_id(0)); } |
512 | 513 |
513 bool IsJump() const OVERRIDE { | 514 bool IsJump() const OVERRIDE { |
514 return !statements_.is_empty() && statements_.last()->IsJump() | 515 return !statements_.is_empty() && statements_.last()->IsJump() |
515 && labels() == NULL; // Good enough as an approximation... | 516 && labels() == NULL; // Good enough as an approximation... |
516 } | 517 } |
518 bool IsStrongSwitchTerminatingStatement() const OVERRIDE { | |
519 return IsJump(); | |
520 } | |
517 | 521 |
518 Scope* scope() const { return scope_; } | 522 Scope* scope() const { return scope_; } |
519 void set_scope(Scope* scope) { scope_ = scope; } | 523 void set_scope(Scope* scope) { scope_ = scope; } |
520 | 524 |
521 protected: | 525 protected: |
522 Block(Zone* zone, ZoneList<const AstRawString*>* labels, int capacity, | 526 Block(Zone* zone, ZoneList<const AstRawString*>* labels, int capacity, |
523 bool is_initializer_block, int pos) | 527 bool is_initializer_block, int pos) |
524 : BreakableStatement(zone, labels, TARGET_FOR_NAMED_ONLY, pos), | 528 : BreakableStatement(zone, labels, TARGET_FOR_NAMED_ONLY, pos), |
525 statements_(capacity, zone), | 529 statements_(capacity, zone), |
526 is_initializer_block_(is_initializer_block), | 530 is_initializer_block_(is_initializer_block), |
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1012 }; | 1016 }; |
1013 | 1017 |
1014 | 1018 |
1015 class ExpressionStatement FINAL : public Statement { | 1019 class ExpressionStatement FINAL : public Statement { |
1016 public: | 1020 public: |
1017 DECLARE_NODE_TYPE(ExpressionStatement) | 1021 DECLARE_NODE_TYPE(ExpressionStatement) |
1018 | 1022 |
1019 void set_expression(Expression* e) { expression_ = e; } | 1023 void set_expression(Expression* e) { expression_ = e; } |
1020 Expression* expression() const { return expression_; } | 1024 Expression* expression() const { return expression_; } |
1021 bool IsJump() const OVERRIDE { return expression_->IsThrow(); } | 1025 bool IsJump() const OVERRIDE { return expression_->IsThrow(); } |
1026 bool IsStrongSwitchTerminatingStatement() const OVERRIDE { return IsJump(); } | |
1022 | 1027 |
1023 protected: | 1028 protected: |
1024 ExpressionStatement(Zone* zone, Expression* expression, int pos) | 1029 ExpressionStatement(Zone* zone, Expression* expression, int pos) |
1025 : Statement(zone, pos), expression_(expression) { } | 1030 : Statement(zone, pos), expression_(expression) { } |
1026 | 1031 |
1027 private: | 1032 private: |
1028 Expression* expression_; | 1033 Expression* expression_; |
1029 }; | 1034 }; |
1030 | 1035 |
1031 | 1036 |
1032 class JumpStatement : public Statement { | 1037 class JumpStatement : public Statement { |
1033 public: | 1038 public: |
1034 bool IsJump() const FINAL { return true; } | 1039 bool IsJump() const FINAL { return true; } |
1040 bool IsStrongSwitchTerminatingStatement() const FINAL { return true; } | |
1035 | 1041 |
1036 protected: | 1042 protected: |
1037 explicit JumpStatement(Zone* zone, int pos) : Statement(zone, pos) {} | 1043 explicit JumpStatement(Zone* zone, int pos) : Statement(zone, pos) {} |
1038 }; | 1044 }; |
1039 | 1045 |
1040 | 1046 |
1041 class ContinueStatement FINAL : public JumpStatement { | 1047 class ContinueStatement FINAL : public JumpStatement { |
1042 public: | 1048 public: |
1043 DECLARE_NODE_TYPE(ContinueStatement) | 1049 DECLARE_NODE_TYPE(ContinueStatement) |
1044 | 1050 |
(...skipping 2532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3577 | 3583 |
3578 private: | 3584 private: |
3579 Zone* zone_; | 3585 Zone* zone_; |
3580 AstValueFactory* ast_value_factory_; | 3586 AstValueFactory* ast_value_factory_; |
3581 }; | 3587 }; |
3582 | 3588 |
3583 | 3589 |
3584 } } // namespace v8::internal | 3590 } } // namespace v8::internal |
3585 | 3591 |
3586 #endif // V8_AST_H_ | 3592 #endif // V8_AST_H_ |
OLD | NEW |