| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 library tree_ir_nodes; | 5 library tree_ir_nodes; |
| 6 | 6 |
| 7 import '../constants/expressions.dart'; | 7 import '../constants/expressions.dart'; |
| 8 import '../constants/values.dart' as values; | 8 import '../constants/values.dart' as values; |
| 9 import '../dart_types.dart' show DartType, GenericType; | 9 import '../dart_types.dart' show DartType, GenericType; |
| 10 import '../elements/elements.dart'; | 10 import '../elements/elements.dart'; |
| (...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 Expression expression; | 553 Expression expression; |
| 554 | 554 |
| 555 ExpressionStatement(this.expression, this.next); | 555 ExpressionStatement(this.expression, this.next); |
| 556 | 556 |
| 557 accept(StatementVisitor visitor) => visitor.visitExpressionStatement(this); | 557 accept(StatementVisitor visitor) => visitor.visitExpressionStatement(this); |
| 558 accept1(StatementVisitor1 visitor, arg) { | 558 accept1(StatementVisitor1 visitor, arg) { |
| 559 return visitor.visitExpressionStatement(this, arg); | 559 return visitor.visitExpressionStatement(this, arg); |
| 560 } | 560 } |
| 561 } | 561 } |
| 562 | 562 |
| 563 // TODO(kmillikin): Do we want this 'TryStatement'? Other than |
| 564 // LabeledStatement and EmptyStatement, the statement class names are not |
| 565 // suffixed with 'Statement'. |
| 566 class Try extends Statement { |
| 567 Statement tryBody; |
| 568 List<Variable> catchParameters; |
| 569 Statement catchBody; |
| 570 |
| 571 Statement get next => null; |
| 572 void set next(Statement s) => throw 'UNREACHABLE'; |
| 573 |
| 574 Try(this.tryBody, this.catchParameters, this.catchBody); |
| 575 |
| 576 accept(StatementVisitor visitor) => visitor.visitTry(this); |
| 577 accept1(StatementVisitor1 visitor, arg) { |
| 578 return visitor.visitTry(this, arg); |
| 579 } |
| 580 } |
| 581 |
| 563 abstract class ExecutableDefinition { | 582 abstract class ExecutableDefinition { |
| 564 ExecutableElement get element; | 583 ExecutableElement get element; |
| 565 Statement body; | 584 Statement body; |
| 566 | 585 |
| 567 applyPass(Pass pass); | 586 applyPass(Pass pass); |
| 568 } | 587 } |
| 569 | 588 |
| 570 class FieldDefinition extends Node implements ExecutableDefinition { | 589 class FieldDefinition extends Node implements ExecutableDefinition { |
| 571 final FieldElement element; | 590 final FieldElement element; |
| 572 // The `body` of a field is its initializer. | 591 // The `body` of a field is its initializer. |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 753 S visitLabeledStatement(LabeledStatement node); | 772 S visitLabeledStatement(LabeledStatement node); |
| 754 S visitAssign(Assign node); | 773 S visitAssign(Assign node); |
| 755 S visitReturn(Return node); | 774 S visitReturn(Return node); |
| 756 S visitBreak(Break node); | 775 S visitBreak(Break node); |
| 757 S visitContinue(Continue node); | 776 S visitContinue(Continue node); |
| 758 S visitIf(If node); | 777 S visitIf(If node); |
| 759 S visitWhileTrue(WhileTrue node); | 778 S visitWhileTrue(WhileTrue node); |
| 760 S visitWhileCondition(WhileCondition node); | 779 S visitWhileCondition(WhileCondition node); |
| 761 S visitFunctionDeclaration(FunctionDeclaration node); | 780 S visitFunctionDeclaration(FunctionDeclaration node); |
| 762 S visitExpressionStatement(ExpressionStatement node); | 781 S visitExpressionStatement(ExpressionStatement node); |
| 782 S visitTry(Try node); |
| 763 S visitSetField(SetField node); | 783 S visitSetField(SetField node); |
| 764 } | 784 } |
| 765 | 785 |
| 766 abstract class StatementVisitor1<S, A> { | 786 abstract class StatementVisitor1<S, A> { |
| 767 S visitStatement(Statement s, A arg) => s.accept1(this, arg); | 787 S visitStatement(Statement s, A arg) => s.accept1(this, arg); |
| 768 S visitLabeledStatement(LabeledStatement node, A arg); | 788 S visitLabeledStatement(LabeledStatement node, A arg); |
| 769 S visitAssign(Assign node, A arg); | 789 S visitAssign(Assign node, A arg); |
| 770 S visitReturn(Return node, A arg); | 790 S visitReturn(Return node, A arg); |
| 771 S visitBreak(Break node, A arg); | 791 S visitBreak(Break node, A arg); |
| 772 S visitContinue(Continue node, A arg); | 792 S visitContinue(Continue node, A arg); |
| 773 S visitIf(If node, A arg); | 793 S visitIf(If node, A arg); |
| 774 S visitWhileTrue(WhileTrue node, A arg); | 794 S visitWhileTrue(WhileTrue node, A arg); |
| 775 S visitWhileCondition(WhileCondition node, A arg); | 795 S visitWhileCondition(WhileCondition node, A arg); |
| 776 S visitFunctionDeclaration(FunctionDeclaration node, A arg); | 796 S visitFunctionDeclaration(FunctionDeclaration node, A arg); |
| 777 S visitExpressionStatement(ExpressionStatement node, A arg); | 797 S visitExpressionStatement(ExpressionStatement node, A arg); |
| 798 S visitTry(Try node, A arg); |
| 778 S visitSetField(SetField node, A arg); | 799 S visitSetField(SetField node, A arg); |
| 779 } | 800 } |
| 780 | 801 |
| 781 abstract class Visitor<S, E> implements ExpressionVisitor<E>, | 802 abstract class Visitor<S, E> implements ExpressionVisitor<E>, |
| 782 StatementVisitor<S> { | 803 StatementVisitor<S> { |
| 783 E visitExpression(Expression e) => e.accept(this); | 804 E visitExpression(Expression e) => e.accept(this); |
| 784 S visitStatement(Statement s) => s.accept(this); | 805 S visitStatement(Statement s) => s.accept(this); |
| 785 } | 806 } |
| 786 | 807 |
| 787 abstract class Visitor1<S, E, A> implements ExpressionVisitor1<E, A>, | 808 abstract class Visitor1<S, E, A> implements ExpressionVisitor1<E, A>, |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 897 visitFunctionDeclaration(FunctionDeclaration node) { | 918 visitFunctionDeclaration(FunctionDeclaration node) { |
| 898 visitFunctionDefinition(node.definition); | 919 visitFunctionDefinition(node.definition); |
| 899 visitStatement(node.next); | 920 visitStatement(node.next); |
| 900 } | 921 } |
| 901 | 922 |
| 902 visitExpressionStatement(ExpressionStatement node) { | 923 visitExpressionStatement(ExpressionStatement node) { |
| 903 visitExpression(node.expression); | 924 visitExpression(node.expression); |
| 904 visitStatement(node.next); | 925 visitStatement(node.next); |
| 905 } | 926 } |
| 906 | 927 |
| 928 visitTry(Try node) { |
| 929 visitStatement(node.tryBody); |
| 930 visitStatement(node.catchBody); |
| 931 } |
| 932 |
| 907 visitFieldInitializer(FieldInitializer node) { | 933 visitFieldInitializer(FieldInitializer node) { |
| 908 visitStatement(node.body); | 934 visitStatement(node.body); |
| 909 } | 935 } |
| 910 | 936 |
| 911 visitSuperInitializer(SuperInitializer node) { | 937 visitSuperInitializer(SuperInitializer node) { |
| 912 node.arguments.forEach(visitStatement); | 938 node.arguments.forEach(visitStatement); |
| 913 } | 939 } |
| 914 | 940 |
| 915 visitGetField(GetField node) { | 941 visitGetField(GetField node) { |
| 916 visitExpression(node.object); | 942 visitExpression(node.object); |
| 917 } | 943 } |
| 918 | 944 |
| 919 visitSetField(SetField node) { | 945 visitSetField(SetField node) { |
| 920 visitExpression(node.object); | 946 visitExpression(node.object); |
| 921 visitExpression(node.value); | 947 visitExpression(node.value); |
| 922 visitStatement(node.next); | 948 visitStatement(node.next); |
| 923 } | 949 } |
| 924 | 950 |
| 925 visitCreateBox(CreateBox node) { | 951 visitCreateBox(CreateBox node) { |
| 926 } | 952 } |
| 927 | 953 |
| 928 visitCreateInstance(CreateInstance node) { | 954 visitCreateInstance(CreateInstance node) { |
| 929 node.arguments.forEach(visitExpression); | 955 node.arguments.forEach(visitExpression); |
| 930 } | 956 } |
| 931 } | 957 } |
| OLD | NEW |