| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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.variable_merger; | 5 library tree_ir.optimization.variable_merger; |
| 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 '../../elements/elements.dart' show Local, ParameterElement; | |
| 10 | 9 |
| 11 /// Merges variables based on liveness and source variable information. | 10 /// Merges variables based on liveness and source variable information. |
| 12 /// | 11 /// |
| 13 /// This phase cleans up artifacts introduced by the translation through CPS, | 12 /// This phase cleans up artifacts introduced by the translation through CPS, |
| 14 /// where each source variable is translated into several copies. The copies | 13 /// where each source variable is translated into several copies. The copies |
| 15 /// are merged again when they are not live simultaneously. | 14 /// are merged again when they are not live simultaneously. |
| 16 class VariableMerger extends RecursiveVisitor implements Pass { | 15 class VariableMerger extends RecursiveVisitor implements Pass { |
| 17 String get passName => 'Variable merger'; | 16 String get passName => 'Variable merger'; |
| 18 | 17 |
| 19 void rewrite(RootNode node) { | 18 void rewrite(RootNode node) { |
| (...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 // VariableDeclaration is only used for captured variables, which are never | 540 // VariableDeclaration is only used for captured variables, which are never |
| 542 // merged, so this is not strictly necessary. But it's nicer if this class | 541 // merged, so this is not strictly necessary. But it's nicer if this class |
| 543 // works for arbitrary substitution maps. | 542 // works for arbitrary substitution maps. |
| 544 node.variable = replaceWrite(node.variable); | 543 node.variable = replaceWrite(node.variable); |
| 545 node.value = visitExpression(node.value); | 544 node.value = visitExpression(node.value); |
| 546 node.next = visitStatement(node.next); | 545 node.next = visitStatement(node.next); |
| 547 return node; | 546 return node; |
| 548 } | 547 } |
| 549 | 548 |
| 550 } | 549 } |
| OLD | NEW |