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.optimization.statement_rewriter; | 5 library tree_ir.optimization.statement_rewriter; |
6 | 6 |
7 import 'optimization.dart' show Pass; | 7 import 'optimization.dart' show Pass; |
8 import '../tree_ir_nodes.dart'; | 8 import '../tree_ir_nodes.dart'; |
9 import '../../io/source_information.dart'; | 9 import '../../io/source_information.dart'; |
10 import '../../elements/elements.dart'; | 10 import '../../elements/elements.dart'; |
(...skipping 1167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1178 node.input = visitExpression(node.input); | 1178 node.input = visitExpression(node.input); |
1179 return node; | 1179 return node; |
1180 } | 1180 } |
1181 | 1181 |
1182 @override | 1182 @override |
1183 Statement visitYield(Yield node) { | 1183 Statement visitYield(Yield node) { |
1184 node.input = visitExpression(node.input); | 1184 node.input = visitExpression(node.input); |
1185 node.next = visitStatement(node.next); | 1185 node.next = visitStatement(node.next); |
1186 return node; | 1186 return node; |
1187 } | 1187 } |
| 1188 |
| 1189 @override |
| 1190 Statement visitNullCheck(NullCheck node) { |
| 1191 inEmptyEnvironment(() { |
| 1192 node.next = visitStatement(node.next); |
| 1193 }); |
| 1194 if (node.condition != null) { |
| 1195 inEmptyEnvironment(() { |
| 1196 // Value occurs in conditional context. |
| 1197 node.value = visitExpression(node.value); |
| 1198 }); |
| 1199 node.condition = visitExpression(node.condition); |
| 1200 } else { |
| 1201 node.value = visitExpression(node.value); |
| 1202 } |
| 1203 return node; |
| 1204 } |
1188 } | 1205 } |
1189 | 1206 |
1190 /// Result of combining two expressions, with the potential for reverting the | 1207 /// Result of combining two expressions, with the potential for reverting the |
1191 /// combination. | 1208 /// combination. |
1192 /// | 1209 /// |
1193 /// Reverting a combination is done by calling [uncombine]. In this case, | 1210 /// Reverting a combination is done by calling [uncombine]. In this case, |
1194 /// both the original expressions should remain in the tree, and the [combined] | 1211 /// both the original expressions should remain in the tree, and the [combined] |
1195 /// expression should be orphaned. | 1212 /// expression should be orphaned. |
1196 /// | 1213 /// |
1197 /// Explicitly reverting a combination is necessary to maintain variable | 1214 /// Explicitly reverting a combination is necessary to maintain variable |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1271 VariableUseCallback callback; | 1288 VariableUseCallback callback; |
1272 | 1289 |
1273 VariableUseVisitor(this.callback); | 1290 VariableUseVisitor(this.callback); |
1274 | 1291 |
1275 visitVariableUse(VariableUse use) => callback(use); | 1292 visitVariableUse(VariableUse use) => callback(use); |
1276 | 1293 |
1277 static void visit(Expression node, VariableUseCallback callback) { | 1294 static void visit(Expression node, VariableUseCallback callback) { |
1278 new VariableUseVisitor(callback).visitExpression(node); | 1295 new VariableUseVisitor(callback).visitExpression(node); |
1279 } | 1296 } |
1280 } | 1297 } |
OLD | NEW |