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(FunctionDefinition root); | 15 void rewrite(ExecutableDefinition root) => root.applyPass(this); |
| 16 void rewriteFieldDefinition(FieldDefinition root); |
| 17 void rewriteFunctionDefinition(FunctionDefinition root); |
16 } | 18 } |
| 19 |
| 20 |
| 21 abstract class PassMixin implements Pass { |
| 22 void rewrite(ExecutableDefinition root) => root.applyPass(this); |
| 23 void rewriteExecutableDefinition(ExecutableDefinition root); |
| 24 void rewriteFieldDefinition(FieldDefinition root) { |
| 25 rewriteExecutableDefinition(root); |
| 26 } |
| 27 void rewriteFunctionDefinition(FunctionDefinition root) { |
| 28 if (root.isAbstract) return; |
| 29 rewriteExecutableDefinition(root); |
| 30 } |
| 31 } |
OLD | NEW |