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 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 DISALLOW_IMPLICIT_CONSTRUCTORS(PrimaryNode); | 502 DISALLOW_IMPLICIT_CONSTRUCTORS(PrimaryNode); |
503 }; | 503 }; |
504 | 504 |
505 | 505 |
506 class ReturnNode : public AstNode { | 506 class ReturnNode : public AstNode { |
507 public: | 507 public: |
508 // Return from a void function returns the null object. | 508 // Return from a void function returns the null object. |
509 explicit ReturnNode(intptr_t token_pos) | 509 explicit ReturnNode(intptr_t token_pos) |
510 : AstNode(token_pos), | 510 : AstNode(token_pos), |
511 value_(new LiteralNode(token_pos, Instance::ZoneHandle())), | 511 value_(new LiteralNode(token_pos, Instance::ZoneHandle())), |
512 inlined_finally_list_() { } | 512 inlined_finally_list_(), |
| 513 saved_return_value_var_(NULL) { } |
513 // Return from a non-void function. | 514 // Return from a non-void function. |
514 ReturnNode(intptr_t token_pos, | 515 ReturnNode(intptr_t token_pos, |
515 AstNode* value) | 516 AstNode* value) |
516 : AstNode(token_pos), value_(value), inlined_finally_list_() { | 517 : AstNode(token_pos), |
| 518 value_(value), |
| 519 inlined_finally_list_(), |
| 520 saved_return_value_var_(NULL) { |
517 ASSERT(value_ != NULL); | 521 ASSERT(value_ != NULL); |
518 } | 522 } |
519 | 523 |
520 AstNode* value() const { return value_; } | 524 AstNode* value() const { return value_; } |
521 | 525 |
522 intptr_t inlined_finally_list_length() const { | 526 intptr_t inlined_finally_list_length() const { |
523 return inlined_finally_list_.length(); | 527 return inlined_finally_list_.length(); |
524 } | 528 } |
525 InlinedFinallyNode* InlinedFinallyNodeAt(intptr_t index) const { | 529 InlinedFinallyNode* InlinedFinallyNodeAt(intptr_t index) const { |
526 return inlined_finally_list_[index]; | 530 return inlined_finally_list_[index]; |
527 } | 531 } |
528 void AddInlinedFinallyNode(InlinedFinallyNode* finally_node) { | 532 void AddInlinedFinallyNode(InlinedFinallyNode* finally_node) { |
529 inlined_finally_list_.Add(finally_node); | 533 inlined_finally_list_.Add(finally_node); |
530 } | 534 } |
531 | 535 |
| 536 LocalVariable* saved_return_value_var() const { |
| 537 return saved_return_value_var_; |
| 538 } |
| 539 void set_saved_return_value_var(LocalVariable* var) { |
| 540 saved_return_value_var_ = var; |
| 541 } |
| 542 |
532 virtual void VisitChildren(AstNodeVisitor* visitor) const { | 543 virtual void VisitChildren(AstNodeVisitor* visitor) const { |
533 if (value() != NULL) { | 544 if (value() != NULL) { |
534 value()->Visit(visitor); | 545 value()->Visit(visitor); |
535 } | 546 } |
536 } | 547 } |
537 | 548 |
538 DECLARE_COMMON_NODE_FUNCTIONS(ReturnNode); | 549 DECLARE_COMMON_NODE_FUNCTIONS(ReturnNode); |
539 | 550 |
540 private: | 551 private: |
541 AstNode* value_; | 552 AstNode* value_; |
542 GrowableArray<InlinedFinallyNode*> inlined_finally_list_; | 553 GrowableArray<InlinedFinallyNode*> inlined_finally_list_; |
| 554 LocalVariable* saved_return_value_var_; |
543 | 555 |
544 DISALLOW_COPY_AND_ASSIGN(ReturnNode); | 556 DISALLOW_COPY_AND_ASSIGN(ReturnNode); |
545 }; | 557 }; |
546 | 558 |
547 | 559 |
548 class ComparisonNode : public AstNode { | 560 class ComparisonNode : public AstNode { |
549 public: | 561 public: |
550 ComparisonNode(intptr_t token_pos, | 562 ComparisonNode(intptr_t token_pos, |
551 Token::Kind kind, | 563 Token::Kind kind, |
552 AstNode* left, | 564 AstNode* left, |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1000 const char* TokenName() const; | 1012 const char* TokenName() const; |
1001 | 1013 |
1002 virtual void VisitChildren(AstNodeVisitor* visitor) const { } | 1014 virtual void VisitChildren(AstNodeVisitor* visitor) const { } |
1003 | 1015 |
1004 DECLARE_COMMON_NODE_FUNCTIONS(JumpNode); | 1016 DECLARE_COMMON_NODE_FUNCTIONS(JumpNode); |
1005 | 1017 |
1006 private: | 1018 private: |
1007 Token::Kind kind_; | 1019 Token::Kind kind_; |
1008 SourceLabel* label_; | 1020 SourceLabel* label_; |
1009 GrowableArray<InlinedFinallyNode*> inlined_finally_list_; | 1021 GrowableArray<InlinedFinallyNode*> inlined_finally_list_; |
| 1022 |
1010 DISALLOW_IMPLICIT_CONSTRUCTORS(JumpNode); | 1023 DISALLOW_IMPLICIT_CONSTRUCTORS(JumpNode); |
1011 }; | 1024 }; |
1012 | 1025 |
1013 | 1026 |
1014 class LoadLocalNode : public AstNode { | 1027 class LoadLocalNode : public AstNode { |
1015 public: | 1028 public: |
1016 LoadLocalNode(intptr_t token_pos, const LocalVariable* local) | 1029 LoadLocalNode(intptr_t token_pos, const LocalVariable* local) |
1017 : AstNode(token_pos), local_(*local) { | 1030 : AstNode(token_pos), local_(*local) { |
1018 ASSERT(local != NULL); | 1031 ASSERT(local != NULL); |
1019 } | 1032 } |
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1773 const intptr_t try_index_; | 1786 const intptr_t try_index_; |
1774 | 1787 |
1775 DISALLOW_IMPLICIT_CONSTRUCTORS(InlinedFinallyNode); | 1788 DISALLOW_IMPLICIT_CONSTRUCTORS(InlinedFinallyNode); |
1776 }; | 1789 }; |
1777 | 1790 |
1778 } // namespace dart | 1791 } // namespace dart |
1779 | 1792 |
1780 #undef DECLARE_COMMON_NODE_FUNCTIONS | 1793 #undef DECLARE_COMMON_NODE_FUNCTIONS |
1781 | 1794 |
1782 #endif // VM_AST_H_ | 1795 #endif // VM_AST_H_ |
OLD | NEW |