| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef VM_AST_H_ | 5 #ifndef VM_AST_H_ |
| 6 #define VM_AST_H_ | 6 #define VM_AST_H_ |
| 7 | 7 |
| 8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 #include "vm/allocation.h" | 9 #include "vm/allocation.h" |
| 10 #include "vm/growable_array.h" | 10 #include "vm/growable_array.h" |
| (...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 | 517 |
| 518 // TODO(mlippautz): Implement return nodes that are used to return from a | 518 // TODO(mlippautz): Implement return nodes that are used to return from a |
| 519 // continuation. | 519 // continuation. |
| 520 class ReturnNode : public AstNode { | 520 class ReturnNode : public AstNode { |
| 521 public: | 521 public: |
| 522 // Return from a void function returns the null object. | 522 // Return from a void function returns the null object. |
| 523 explicit ReturnNode(intptr_t token_pos) | 523 explicit ReturnNode(intptr_t token_pos) |
| 524 : AstNode(token_pos), | 524 : AstNode(token_pos), |
| 525 value_(new LiteralNode(token_pos, Instance::ZoneHandle())), | 525 value_(new LiteralNode(token_pos, Instance::ZoneHandle())), |
| 526 inlined_finally_list_(), | 526 inlined_finally_list_(), |
| 527 saved_return_value_var_(NULL), | |
| 528 is_regular_return_(true) { } | 527 is_regular_return_(true) { } |
| 529 // Return from a non-void function. | 528 // Return from a non-void function. |
| 530 ReturnNode(intptr_t token_pos, | 529 ReturnNode(intptr_t token_pos, |
| 531 AstNode* value) | 530 AstNode* value) |
| 532 : AstNode(token_pos), | 531 : AstNode(token_pos), |
| 533 value_(value), | 532 value_(value), |
| 534 inlined_finally_list_(), | 533 inlined_finally_list_(), |
| 535 saved_return_value_var_(NULL), | |
| 536 is_regular_return_(true) { | 534 is_regular_return_(true) { |
| 537 ASSERT(value_ != NULL); | 535 ASSERT(value_ != NULL); |
| 538 } | 536 } |
| 539 | 537 |
| 540 AstNode* value() const { return value_; } | 538 AstNode* value() const { return value_; } |
| 541 | 539 |
| 542 intptr_t inlined_finally_list_length() const { | 540 intptr_t inlined_finally_list_length() const { |
| 543 return inlined_finally_list_.length(); | 541 return inlined_finally_list_.length(); |
| 544 } | 542 } |
| 545 InlinedFinallyNode* InlinedFinallyNodeAt(intptr_t index) const { | 543 InlinedFinallyNode* InlinedFinallyNodeAt(intptr_t index) const { |
| 546 return inlined_finally_list_[index]; | 544 return inlined_finally_list_[index]; |
| 547 } | 545 } |
| 548 void AddInlinedFinallyNode(InlinedFinallyNode* finally_node) { | 546 void AddInlinedFinallyNode(InlinedFinallyNode* finally_node) { |
| 549 inlined_finally_list_.Add(finally_node); | 547 inlined_finally_list_.Add(finally_node); |
| 550 } | 548 } |
| 551 | 549 |
| 552 LocalVariable* saved_return_value_var() const { | |
| 553 return saved_return_value_var_; | |
| 554 } | |
| 555 void set_saved_return_value_var(LocalVariable* var) { | |
| 556 saved_return_value_var_ = var; | |
| 557 } | |
| 558 | |
| 559 virtual void VisitChildren(AstNodeVisitor* visitor) const { | 550 virtual void VisitChildren(AstNodeVisitor* visitor) const { |
| 560 if (value() != NULL) { | 551 if (value() != NULL) { |
| 561 value()->Visit(visitor); | 552 value()->Visit(visitor); |
| 562 } | 553 } |
| 563 } | 554 } |
| 564 | 555 |
| 565 void set_scope(LocalScope* scope) { scope_ = scope; } | 556 void set_scope(LocalScope* scope) { scope_ = scope; } |
| 566 LocalScope* scope() const { return scope_; } | 557 LocalScope* scope() const { return scope_; } |
| 567 | 558 |
| 568 // Returns false if the return node is used to return from a continuation. | 559 // Returns false if the return node is used to return from a continuation. |
| 569 bool is_regular_return() const { return is_regular_return_; } | 560 bool is_regular_return() const { return is_regular_return_; } |
| 570 | 561 |
| 571 DECLARE_COMMON_NODE_FUNCTIONS(ReturnNode); | 562 DECLARE_COMMON_NODE_FUNCTIONS(ReturnNode); |
| 572 | 563 |
| 573 private: | 564 private: |
| 574 AstNode* value_; | 565 AstNode* value_; |
| 575 GrowableArray<InlinedFinallyNode*> inlined_finally_list_; | 566 GrowableArray<InlinedFinallyNode*> inlined_finally_list_; |
| 576 LocalVariable* saved_return_value_var_; | |
| 577 LocalScope* scope_; | 567 LocalScope* scope_; |
| 578 bool is_regular_return_; | 568 bool is_regular_return_; |
| 579 | 569 |
| 580 DISALLOW_COPY_AND_ASSIGN(ReturnNode); | 570 DISALLOW_COPY_AND_ASSIGN(ReturnNode); |
| 581 }; | 571 }; |
| 582 | 572 |
| 583 | 573 |
| 584 class ComparisonNode : public AstNode { | 574 class ComparisonNode : public AstNode { |
| 585 public: | 575 public: |
| 586 ComparisonNode(intptr_t token_pos, | 576 ComparisonNode(intptr_t token_pos, |
| (...skipping 1229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1816 const intptr_t try_index_; | 1806 const intptr_t try_index_; |
| 1817 | 1807 |
| 1818 DISALLOW_IMPLICIT_CONSTRUCTORS(InlinedFinallyNode); | 1808 DISALLOW_IMPLICIT_CONSTRUCTORS(InlinedFinallyNode); |
| 1819 }; | 1809 }; |
| 1820 | 1810 |
| 1821 } // namespace dart | 1811 } // namespace dart |
| 1822 | 1812 |
| 1823 #undef DECLARE_COMMON_NODE_FUNCTIONS | 1813 #undef DECLARE_COMMON_NODE_FUNCTIONS |
| 1824 | 1814 |
| 1825 #endif // VM_AST_H_ | 1815 #endif // VM_AST_H_ |
| OLD | NEW |