Index: pkg/compiler/lib/src/tree_ir/optimization/optimization.dart |
diff --git a/pkg/compiler/lib/src/tree_ir/optimization/optimization.dart b/pkg/compiler/lib/src/tree_ir/optimization/optimization.dart |
index d7b8e086f8354a892319df91717a78efc7bdf0b0..63652c45e3f0e1810d6a0b9a9148811b999706c5 100644 |
--- a/pkg/compiler/lib/src/tree_ir/optimization/optimization.dart |
+++ b/pkg/compiler/lib/src/tree_ir/optimization/optimization.dart |
@@ -12,5 +12,20 @@ part 'statement_rewriter.dart'; |
/// An optimization pass over the Tree IR. |
abstract class Pass { |
/// Applies optimizations to root, rewriting it in the process. |
- void rewrite(FunctionDefinition root); |
+ void rewrite(ExecutableDefinition root) => root.applyPass(this); |
+ void rewriteFieldDefinition(FieldDefinition root); |
+ void rewriteFunctionDefinition(FunctionDefinition root); |
} |
+ |
+ |
+abstract class PassMixin implements Pass { |
+ void rewrite(ExecutableDefinition root) => root.applyPass(this); |
+ void rewriteExecutableDefinition(ExecutableDefinition root); |
+ void rewriteFieldDefinition(FieldDefinition root) { |
+ rewriteExecutableDefinition(root); |
+ } |
+ void rewriteFunctionDefinition(FunctionDefinition root) { |
+ if (root.isAbstract) return; |
+ rewriteExecutableDefinition(root); |
+ } |
+} |