| 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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 DECLARE_COMMON_NODE_FUNCTIONS(AwaitNode); | 163 DECLARE_COMMON_NODE_FUNCTIONS(AwaitNode); |
| 164 | 164 |
| 165 private: | 165 private: |
| 166 AstNode* expr_; | 166 AstNode* expr_; |
| 167 | 167 |
| 168 DISALLOW_COPY_AND_ASSIGN(AwaitNode); | 168 DISALLOW_COPY_AND_ASSIGN(AwaitNode); |
| 169 }; | 169 }; |
| 170 | 170 |
| 171 | 171 |
| 172 // AwaitMarker nodes are used to generate markers that the FlowGraphBuilder | 172 // AwaitMarker nodes are used to generate markers that the FlowGraphBuilder |
| 173 // relies on. They can occur in two kinds: | 173 // relies on. A marker indicates that a new await state needs to be |
| 174 // 1) kNewContinuationState: A marker indicating that a new await state needs to | 174 // added to a function preamble. This type also triggers storing of the |
| 175 // be added to a function preamble. This type also triggers storing of the | 175 // current context. |
| 176 // current context. | |
| 177 // 2) kTargetForContinuation: A marker indicating an entry point for the most | |
| 178 // recent generated state. | |
| 179 // | 176 // |
| 180 // In general it is expected (ASSERT) that the different kinds of markers reach | 177 // It is expected (ASSERT) that an AwaitMarker is followed by |
| 181 // the FlowGraphBuilder in alternating order. That is: | 178 // a return node of kind kContinuationTarget. That is: |
| 182 // <new state> -> <other nodes> -> <target> -> <other nodes> -> | 179 // <AwaitMarker> -> <other nodes> -> <kContinuationTarget> -> <other nodes> -> |
| 183 // <new state> -> ... | 180 // <AwaitMarker> -> ... |
| 184 class AwaitMarkerNode : public AstNode { | 181 class AwaitMarkerNode : public AstNode { |
| 185 public: | 182 public: |
| 186 enum MarkerType { | 183 AwaitMarkerNode() : AstNode(Scanner::kNoSourcePos) { } |
| 187 kNewContinuationState, | |
| 188 kTargetForContinuation, | |
| 189 }; | |
| 190 | |
| 191 explicit AwaitMarkerNode(MarkerType marker_type) | |
| 192 : AstNode(Scanner::kNoSourcePos), | |
| 193 marker_type_(marker_type) { } | |
| 194 | 184 |
| 195 void VisitChildren(AstNodeVisitor* visitor) const { } | 185 void VisitChildren(AstNodeVisitor* visitor) const { } |
| 196 | 186 |
| 197 MarkerType marker_type() const { | |
| 198 return marker_type_; | |
| 199 } | |
| 200 | |
| 201 LocalScope* scope() const { return scope_; } | 187 LocalScope* scope() const { return scope_; } |
| 202 void set_scope(LocalScope* scope) { scope_ = scope; } | 188 void set_scope(LocalScope* scope) { scope_ = scope; } |
| 203 | 189 |
| 204 DECLARE_COMMON_NODE_FUNCTIONS(AwaitMarkerNode); | 190 DECLARE_COMMON_NODE_FUNCTIONS(AwaitMarkerNode); |
| 205 | 191 |
| 206 private: | 192 private: |
| 207 MarkerType marker_type_; | |
| 208 LocalScope* scope_; | 193 LocalScope* scope_; |
| 209 | 194 |
| 210 DISALLOW_COPY_AND_ASSIGN(AwaitMarkerNode); | 195 DISALLOW_COPY_AND_ASSIGN(AwaitMarkerNode); |
| 211 }; | 196 }; |
| 212 | 197 |
| 213 | 198 |
| 214 class SequenceNode : public AstNode { | 199 class SequenceNode : public AstNode { |
| 215 public: | 200 public: |
| 216 SequenceNode(intptr_t token_pos, LocalScope* scope) | 201 SequenceNode(intptr_t token_pos, LocalScope* scope) |
| 217 : AstNode(token_pos), | 202 : AstNode(token_pos), |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 572 | 557 |
| 573 DECLARE_COMMON_NODE_FUNCTIONS(PrimaryNode); | 558 DECLARE_COMMON_NODE_FUNCTIONS(PrimaryNode); |
| 574 | 559 |
| 575 private: | 560 private: |
| 576 const Object& primary_; | 561 const Object& primary_; |
| 577 bool is_deferred_reference_; | 562 bool is_deferred_reference_; |
| 578 | 563 |
| 579 DISALLOW_IMPLICIT_CONSTRUCTORS(PrimaryNode); | 564 DISALLOW_IMPLICIT_CONSTRUCTORS(PrimaryNode); |
| 580 }; | 565 }; |
| 581 | 566 |
| 582 // Return nodes can be of different types: | 567 // In asynchronous code that gets suspeded and resumed, return nodes |
| 583 // * A regular return node that in the case of async functions gets replaced | 568 // can be of different types: |
| 584 // with appropriate completer calls. This kind is generated by dart code. | 569 // * A regular return node that in the case of async functions |
| 585 // * A continuation return that just returns from a function. This kind is | 570 // gets replaced with appropriate completer calls. (kRegular) |
| 586 // generated by AST transformers. | 571 // * A continuation return that just returns from a function, without |
| 572 // completing the Future. (kContinuation) |
| 573 // * A continuation return followed by a continuation target, i.e. the |
| 574 // location at which the closure resumes the next time it gets invoked. |
| 575 // (kContinuationTarget). |
| 576 // In synchronous functions, return nodes are always of type'kRegular' |
| 587 class ReturnNode : public AstNode { | 577 class ReturnNode : public AstNode { |
| 588 public: | 578 public: |
| 589 enum ReturnType { | 579 enum ReturnType { |
| 590 kRegular, | 580 kRegular, |
| 591 kContinuation, | 581 kContinuation, |
| 582 kContinuationTarget |
| 592 }; | 583 }; |
| 593 | 584 |
| 594 // Return from a void function returns the null object. | 585 // Return from a void function returns the null object. |
| 595 explicit ReturnNode(intptr_t token_pos) | 586 explicit ReturnNode(intptr_t token_pos) |
| 596 : AstNode(token_pos), | 587 : AstNode(token_pos), |
| 597 value_(new LiteralNode(token_pos, Instance::ZoneHandle())), | 588 value_(new LiteralNode(token_pos, Instance::ZoneHandle())), |
| 598 inlined_finally_list_(), | 589 inlined_finally_list_(), |
| 599 return_type_(kRegular) { } | 590 return_type_(kRegular) { } |
| 600 // Return from a non-void function. | 591 // Return from a non-void function. |
| 601 ReturnNode(intptr_t token_pos, | 592 ReturnNode(intptr_t token_pos, |
| (...skipping 1311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1913 const intptr_t try_index_; | 1904 const intptr_t try_index_; |
| 1914 | 1905 |
| 1915 DISALLOW_IMPLICIT_CONSTRUCTORS(InlinedFinallyNode); | 1906 DISALLOW_IMPLICIT_CONSTRUCTORS(InlinedFinallyNode); |
| 1916 }; | 1907 }; |
| 1917 | 1908 |
| 1918 } // namespace dart | 1909 } // namespace dart |
| 1919 | 1910 |
| 1920 #undef DECLARE_COMMON_NODE_FUNCTIONS | 1911 #undef DECLARE_COMMON_NODE_FUNCTIONS |
| 1921 | 1912 |
| 1922 #endif // VM_AST_H_ | 1913 #endif // VM_AST_H_ |
| OLD | NEW |