| OLD | NEW |
| 1 library tree_ir.optimization; | 1 library tree_ir.optimization; |
| 2 | 2 |
| 3 import '../tree_ir_nodes.dart'; | 3 import '../tree_ir_nodes.dart'; |
| 4 import '../../elements/elements.dart'; | 4 import '../../elements/elements.dart'; |
| 5 import '../../constants/values.dart' as values; | 5 import '../../constants/values.dart' as values; |
| 6 | 6 |
| 7 part 'copy_propagator.dart'; | 7 part 'copy_propagator.dart'; |
| 8 part 'logical_rewriter.dart'; | 8 part 'logical_rewriter.dart'; |
| 9 part 'loop_rewriter.dart'; | 9 part 'loop_rewriter.dart'; |
| 10 part 'statement_rewriter.dart'; | 10 part 'statement_rewriter.dart'; |
| 11 | 11 |
| 12 /// An optimization pass over the Tree IR. | 12 /// An optimization pass over the Tree IR. |
| 13 abstract class Pass { | 13 abstract class Pass { |
| 14 /// Applies optimizations to root, rewriting it in the process. | 14 /// Applies optimizations to root, rewriting it in the process. |
| 15 void rewrite(ExecutableDefinition root) => root.applyPass(this); | 15 void rewrite(ExecutableDefinition root) => root.applyPass(this); |
| 16 void rewriteFieldDefinition(FieldDefinition root); | 16 void rewriteFieldDefinition(FieldDefinition root); |
| 17 void rewriteFunctionDefinition(FunctionDefinition root); | 17 void rewriteFunctionDefinition(FunctionDefinition root); |
| 18 void rewriteConstructorDefinition(ConstructorDefinition root); |
| 18 } | 19 } |
| 19 | 20 |
| 20 | 21 |
| 21 abstract class PassMixin implements Pass { | 22 abstract class PassMixin implements Pass { |
| 22 void rewrite(ExecutableDefinition root) => root.applyPass(this); | 23 void rewrite(ExecutableDefinition root) => root.applyPass(this); |
| 23 void rewriteExecutableDefinition(ExecutableDefinition root); | 24 void rewriteExecutableDefinition(ExecutableDefinition root); |
| 24 void rewriteFieldDefinition(FieldDefinition root) { | 25 void rewriteFieldDefinition(FieldDefinition root) { |
| 25 if (!root.hasInitializer) return; | 26 if (!root.hasInitializer) return; |
| 26 rewriteExecutableDefinition(root); | 27 rewriteExecutableDefinition(root); |
| 27 } | 28 } |
| 28 void rewriteFunctionDefinition(FunctionDefinition root) { | 29 void rewriteFunctionDefinition(FunctionDefinition root) { |
| 29 if (root.isAbstract) return; | 30 if (root.isAbstract) return; |
| 30 rewriteExecutableDefinition(root); | 31 rewriteExecutableDefinition(root); |
| 31 } | 32 } |
| 33 void rewriteConstructorDefinition(ConstructorDefinition root) { |
| 34 if (root.isAbstract) return; |
| 35 rewriteExecutableDefinition(root); |
| 36 } |
| 32 } | 37 } |
| OLD | NEW |