Chromium Code Reviews| 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 155 label_(NULL) { | 155 label_(NULL) { |
| 156 } | 156 } |
| 157 | 157 |
| 158 LocalScope* scope() const { return scope_; } | 158 LocalScope* scope() const { return scope_; } |
| 159 | 159 |
| 160 SourceLabel* label() const { return label_; } | 160 SourceLabel* label() const { return label_; } |
| 161 void set_label(SourceLabel* value) { label_ = value; } | 161 void set_label(SourceLabel* value) { label_ = value; } |
| 162 | 162 |
| 163 void VisitChildren(AstNodeVisitor* visitor) const; | 163 void VisitChildren(AstNodeVisitor* visitor) const; |
| 164 | 164 |
| 165 void Add(AstNode* node) { nodes_.Add(node); } | 165 void Add(AstNode* node); |
| 166 intptr_t length() const { return nodes_.length(); } | 166 intptr_t length() const { return nodes_.length(); } |
| 167 AstNode* NodeAt(intptr_t index) const { return nodes_[index]; } | 167 AstNode* NodeAt(intptr_t index) const { return nodes_[index]; } |
| 168 void ReplaceNodeAt(intptr_t index, AstNode* value) { nodes_[index] = value; } | 168 void ReplaceNodeAt(intptr_t index, AstNode* value) { nodes_[index] = value; } |
| 169 | 169 |
| 170 DECLARE_COMMON_NODE_FUNCTIONS(SequenceNode); | 170 DECLARE_COMMON_NODE_FUNCTIONS(SequenceNode); |
| 171 | 171 |
| 172 // Collects all nodes accessible from this sequence node into array 'nodes'. | 172 // Collects all nodes accessible from this sequence node into array 'nodes'. |
| 173 void CollectAllNodes(GrowableArray<AstNode*>* nodes); | 173 void CollectAllNodes(GrowableArray<AstNode*>* nodes); |
| 174 | 174 |
| 175 private: | 175 private: |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 515 }; | 515 }; |
| 516 | 516 |
| 517 | 517 |
| 518 class ReturnNode : public AstNode { | 518 class ReturnNode : public AstNode { |
| 519 public: | 519 public: |
| 520 // Return from a void function returns the null object. | 520 // Return from a void function returns the null object. |
| 521 explicit ReturnNode(intptr_t token_pos) | 521 explicit ReturnNode(intptr_t token_pos) |
| 522 : AstNode(token_pos), | 522 : AstNode(token_pos), |
| 523 value_(new LiteralNode(token_pos, Instance::ZoneHandle())), | 523 value_(new LiteralNode(token_pos, Instance::ZoneHandle())), |
| 524 inlined_finally_list_(), | 524 inlined_finally_list_(), |
| 525 saved_return_value_var_(NULL) { } | 525 saved_return_value_var_(NULL), |
| 526 is_regular_return_(true) { } | |
| 526 // Return from a non-void function. | 527 // Return from a non-void function. |
| 527 ReturnNode(intptr_t token_pos, | 528 ReturnNode(intptr_t token_pos, |
| 528 AstNode* value) | 529 AstNode* value) |
| 529 : AstNode(token_pos), | 530 : AstNode(token_pos), |
| 530 value_(value), | 531 value_(value), |
| 531 inlined_finally_list_(), | 532 inlined_finally_list_(), |
| 532 saved_return_value_var_(NULL) { | 533 saved_return_value_var_(NULL), |
| 534 is_regular_return_(true) { | |
| 533 ASSERT(value_ != NULL); | 535 ASSERT(value_ != NULL); |
| 534 } | 536 } |
| 535 | 537 |
| 536 AstNode* value() const { return value_; } | 538 AstNode* value() const { return value_; } |
| 537 | 539 |
| 538 intptr_t inlined_finally_list_length() const { | 540 intptr_t inlined_finally_list_length() const { |
| 539 return inlined_finally_list_.length(); | 541 return inlined_finally_list_.length(); |
| 540 } | 542 } |
| 541 InlinedFinallyNode* InlinedFinallyNodeAt(intptr_t index) const { | 543 InlinedFinallyNode* InlinedFinallyNodeAt(intptr_t index) const { |
| 542 return inlined_finally_list_[index]; | 544 return inlined_finally_list_[index]; |
| 543 } | 545 } |
| 544 void AddInlinedFinallyNode(InlinedFinallyNode* finally_node) { | 546 void AddInlinedFinallyNode(InlinedFinallyNode* finally_node) { |
| 545 inlined_finally_list_.Add(finally_node); | 547 inlined_finally_list_.Add(finally_node); |
| 546 } | 548 } |
| 547 | 549 |
| 548 LocalVariable* saved_return_value_var() const { | 550 LocalVariable* saved_return_value_var() const { |
| 549 return saved_return_value_var_; | 551 return saved_return_value_var_; |
| 550 } | 552 } |
| 551 void set_saved_return_value_var(LocalVariable* var) { | 553 void set_saved_return_value_var(LocalVariable* var) { |
| 552 saved_return_value_var_ = var; | 554 saved_return_value_var_ = var; |
| 553 } | 555 } |
| 554 | 556 |
| 555 virtual void VisitChildren(AstNodeVisitor* visitor) const { | 557 virtual void VisitChildren(AstNodeVisitor* visitor) const { |
| 556 if (value() != NULL) { | 558 if (value() != NULL) { |
| 557 value()->Visit(visitor); | 559 value()->Visit(visitor); |
| 558 } | 560 } |
| 559 } | 561 } |
| 560 | 562 |
| 563 void set_scope(LocalScope* scope) { scope_ = scope; } | |
| 564 LocalScope* scope() const { return scope_; } | |
| 565 | |
| 566 // Returns true if the return node is not used to return from a continuation. | |
|
srdjan
2014/08/12 21:39:24
Simplify: returns false if the return node is used
Michael Lippautz (Google)
2014/08/12 21:50:51
Done.
| |
| 567 bool is_regular_return() const { return is_regular_return_; } | |
| 568 | |
| 561 DECLARE_COMMON_NODE_FUNCTIONS(ReturnNode); | 569 DECLARE_COMMON_NODE_FUNCTIONS(ReturnNode); |
| 562 | 570 |
| 563 private: | 571 private: |
| 564 AstNode* value_; | 572 AstNode* value_; |
| 565 GrowableArray<InlinedFinallyNode*> inlined_finally_list_; | 573 GrowableArray<InlinedFinallyNode*> inlined_finally_list_; |
| 566 LocalVariable* saved_return_value_var_; | 574 LocalVariable* saved_return_value_var_; |
| 575 LocalScope* scope_; | |
| 576 bool is_regular_return_; | |
| 567 | 577 |
| 568 DISALLOW_COPY_AND_ASSIGN(ReturnNode); | 578 DISALLOW_COPY_AND_ASSIGN(ReturnNode); |
| 569 }; | 579 }; |
| 570 | 580 |
| 571 | 581 |
| 572 class ComparisonNode : public AstNode { | 582 class ComparisonNode : public AstNode { |
| 573 public: | 583 public: |
| 574 ComparisonNode(intptr_t token_pos, | 584 ComparisonNode(intptr_t token_pos, |
| 575 Token::Kind kind, | 585 Token::Kind kind, |
| 576 AstNode* left, | 586 AstNode* left, |
| (...skipping 1227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1804 const intptr_t try_index_; | 1814 const intptr_t try_index_; |
| 1805 | 1815 |
| 1806 DISALLOW_IMPLICIT_CONSTRUCTORS(InlinedFinallyNode); | 1816 DISALLOW_IMPLICIT_CONSTRUCTORS(InlinedFinallyNode); |
| 1807 }; | 1817 }; |
| 1808 | 1818 |
| 1809 } // namespace dart | 1819 } // namespace dart |
| 1810 | 1820 |
| 1811 #undef DECLARE_COMMON_NODE_FUNCTIONS | 1821 #undef DECLARE_COMMON_NODE_FUNCTIONS |
| 1812 | 1822 |
| 1813 #endif // VM_AST_H_ | 1823 #endif // VM_AST_H_ |
| OLD | NEW |