| 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 NODE_LIST(V) \ | 18 #define NODE_LIST(V) \ |
| 19 V(ReturnNode, "return") \ | 19 V(ReturnNode, "return") \ |
| 20 V(LiteralNode, "literal") \ | 20 V(LiteralNode, "literal") \ |
| 21 V(TypeNode, "type") \ | 21 V(TypeNode, "type") \ |
| 22 V(AssignableNode, "assignable") \ | 22 V(AssignableNode, "assignable") \ |
| 23 V(BinaryOpNode, "binop") \ | 23 V(BinaryOpNode, "binop") \ |
| 24 V(StringConcatNode, "concat") \ | |
| 25 V(ComparisonNode, "compare") \ | 24 V(ComparisonNode, "compare") \ |
| 26 V(UnaryOpNode, "unaryop") \ | 25 V(UnaryOpNode, "unaryop") \ |
| 27 V(ConditionalExprNode, "?:") \ | 26 V(ConditionalExprNode, "?:") \ |
| 28 V(IfNode, "if") \ | 27 V(IfNode, "if") \ |
| 29 V(SwitchNode, "switch") \ | 28 V(SwitchNode, "switch") \ |
| 30 V(CaseNode, "case") \ | 29 V(CaseNode, "case") \ |
| 31 V(WhileNode, "while") \ | 30 V(WhileNode, "while") \ |
| 32 V(DoWhileNode, "dowhile") \ | 31 V(DoWhileNode, "dowhile") \ |
| 33 V(ForNode, "for") \ | 32 V(ForNode, "for") \ |
| 34 V(JumpNode, "jump") \ | 33 V(JumpNode, "jump") \ |
| (...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 const Token::Kind kind_; | 566 const Token::Kind kind_; |
| 568 AstNode* left_; | 567 AstNode* left_; |
| 569 AstNode* right_; | 568 AstNode* right_; |
| 570 | 569 |
| 571 bool IsKindValid() const; | 570 bool IsKindValid() const; |
| 572 | 571 |
| 573 DISALLOW_IMPLICIT_CONSTRUCTORS(BinaryOpNode); | 572 DISALLOW_IMPLICIT_CONSTRUCTORS(BinaryOpNode); |
| 574 }; | 573 }; |
| 575 | 574 |
| 576 | 575 |
| 577 class StringConcatNode : public AstNode { | |
| 578 public: | |
| 579 explicit StringConcatNode(intptr_t token_pos) | |
| 580 : AstNode(token_pos), | |
| 581 values_(new ArrayNode(token_pos, TypeArguments::ZoneHandle())) { | |
| 582 } | |
| 583 | |
| 584 ArrayNode* values() const { return values_; } | |
| 585 | |
| 586 virtual const Instance* EvalConstExpr() const; | |
| 587 | |
| 588 void AddExpr(AstNode* expr) const { | |
| 589 values_->AddElement(expr); | |
| 590 } | |
| 591 | |
| 592 virtual void VisitChildren(AstNodeVisitor* visitor) const { | |
| 593 values_->Visit(visitor); | |
| 594 } | |
| 595 | |
| 596 DECLARE_COMMON_NODE_FUNCTIONS(StringConcatNode); | |
| 597 | |
| 598 private: | |
| 599 ArrayNode* values_; | |
| 600 DISALLOW_IMPLICIT_CONSTRUCTORS(StringConcatNode); | |
| 601 }; | |
| 602 | |
| 603 | |
| 604 class UnaryOpNode : public AstNode { | 576 class UnaryOpNode : public AstNode { |
| 605 public: | 577 public: |
| 606 // Returns optimized version, e.g., for ('-' '1') ('-1') literal is returned. | 578 // Returns optimized version, e.g., for ('-' '1') ('-1') literal is returned. |
| 607 static AstNode* UnaryOpOrLiteral(intptr_t token_pos, | 579 static AstNode* UnaryOpOrLiteral(intptr_t token_pos, |
| 608 Token::Kind kind, | 580 Token::Kind kind, |
| 609 AstNode* operand); | 581 AstNode* operand); |
| 610 UnaryOpNode(intptr_t token_pos, | 582 UnaryOpNode(intptr_t token_pos, |
| 611 Token::Kind kind, | 583 Token::Kind kind, |
| 612 AstNode* operand) | 584 AstNode* operand) |
| 613 : AstNode(token_pos), kind_(kind), operand_(operand) { | 585 : AstNode(token_pos), kind_(kind), operand_(operand) { |
| (...skipping 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1681 const LocalVariable& context_var_; | 1653 const LocalVariable& context_var_; |
| 1682 | 1654 |
| 1683 DISALLOW_IMPLICIT_CONSTRUCTORS(InlinedFinallyNode); | 1655 DISALLOW_IMPLICIT_CONSTRUCTORS(InlinedFinallyNode); |
| 1684 }; | 1656 }; |
| 1685 | 1657 |
| 1686 } // namespace dart | 1658 } // namespace dart |
| 1687 | 1659 |
| 1688 #undef DECLARE_COMMON_NODE_FUNCTIONS | 1660 #undef DECLARE_COMMON_NODE_FUNCTIONS |
| 1689 | 1661 |
| 1690 #endif // VM_AST_H_ | 1662 #endif // VM_AST_H_ |
| OLD | NEW |