| 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 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 508 DECLARE_COMMON_NODE_FUNCTIONS(PrimaryNode); | 508 DECLARE_COMMON_NODE_FUNCTIONS(PrimaryNode); |
| 509 | 509 |
| 510 private: | 510 private: |
| 511 const Object& primary_; | 511 const Object& primary_; |
| 512 bool is_deferred_reference_; | 512 bool is_deferred_reference_; |
| 513 | 513 |
| 514 DISALLOW_IMPLICIT_CONSTRUCTORS(PrimaryNode); | 514 DISALLOW_IMPLICIT_CONSTRUCTORS(PrimaryNode); |
| 515 }; | 515 }; |
| 516 | 516 |
| 517 | 517 |
| 518 // TODO(mlippautz): Implement return nodes that are used to return from a |
| 519 // continuation. |
| 518 class ReturnNode : public AstNode { | 520 class ReturnNode : public AstNode { |
| 519 public: | 521 public: |
| 520 // Return from a void function returns the null object. | 522 // Return from a void function returns the null object. |
| 521 explicit ReturnNode(intptr_t token_pos) | 523 explicit ReturnNode(intptr_t token_pos) |
| 522 : AstNode(token_pos), | 524 : AstNode(token_pos), |
| 523 value_(new LiteralNode(token_pos, Instance::ZoneHandle())), | 525 value_(new LiteralNode(token_pos, Instance::ZoneHandle())), |
| 524 inlined_finally_list_(), | 526 inlined_finally_list_(), |
| 525 saved_return_value_var_(NULL) { } | 527 saved_return_value_var_(NULL), |
| 528 is_regular_return_(true) { } |
| 526 // Return from a non-void function. | 529 // Return from a non-void function. |
| 527 ReturnNode(intptr_t token_pos, | 530 ReturnNode(intptr_t token_pos, |
| 528 AstNode* value) | 531 AstNode* value) |
| 529 : AstNode(token_pos), | 532 : AstNode(token_pos), |
| 530 value_(value), | 533 value_(value), |
| 531 inlined_finally_list_(), | 534 inlined_finally_list_(), |
| 532 saved_return_value_var_(NULL) { | 535 saved_return_value_var_(NULL), |
| 536 is_regular_return_(true) { |
| 533 ASSERT(value_ != NULL); | 537 ASSERT(value_ != NULL); |
| 534 } | 538 } |
| 535 | 539 |
| 536 AstNode* value() const { return value_; } | 540 AstNode* value() const { return value_; } |
| 537 | 541 |
| 538 intptr_t inlined_finally_list_length() const { | 542 intptr_t inlined_finally_list_length() const { |
| 539 return inlined_finally_list_.length(); | 543 return inlined_finally_list_.length(); |
| 540 } | 544 } |
| 541 InlinedFinallyNode* InlinedFinallyNodeAt(intptr_t index) const { | 545 InlinedFinallyNode* InlinedFinallyNodeAt(intptr_t index) const { |
| 542 return inlined_finally_list_[index]; | 546 return inlined_finally_list_[index]; |
| 543 } | 547 } |
| 544 void AddInlinedFinallyNode(InlinedFinallyNode* finally_node) { | 548 void AddInlinedFinallyNode(InlinedFinallyNode* finally_node) { |
| 545 inlined_finally_list_.Add(finally_node); | 549 inlined_finally_list_.Add(finally_node); |
| 546 } | 550 } |
| 547 | 551 |
| 548 LocalVariable* saved_return_value_var() const { | 552 LocalVariable* saved_return_value_var() const { |
| 549 return saved_return_value_var_; | 553 return saved_return_value_var_; |
| 550 } | 554 } |
| 551 void set_saved_return_value_var(LocalVariable* var) { | 555 void set_saved_return_value_var(LocalVariable* var) { |
| 552 saved_return_value_var_ = var; | 556 saved_return_value_var_ = var; |
| 553 } | 557 } |
| 554 | 558 |
| 555 virtual void VisitChildren(AstNodeVisitor* visitor) const { | 559 virtual void VisitChildren(AstNodeVisitor* visitor) const { |
| 556 if (value() != NULL) { | 560 if (value() != NULL) { |
| 557 value()->Visit(visitor); | 561 value()->Visit(visitor); |
| 558 } | 562 } |
| 559 } | 563 } |
| 560 | 564 |
| 565 void set_scope(LocalScope* scope) { scope_ = scope; } |
| 566 LocalScope* scope() const { return scope_; } |
| 567 |
| 568 // Returns false if the return node is used to return from a continuation. |
| 569 bool is_regular_return() const { return is_regular_return_; } |
| 570 |
| 561 DECLARE_COMMON_NODE_FUNCTIONS(ReturnNode); | 571 DECLARE_COMMON_NODE_FUNCTIONS(ReturnNode); |
| 562 | 572 |
| 563 private: | 573 private: |
| 564 AstNode* value_; | 574 AstNode* value_; |
| 565 GrowableArray<InlinedFinallyNode*> inlined_finally_list_; | 575 GrowableArray<InlinedFinallyNode*> inlined_finally_list_; |
| 566 LocalVariable* saved_return_value_var_; | 576 LocalVariable* saved_return_value_var_; |
| 577 LocalScope* scope_; |
| 578 bool is_regular_return_; |
| 567 | 579 |
| 568 DISALLOW_COPY_AND_ASSIGN(ReturnNode); | 580 DISALLOW_COPY_AND_ASSIGN(ReturnNode); |
| 569 }; | 581 }; |
| 570 | 582 |
| 571 | 583 |
| 572 class ComparisonNode : public AstNode { | 584 class ComparisonNode : public AstNode { |
| 573 public: | 585 public: |
| 574 ComparisonNode(intptr_t token_pos, | 586 ComparisonNode(intptr_t token_pos, |
| 575 Token::Kind kind, | 587 Token::Kind kind, |
| 576 AstNode* left, | 588 AstNode* left, |
| (...skipping 1227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1804 const intptr_t try_index_; | 1816 const intptr_t try_index_; |
| 1805 | 1817 |
| 1806 DISALLOW_IMPLICIT_CONSTRUCTORS(InlinedFinallyNode); | 1818 DISALLOW_IMPLICIT_CONSTRUCTORS(InlinedFinallyNode); |
| 1807 }; | 1819 }; |
| 1808 | 1820 |
| 1809 } // namespace dart | 1821 } // namespace dart |
| 1810 | 1822 |
| 1811 #undef DECLARE_COMMON_NODE_FUNCTIONS | 1823 #undef DECLARE_COMMON_NODE_FUNCTIONS |
| 1812 | 1824 |
| 1813 #endif // VM_AST_H_ | 1825 #endif // VM_AST_H_ |
| OLD | NEW |