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 | 10 |
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
657 | 657 |
658 Statement visitWhileTrue(WhileTrue node) { | 658 Statement visitWhileTrue(WhileTrue node) { |
659 // Do not propagate assignments into loops. Doing so is not safe for | 659 // Do not propagate assignments into loops. Doing so is not safe for |
660 // variables modified in the loop (the initial value will be propagated). | 660 // variables modified in the loop (the initial value will be propagated). |
661 inEmptyEnvironment(() { | 661 inEmptyEnvironment(() { |
662 node.body = visitStatement(node.body); | 662 node.body = visitStatement(node.body); |
663 }); | 663 }); |
664 return node; | 664 return node; |
665 } | 665 } |
666 | 666 |
667 Statement visitFor(For node) { | 667 Statement visitWhileCondition(WhileCondition node) { |
668 // Not introduced yet | 668 // Not introduced yet |
669 throw "Unexpected For in StatementRewriter"; | 669 throw "Unexpected WhileCondition in StatementRewriter"; |
670 } | 670 } |
671 | 671 |
672 Statement visitTry(Try node) { | 672 Statement visitTry(Try node) { |
673 inEmptyEnvironment(() { | 673 inEmptyEnvironment(() { |
674 Set<Label> saved = safeForInlining; | 674 Set<Label> saved = safeForInlining; |
675 safeForInlining = new Set<Label>(); | 675 safeForInlining = new Set<Label>(); |
676 node.tryBody = visitStatement(node.tryBody); | 676 node.tryBody = visitStatement(node.tryBody); |
677 safeForInlining = saved; | 677 safeForInlining = saved; |
678 node.catchParameters.forEach(pushDominatingAssignment); | 678 node.catchParameters.forEach(pushDominatingAssignment); |
679 node.catchBody = visitStatement(node.catchBody); | 679 node.catchBody = visitStatement(node.catchBody); |
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1217 VariableUseVisitor(this.callback); | 1217 VariableUseVisitor(this.callback); |
1218 | 1218 |
1219 visitVariableUse(VariableUse use) => callback(use); | 1219 visitVariableUse(VariableUse use) => callback(use); |
1220 | 1220 |
1221 visitInnerFunction(FunctionDefinition node) {} | 1221 visitInnerFunction(FunctionDefinition node) {} |
1222 | 1222 |
1223 static void visit(Expression node, VariableUseCallback callback) { | 1223 static void visit(Expression node, VariableUseCallback callback) { |
1224 new VariableUseVisitor(callback).visitExpression(node); | 1224 new VariableUseVisitor(callback).visitExpression(node); |
1225 } | 1225 } |
1226 } | 1226 } |
OLD | NEW |