Chromium Code Reviews| 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 TryStatement extends Statement { | |
|
floitsch
2015/02/16 14:54:07
Try should be good enough.
Kevin Millikin (Google)
2015/02/25 11:06:36
Done.
| |
| 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 TryStatement(this.tryBody, this.catchParameters, this.catchBody); | |
| 575 | |
| 576 accept(StatementVisitor visitor) => visitor.visitTryStatement(this); | |
| 577 accept1(StatementVisitor1 visitor, arg) { | |
| 578 return visitor.visitTryStatement(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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 751 S visitLabeledStatement(LabeledStatement node); | 770 S visitLabeledStatement(LabeledStatement node); |
| 752 S visitAssign(Assign node); | 771 S visitAssign(Assign node); |
| 753 S visitReturn(Return node); | 772 S visitReturn(Return node); |
| 754 S visitBreak(Break node); | 773 S visitBreak(Break node); |
| 755 S visitContinue(Continue node); | 774 S visitContinue(Continue node); |
| 756 S visitIf(If node); | 775 S visitIf(If node); |
| 757 S visitWhileTrue(WhileTrue node); | 776 S visitWhileTrue(WhileTrue node); |
| 758 S visitWhileCondition(WhileCondition node); | 777 S visitWhileCondition(WhileCondition node); |
| 759 S visitFunctionDeclaration(FunctionDeclaration node); | 778 S visitFunctionDeclaration(FunctionDeclaration node); |
| 760 S visitExpressionStatement(ExpressionStatement node); | 779 S visitExpressionStatement(ExpressionStatement node); |
| 780 S visitTryStatement(TryStatement node); | |
| 761 S visitSetField(SetField node); | 781 S visitSetField(SetField node); |
| 762 } | 782 } |
| 763 | 783 |
| 764 abstract class StatementVisitor1<S, A> { | 784 abstract class StatementVisitor1<S, A> { |
| 765 S visitStatement(Statement s, A arg) => s.accept1(this, arg); | 785 S visitStatement(Statement s, A arg) => s.accept1(this, arg); |
| 766 S visitLabeledStatement(LabeledStatement node, A arg); | 786 S visitLabeledStatement(LabeledStatement node, A arg); |
| 767 S visitAssign(Assign node, A arg); | 787 S visitAssign(Assign node, A arg); |
| 768 S visitReturn(Return node, A arg); | 788 S visitReturn(Return node, A arg); |
| 769 S visitBreak(Break node, A arg); | 789 S visitBreak(Break node, A arg); |
| 770 S visitContinue(Continue node, A arg); | 790 S visitContinue(Continue node, A arg); |
| 771 S visitIf(If node, A arg); | 791 S visitIf(If node, A arg); |
| 772 S visitWhileTrue(WhileTrue node, A arg); | 792 S visitWhileTrue(WhileTrue node, A arg); |
| 773 S visitWhileCondition(WhileCondition node, A arg); | 793 S visitWhileCondition(WhileCondition node, A arg); |
| 774 S visitFunctionDeclaration(FunctionDeclaration node, A arg); | 794 S visitFunctionDeclaration(FunctionDeclaration node, A arg); |
| 775 S visitExpressionStatement(ExpressionStatement node, A arg); | 795 S visitExpressionStatement(ExpressionStatement node, A arg); |
| 796 S visitTryStatement(TryStatement node, A arg); | |
| 776 S visitSetField(SetField node, A arg); | 797 S visitSetField(SetField node, A arg); |
| 777 } | 798 } |
| 778 | 799 |
| 779 abstract class Visitor<S, E> implements ExpressionVisitor<E>, | 800 abstract class Visitor<S, E> implements ExpressionVisitor<E>, |
| 780 StatementVisitor<S> { | 801 StatementVisitor<S> { |
| 781 E visitExpression(Expression e) => e.accept(this); | 802 E visitExpression(Expression e) => e.accept(this); |
| 782 S visitStatement(Statement s) => s.accept(this); | 803 S visitStatement(Statement s) => s.accept(this); |
| 783 } | 804 } |
| 784 | 805 |
| 785 abstract class Visitor1<S, E, A> implements ExpressionVisitor1<E, A>, | 806 abstract class Visitor1<S, E, A> implements ExpressionVisitor1<E, A>, |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 895 visitFunctionDeclaration(FunctionDeclaration node) { | 916 visitFunctionDeclaration(FunctionDeclaration node) { |
| 896 visitFunctionDefinition(node.definition); | 917 visitFunctionDefinition(node.definition); |
| 897 visitStatement(node.next); | 918 visitStatement(node.next); |
| 898 } | 919 } |
| 899 | 920 |
| 900 visitExpressionStatement(ExpressionStatement node) { | 921 visitExpressionStatement(ExpressionStatement node) { |
| 901 visitExpression(node.expression); | 922 visitExpression(node.expression); |
| 902 visitStatement(node.next); | 923 visitStatement(node.next); |
| 903 } | 924 } |
| 904 | 925 |
| 926 visitTryStatement(TryStatement node) { | |
| 927 visitStatement(node.tryBody); | |
| 928 visitStatement(node.catchBody); | |
| 929 } | |
| 930 | |
| 905 visitFieldInitializer(FieldInitializer node) { | 931 visitFieldInitializer(FieldInitializer node) { |
| 906 visitStatement(node.body); | 932 visitStatement(node.body); |
| 907 } | 933 } |
| 908 | 934 |
| 909 visitSuperInitializer(SuperInitializer node) { | 935 visitSuperInitializer(SuperInitializer node) { |
| 910 node.arguments.forEach(visitStatement); | 936 node.arguments.forEach(visitStatement); |
| 911 } | 937 } |
| 912 | 938 |
| 913 visitGetField(GetField node) { | 939 visitGetField(GetField node) { |
| 914 visitExpression(node.object); | 940 visitExpression(node.object); |
| 915 } | 941 } |
| 916 | 942 |
| 917 visitSetField(SetField node) { | 943 visitSetField(SetField node) { |
| 918 visitExpression(node.object); | 944 visitExpression(node.object); |
| 919 visitExpression(node.value); | 945 visitExpression(node.value); |
| 920 visitStatement(node.next); | 946 visitStatement(node.next); |
| 921 } | 947 } |
| 922 | 948 |
| 923 visitCreateBox(CreateBox node) { | 949 visitCreateBox(CreateBox node) { |
| 924 } | 950 } |
| 925 | 951 |
| 926 visitCreateInstance(CreateInstance node) { | 952 visitCreateInstance(CreateInstance node) { |
| 927 node.arguments.forEach(visitExpression); | 953 node.arguments.forEach(visitExpression); |
| 928 } | 954 } |
| 929 } | 955 } |
| OLD | NEW |