| 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, InterfaceType, TypeVaria
bleType; | 9 import '../dart_types.dart' show DartType, GenericType, InterfaceType, TypeVaria
bleType; |
| 10 import '../elements/elements.dart'; | 10 import '../elements/elements.dart'; |
| (...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 | 575 |
| 576 Statement get next => null; | 576 Statement get next => null; |
| 577 void set next(Statement s) => throw 'UNREACHABLE'; | 577 void set next(Statement s) => throw 'UNREACHABLE'; |
| 578 | 578 |
| 579 Return(this.value); | 579 Return(this.value); |
| 580 | 580 |
| 581 accept(StatementVisitor visitor) => visitor.visitReturn(this); | 581 accept(StatementVisitor visitor) => visitor.visitReturn(this); |
| 582 accept1(StatementVisitor1 visitor, arg) => visitor.visitReturn(this, arg); | 582 accept1(StatementVisitor1 visitor, arg) => visitor.visitReturn(this, arg); |
| 583 } | 583 } |
| 584 | 584 |
| 585 /// A throw statement. |
| 586 /// |
| 587 /// In the Tree IR, throw is a statement (like JavaScript and unlike Dart). |
| 588 class Throw extends Statement { |
| 589 Expression value; |
| 590 |
| 591 Statement get next => null; |
| 592 void set next(Statement s) => throw 'UNREACHABLE'; |
| 593 |
| 594 Throw(this.value); |
| 595 |
| 596 accept(StatementVisitor visitor) => visitor.visitThrow(this); |
| 597 accept1(StatementVisitor1 visitor, arg) => visitor.visitThrow(this, arg); |
| 598 } |
| 599 |
| 600 /// A rethrow exit from the function. |
| 601 /// |
| 602 /// Rethrow can only occur nested inside a catch block. It implicitly throws |
| 603 /// the block's caught exception value without changing the caught stack trace. |
| 604 class Rethrow extends Statement { |
| 605 Statement get next => null; |
| 606 void set next(Statement s) => throw 'UNREACHABLE'; |
| 607 |
| 608 Rethrow(); |
| 609 |
| 610 accept(StatementVisitor visitor) => visitor.visitRethrow(this); |
| 611 accept1(StatementVisitor1 visitor, arg) => visitor.visitRethrow(this, arg); |
| 612 } |
| 613 |
| 585 /** | 614 /** |
| 586 * A conditional branch based on the true value of an [Expression]. | 615 * A conditional branch based on the true value of an [Expression]. |
| 587 */ | 616 */ |
| 588 class If extends Statement { | 617 class If extends Statement { |
| 589 Expression condition; | 618 Expression condition; |
| 590 Statement thenStatement; | 619 Statement thenStatement; |
| 591 Statement elseStatement; | 620 Statement elseStatement; |
| 592 | 621 |
| 593 Statement get next => null; | 622 Statement get next => null; |
| 594 void set next(Statement s) => throw 'UNREACHABLE'; | 623 void set next(Statement s) => throw 'UNREACHABLE'; |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 941 E visitReifyRuntimeType(ReifyRuntimeType node, A arg); | 970 E visitReifyRuntimeType(ReifyRuntimeType node, A arg); |
| 942 E visitReadTypeVariable(ReadTypeVariable node, A arg); | 971 E visitReadTypeVariable(ReadTypeVariable node, A arg); |
| 943 E visitTypeExpression(TypeExpression node, A arg); | 972 E visitTypeExpression(TypeExpression node, A arg); |
| 944 E visitSetField(SetField node, A arg); | 973 E visitSetField(SetField node, A arg); |
| 945 } | 974 } |
| 946 | 975 |
| 947 abstract class StatementVisitor<S> { | 976 abstract class StatementVisitor<S> { |
| 948 S visitStatement(Statement node) => node.accept(this); | 977 S visitStatement(Statement node) => node.accept(this); |
| 949 S visitLabeledStatement(LabeledStatement node); | 978 S visitLabeledStatement(LabeledStatement node); |
| 950 S visitReturn(Return node); | 979 S visitReturn(Return node); |
| 980 S visitThrow(Throw node); |
| 981 S visitRethrow(Rethrow node); |
| 951 S visitBreak(Break node); | 982 S visitBreak(Break node); |
| 952 S visitContinue(Continue node); | 983 S visitContinue(Continue node); |
| 953 S visitIf(If node); | 984 S visitIf(If node); |
| 954 S visitWhileTrue(WhileTrue node); | 985 S visitWhileTrue(WhileTrue node); |
| 955 S visitWhileCondition(WhileCondition node); | 986 S visitWhileCondition(WhileCondition node); |
| 956 S visitFunctionDeclaration(FunctionDeclaration node); | 987 S visitFunctionDeclaration(FunctionDeclaration node); |
| 957 S visitVariableDeclaration(VariableDeclaration node); | 988 S visitVariableDeclaration(VariableDeclaration node); |
| 958 S visitExpressionStatement(ExpressionStatement node); | 989 S visitExpressionStatement(ExpressionStatement node); |
| 959 S visitTry(Try node); | 990 S visitTry(Try node); |
| 960 } | 991 } |
| 961 | 992 |
| 962 abstract class StatementVisitor1<S, A> { | 993 abstract class StatementVisitor1<S, A> { |
| 963 S visitStatement(Statement node, A arg) => node.accept1(this, arg); | 994 S visitStatement(Statement node, A arg) => node.accept1(this, arg); |
| 964 S visitLabeledStatement(LabeledStatement node, A arg); | 995 S visitLabeledStatement(LabeledStatement node, A arg); |
| 965 S visitReturn(Return node, A arg); | 996 S visitReturn(Return node, A arg); |
| 997 S visitThrow(Throw node, A arg); |
| 998 S visitRethrow(Rethrow node, A arg); |
| 966 S visitBreak(Break node, A arg); | 999 S visitBreak(Break node, A arg); |
| 967 S visitContinue(Continue node, A arg); | 1000 S visitContinue(Continue node, A arg); |
| 968 S visitIf(If node, A arg); | 1001 S visitIf(If node, A arg); |
| 969 S visitWhileTrue(WhileTrue node, A arg); | 1002 S visitWhileTrue(WhileTrue node, A arg); |
| 970 S visitWhileCondition(WhileCondition node, A arg); | 1003 S visitWhileCondition(WhileCondition node, A arg); |
| 971 S visitFunctionDeclaration(FunctionDeclaration node, A arg); | 1004 S visitFunctionDeclaration(FunctionDeclaration node, A arg); |
| 972 S visitVariableDeclaration(VariableDeclaration node, A arg); | 1005 S visitVariableDeclaration(VariableDeclaration node, A arg); |
| 973 S visitExpressionStatement(ExpressionStatement node, A arg); | 1006 S visitExpressionStatement(ExpressionStatement node, A arg); |
| 974 S visitTry(Try node, A arg); | 1007 S visitTry(Try node, A arg); |
| 975 } | 1008 } |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1087 | 1120 |
| 1088 visitLabeledStatement(LabeledStatement node) { | 1121 visitLabeledStatement(LabeledStatement node) { |
| 1089 visitStatement(node.body); | 1122 visitStatement(node.body); |
| 1090 visitStatement(node.next); | 1123 visitStatement(node.next); |
| 1091 } | 1124 } |
| 1092 | 1125 |
| 1093 visitReturn(Return node) { | 1126 visitReturn(Return node) { |
| 1094 visitExpression(node.value); | 1127 visitExpression(node.value); |
| 1095 } | 1128 } |
| 1096 | 1129 |
| 1130 visitThrow(Throw node) { |
| 1131 visitExpression(node.value); |
| 1132 } |
| 1133 |
| 1134 visitRethrow(Rethrow node) {} |
| 1135 |
| 1097 visitBreak(Break node) {} | 1136 visitBreak(Break node) {} |
| 1098 | 1137 |
| 1099 visitContinue(Continue node) {} | 1138 visitContinue(Continue node) {} |
| 1100 | 1139 |
| 1101 visitIf(If node) { | 1140 visitIf(If node) { |
| 1102 visitExpression(node.condition); | 1141 visitExpression(node.condition); |
| 1103 visitStatement(node.thenStatement); | 1142 visitStatement(node.thenStatement); |
| 1104 visitStatement(node.elseStatement); | 1143 visitStatement(node.elseStatement); |
| 1105 } | 1144 } |
| 1106 | 1145 |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1266 node.body = visitStatement(node.body); | 1305 node.body = visitStatement(node.body); |
| 1267 node.next = visitStatement(node.next); | 1306 node.next = visitStatement(node.next); |
| 1268 return node; | 1307 return node; |
| 1269 } | 1308 } |
| 1270 | 1309 |
| 1271 visitReturn(Return node) { | 1310 visitReturn(Return node) { |
| 1272 node.value = visitExpression(node.value); | 1311 node.value = visitExpression(node.value); |
| 1273 return node; | 1312 return node; |
| 1274 } | 1313 } |
| 1275 | 1314 |
| 1315 visitThrow(Throw node) { |
| 1316 node.value = visitExpression(node.value); |
| 1317 return node; |
| 1318 } |
| 1319 |
| 1320 visitRethrow(Rethrow node) => node; |
| 1321 |
| 1276 visitBreak(Break node) => node; | 1322 visitBreak(Break node) => node; |
| 1277 | 1323 |
| 1278 visitContinue(Continue node) => node; | 1324 visitContinue(Continue node) => node; |
| 1279 | 1325 |
| 1280 visitIf(If node) { | 1326 visitIf(If node) { |
| 1281 node.condition = visitExpression(node.condition); | 1327 node.condition = visitExpression(node.condition); |
| 1282 node.thenStatement = visitStatement(node.thenStatement); | 1328 node.thenStatement = visitStatement(node.thenStatement); |
| 1283 node.elseStatement = visitStatement(node.elseStatement); | 1329 node.elseStatement = visitStatement(node.elseStatement); |
| 1284 return node; | 1330 return node; |
| 1285 } | 1331 } |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1340 visitReadTypeVariable(ReadTypeVariable node) { | 1386 visitReadTypeVariable(ReadTypeVariable node) { |
| 1341 node.target = visitExpression(node.target); | 1387 node.target = visitExpression(node.target); |
| 1342 return node; | 1388 return node; |
| 1343 } | 1389 } |
| 1344 | 1390 |
| 1345 visitTypeExpression(TypeExpression node) { | 1391 visitTypeExpression(TypeExpression node) { |
| 1346 _replaceExpressions(node.arguments); | 1392 _replaceExpressions(node.arguments); |
| 1347 return node; | 1393 return node; |
| 1348 } | 1394 } |
| 1349 } | 1395 } |
| OLD | NEW |