| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 dart2js.optimizers; | 5 library dart2js.cps_ir.optimizers; |
| 6 | 6 |
| 7 import '../constants/expressions.dart' show | 7 import '../constants/expressions.dart' show |
| 8 ConstantExpression, | 8 ConstantExpression, |
| 9 PrimitiveConstantExpression; | 9 PrimitiveConstantExpression; |
| 10 import '../constants/values.dart'; | 10 import '../constants/values.dart'; |
| 11 import '../dart_types.dart' as types; | 11 import '../dart_types.dart' as types; |
| 12 import '../dart2jslib.dart' as dart2js; | 12 import '../dart2jslib.dart' as dart2js; |
| 13 import '../tree/tree.dart' show LiteralDartString; | 13 import '../tree/tree.dart' show LiteralDartString; |
| 14 import '../util/util.dart'; | 14 import '../util/util.dart'; |
| 15 import 'cps_ir_nodes.dart'; | 15 import 'cps_ir_nodes.dart'; |
| 16 import '../types/types.dart' show TypeMask, TypesTask; | 16 import '../types/types.dart' show TypeMask, TypesTask; |
| 17 import '../elements/elements.dart' show ClassElement, Element, Entity, | 17 import '../elements/elements.dart' show ClassElement, Element, Entity, |
| 18 FieldElement, FunctionElement, ParameterElement; | 18 FieldElement, FunctionElement, ParameterElement; |
| 19 import '../dart2jslib.dart' show ClassWorld, Compiler; | 19 import '../dart2jslib.dart' show ClassWorld, Compiler; |
| 20 | 20 |
| 21 part 'type_propagation.dart'; | 21 part 'type_propagation.dart'; |
| 22 part 'redundant_phi.dart'; | 22 part 'redundant_phi.dart'; |
| 23 part 'shrinking_reductions.dart'; | 23 part 'shrinking_reductions.dart'; |
| 24 | 24 |
| 25 /// An optimization pass over the CPS IR. | 25 /// An optimization pass over the CPS IR. |
| 26 abstract class Pass { | 26 abstract class Pass { |
| 27 /// Applies optimizations to root, rewriting it in the process. | 27 /// Applies optimizations to root, rewriting it in the process. |
| 28 void rewrite(ExecutableDefinition root) => root.applyPass(this); | 28 void rewrite(ExecutableDefinition root) => root.applyPass(this); |
| 29 |
| 30 void rewriteConstructorDefinition(ConstructorDefinition root); |
| 31 void rewriteFunctionDefinition(FunctionDefinition root); |
| 32 void rewriteFieldDefinition(FieldDefinition root); |
| 33 } |
| 34 |
| 35 abstract class PassMixin implements Pass { |
| 36 void rewrite(ExecutableDefinition root) => root.applyPass(this); |
| 37 |
| 38 void rewriteExecutableDefinition(ExecutableDefinition root); |
| 39 |
| 29 void rewriteFunctionDefinition(FunctionDefinition root) { | 40 void rewriteFunctionDefinition(FunctionDefinition root) { |
| 30 return root.applyPass(this); | 41 if (root.isAbstract) return; |
| 42 rewriteExecutableDefinition(root); |
| 43 } |
| 44 |
| 45 void rewriteConstructorDefinition(ConstructorDefinition root) { |
| 46 if (root.isAbstract) return; |
| 47 rewriteExecutableDefinition(root); |
| 31 } | 48 } |
| 32 void rewriteFieldDefinition(FieldDefinition root) { | 49 void rewriteFieldDefinition(FieldDefinition root) { |
| 33 return root.applyPass(this); | 50 if (!root.hasInitializer) return; |
| 51 rewriteExecutableDefinition(root); |
| 34 } | 52 } |
| 35 } | 53 } |
| OLD | NEW |