| 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" |
| 11 #include "vm/scopes.h" | 11 #include "vm/scopes.h" |
| 12 #include "vm/object.h" | 12 #include "vm/object.h" |
| 13 #include "vm/native_entry.h" | 13 #include "vm/native_entry.h" |
| 14 #include "vm/token.h" | 14 #include "vm/token.h" |
| 15 | 15 |
| 16 namespace dart { | 16 namespace dart { |
| 17 | 17 |
| 18 #define FOR_EACH_NODE(V) \ | 18 #define FOR_EACH_NODE(V) \ |
| 19 V(Await) \ | 19 V(Await) \ |
| 20 V(AwaitMarker) \ |
| 20 V(Return) \ | 21 V(Return) \ |
| 21 V(Literal) \ | 22 V(Literal) \ |
| 22 V(Type) \ | 23 V(Type) \ |
| 23 V(Assignable) \ | 24 V(Assignable) \ |
| 24 V(BinaryOp) \ | 25 V(BinaryOp) \ |
| 25 V(BinaryOpWithMask32) \ | 26 V(BinaryOpWithMask32) \ |
| 26 V(Comparison) \ | 27 V(Comparison) \ |
| 27 V(UnaryOp) \ | 28 V(UnaryOp) \ |
| 28 V(ConditionalExpr) \ | 29 V(ConditionalExpr) \ |
| 29 V(If) \ | 30 V(If) \ |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 | 162 |
| 162 DECLARE_COMMON_NODE_FUNCTIONS(AwaitNode); | 163 DECLARE_COMMON_NODE_FUNCTIONS(AwaitNode); |
| 163 | 164 |
| 164 private: | 165 private: |
| 165 AstNode* expr_; | 166 AstNode* expr_; |
| 166 | 167 |
| 167 DISALLOW_COPY_AND_ASSIGN(AwaitNode); | 168 DISALLOW_COPY_AND_ASSIGN(AwaitNode); |
| 168 }; | 169 }; |
| 169 | 170 |
| 170 | 171 |
| 172 class AwaitMarkerNode : public AstNode { |
| 173 public: |
| 174 enum Type { |
| 175 kNewContinuationState, |
| 176 kTargetForContinuation, |
| 177 }; |
| 178 |
| 179 explicit AwaitMarkerNode(Type type) |
| 180 : AstNode(Scanner::kNoSourcePos), type_(type) { } |
| 181 |
| 182 void VisitChildren(AstNodeVisitor* visitor) const { } |
| 183 |
| 184 Type type() const { return type_; } |
| 185 |
| 186 LocalScope* scope() const { return scope_; } |
| 187 void set_scope(LocalScope* scope) { scope_ = scope; } |
| 188 |
| 189 DECLARE_COMMON_NODE_FUNCTIONS(AwaitMarkerNode); |
| 190 |
| 191 private: |
| 192 Type type_; |
| 193 LocalScope* scope_; |
| 194 |
| 195 DISALLOW_COPY_AND_ASSIGN(AwaitMarkerNode); |
| 196 }; |
| 197 |
| 198 |
| 171 class SequenceNode : public AstNode { | 199 class SequenceNode : public AstNode { |
| 172 public: | 200 public: |
| 173 SequenceNode(intptr_t token_pos, LocalScope* scope) | 201 SequenceNode(intptr_t token_pos, LocalScope* scope) |
| 174 : AstNode(token_pos), | 202 : AstNode(token_pos), |
| 175 scope_(scope), | 203 scope_(scope), |
| 176 nodes_(4), | 204 nodes_(4), |
| 177 label_(NULL) { | 205 label_(NULL) { |
| 178 } | 206 } |
| 179 | 207 |
| 180 LocalScope* scope() const { return scope_; } | 208 LocalScope* scope() const { return scope_; } |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 DECLARE_COMMON_NODE_FUNCTIONS(PrimaryNode); | 558 DECLARE_COMMON_NODE_FUNCTIONS(PrimaryNode); |
| 531 | 559 |
| 532 private: | 560 private: |
| 533 const Object& primary_; | 561 const Object& primary_; |
| 534 bool is_deferred_reference_; | 562 bool is_deferred_reference_; |
| 535 | 563 |
| 536 DISALLOW_IMPLICIT_CONSTRUCTORS(PrimaryNode); | 564 DISALLOW_IMPLICIT_CONSTRUCTORS(PrimaryNode); |
| 537 }; | 565 }; |
| 538 | 566 |
| 539 | 567 |
| 540 // TODO(mlippautz): Implement return nodes that are used to return from a | |
| 541 // continuation. | |
| 542 class ReturnNode : public AstNode { | 568 class ReturnNode : public AstNode { |
| 543 public: | 569 public: |
| 544 // Return from a void function returns the null object. | 570 // Return from a void function returns the null object. |
| 545 explicit ReturnNode(intptr_t token_pos) | 571 explicit ReturnNode(intptr_t token_pos) |
| 546 : AstNode(token_pos), | 572 : AstNode(token_pos), |
| 547 value_(new LiteralNode(token_pos, Instance::ZoneHandle())), | 573 value_(new LiteralNode(token_pos, Instance::ZoneHandle())), |
| 548 inlined_finally_list_(), | 574 inlined_finally_list_(), |
| 549 is_regular_return_(true) { } | 575 is_regular_return_(true) { } |
| 550 // Return from a non-void function. | 576 // Return from a non-void function. |
| 551 ReturnNode(intptr_t token_pos, | 577 ReturnNode(intptr_t token_pos, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 573 if (value() != NULL) { | 599 if (value() != NULL) { |
| 574 value()->Visit(visitor); | 600 value()->Visit(visitor); |
| 575 } | 601 } |
| 576 } | 602 } |
| 577 | 603 |
| 578 void set_scope(LocalScope* scope) { scope_ = scope; } | 604 void set_scope(LocalScope* scope) { scope_ = scope; } |
| 579 LocalScope* scope() const { return scope_; } | 605 LocalScope* scope() const { return scope_; } |
| 580 | 606 |
| 581 // Returns false if the return node is used to return from a continuation. | 607 // Returns false if the return node is used to return from a continuation. |
| 582 bool is_regular_return() const { return is_regular_return_; } | 608 bool is_regular_return() const { return is_regular_return_; } |
| 609 void set_is_regular_return(bool is_regular_return) { |
| 610 is_regular_return_ = is_regular_return; |
| 611 } |
| 583 | 612 |
| 584 DECLARE_COMMON_NODE_FUNCTIONS(ReturnNode); | 613 DECLARE_COMMON_NODE_FUNCTIONS(ReturnNode); |
| 585 | 614 |
| 586 private: | 615 private: |
| 587 AstNode* value_; | 616 AstNode* value_; |
| 588 GrowableArray<InlinedFinallyNode*> inlined_finally_list_; | 617 GrowableArray<InlinedFinallyNode*> inlined_finally_list_; |
| 589 LocalScope* scope_; | 618 LocalScope* scope_; |
| 590 bool is_regular_return_; | 619 bool is_regular_return_; |
| 591 | 620 |
| 592 DISALLOW_COPY_AND_ASSIGN(ReturnNode); | 621 DISALLOW_COPY_AND_ASSIGN(ReturnNode); |
| (...skipping 1255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1848 const intptr_t try_index_; | 1877 const intptr_t try_index_; |
| 1849 | 1878 |
| 1850 DISALLOW_IMPLICIT_CONSTRUCTORS(InlinedFinallyNode); | 1879 DISALLOW_IMPLICIT_CONSTRUCTORS(InlinedFinallyNode); |
| 1851 }; | 1880 }; |
| 1852 | 1881 |
| 1853 } // namespace dart | 1882 } // namespace dart |
| 1854 | 1883 |
| 1855 #undef DECLARE_COMMON_NODE_FUNCTIONS | 1884 #undef DECLARE_COMMON_NODE_FUNCTIONS |
| 1856 | 1885 |
| 1857 #endif // VM_AST_H_ | 1886 #endif // VM_AST_H_ |
| OLD | NEW |