| 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 void rewriteConstructorDefinition(ConstructorDefinition root); |
| 19 |
| 20 String get passName; |
| 19 } | 21 } |
| 20 | 22 |
| 21 | 23 |
| 22 abstract class PassMixin implements Pass { | 24 abstract class PassMixin implements Pass { |
| 23 void rewrite(ExecutableDefinition root) => root.applyPass(this); | 25 void rewrite(ExecutableDefinition root) => root.applyPass(this); |
| 24 void rewriteExecutableDefinition(ExecutableDefinition root); | 26 void rewriteExecutableDefinition(ExecutableDefinition root); |
| 25 void rewriteFieldDefinition(FieldDefinition root) { | 27 void rewriteFieldDefinition(FieldDefinition root) { |
| 26 if (!root.hasInitializer) return; | 28 if (!root.hasInitializer) return; |
| 27 rewriteExecutableDefinition(root); | 29 rewriteExecutableDefinition(root); |
| 28 } | 30 } |
| 29 void rewriteFunctionDefinition(FunctionDefinition root) { | 31 void rewriteFunctionDefinition(FunctionDefinition root) { |
| 30 if (root.isAbstract) return; | 32 if (root.isAbstract) return; |
| 31 rewriteExecutableDefinition(root); | 33 rewriteExecutableDefinition(root); |
| 32 } | 34 } |
| 33 void rewriteConstructorDefinition(ConstructorDefinition root) { | 35 void rewriteConstructorDefinition(ConstructorDefinition root) { |
| 34 if (root.isAbstract) return; | 36 if (root.isAbstract) return; |
| 35 rewriteExecutableDefinition(root); | 37 rewriteExecutableDefinition(root); |
| 36 } | 38 } |
| 37 } | 39 } |
| OLD | NEW |