| 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.cps_ir.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 '../core_types.dart' show CoreTypes; | 17 import '../core_types.dart' show CoreTypes; |
| 18 import '../types/constants.dart' show computeTypeMask; | 18 import '../types/constants.dart' show computeTypeMask; |
| 19 import '../elements/elements.dart' show ClassElement, Element, Entity, | 19 import '../elements/elements.dart' show ClassElement, Element, Entity, |
| 20 FieldElement, FunctionElement, ParameterElement; | 20 FieldElement, FunctionElement, ParameterElement; |
| 21 import '../dart2jslib.dart' show ClassWorld; | 21 import '../dart2jslib.dart' show ClassWorld; |
| 22 | 22 |
| 23 part 'type_propagation.dart'; | 23 part 'type_propagation.dart'; |
| 24 part 'redundant_phi.dart'; | 24 part 'redundant_phi.dart'; |
| 25 part 'shrinking_reductions.dart'; | 25 part 'shrinking_reductions.dart'; |
| 26 | 26 |
| 27 /// An optimization pass over the CPS IR. | 27 /// An optimization pass over the CPS IR. |
| 28 abstract class Pass { | 28 abstract class Pass { |
| 29 /// Applies optimizations to root, rewriting it in the process. | 29 /// Applies optimizations to root, rewriting it in the process. |
| 30 void rewrite(ExecutableDefinition root) => root.applyPass(this); | 30 void rewrite(RootNode root); |
| 31 | |
| 32 void rewriteConstructorDefinition(ConstructorDefinition root); | |
| 33 void rewriteFunctionDefinition(FunctionDefinition root); | |
| 34 void rewriteFieldDefinition(FieldDefinition root); | |
| 35 | 31 |
| 36 String get passName; | 32 String get passName; |
| 37 } | 33 } |
| 38 | |
| 39 abstract class PassMixin implements Pass { | |
| 40 void rewrite(ExecutableDefinition root) => root.applyPass(this); | |
| 41 | |
| 42 void rewriteExecutableDefinition(ExecutableDefinition root); | |
| 43 | |
| 44 void rewriteFunctionDefinition(FunctionDefinition root) { | |
| 45 if (root.isAbstract) return; | |
| 46 rewriteExecutableDefinition(root); | |
| 47 } | |
| 48 | |
| 49 void rewriteConstructorDefinition(ConstructorDefinition root) { | |
| 50 if (root.isAbstract) return; | |
| 51 rewriteExecutableDefinition(root); | |
| 52 } | |
| 53 void rewriteFieldDefinition(FieldDefinition root) { | |
| 54 if (!root.hasInitializer) return; | |
| 55 rewriteExecutableDefinition(root); | |
| 56 } | |
| 57 } | |
| OLD | NEW |