| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 library kernel.transformations.mixin_full_resolution; | 4 library kernel.transformations.mixin_full_resolution; |
| 5 | 5 |
| 6 import '../ast.dart'; | 6 import '../ast.dart'; |
| 7 import '../class_hierarchy.dart'; | 7 import '../class_hierarchy.dart'; |
| 8 import '../clone.dart'; | 8 import '../clone.dart'; |
| 9 import '../core_types.dart'; | 9 import '../core_types.dart'; |
| 10 import '../target/targets.dart' show NoneTarget, Target; | 10 import '../target/targets.dart' show NoneTarget, Target; |
| 11 import '../type_algebra.dart'; | 11 import '../type_algebra.dart'; |
| 12 | 12 |
| 13 Program transformProgram(Program program) { | 13 Program transformProgram(CoreTypes coreTypes, Program program) { |
| 14 new MixinFullResolution(new NoneTarget(null)).transform(program); | 14 new MixinFullResolution(new NoneTarget(null), coreTypes).transform(program); |
| 15 return program; | 15 return program; |
| 16 } | 16 } |
| 17 | 17 |
| 18 /// Replaces all mixin applications with regular classes, cloning all fields | 18 /// Replaces all mixin applications with regular classes, cloning all fields |
| 19 /// and procedures from the mixed-in class, cloning all constructors from the | 19 /// and procedures from the mixed-in class, cloning all constructors from the |
| 20 /// base class. | 20 /// base class. |
| 21 /// | 21 /// |
| 22 /// Super calls (as well as super initializer invocations) are also resolved | 22 /// Super calls (as well as super initializer invocations) are also resolved |
| 23 /// to their targets in this pass. | 23 /// to their targets in this pass. |
| 24 class MixinFullResolution { | 24 class MixinFullResolution { |
| 25 final Target targetInfo; | 25 final Target targetInfo; |
| 26 | 26 |
| 27 final CoreTypes coreTypes; |
| 27 ClassHierarchy hierarchy; | 28 ClassHierarchy hierarchy; |
| 28 CoreTypes coreTypes; | |
| 29 | 29 |
| 30 MixinFullResolution(this.targetInfo); | 30 MixinFullResolution(this.targetInfo, this.coreTypes); |
| 31 | 31 |
| 32 void transform(Program program) { | 32 void transform(Program program) { |
| 33 var transformedClasses = new Set<Class>(); | 33 var transformedClasses = new Set<Class>(); |
| 34 | 34 |
| 35 // Desugar all mixin application classes by copying in fields/methods from | 35 // Desugar all mixin application classes by copying in fields/methods from |
| 36 // the mixin and constructors from the base class. | 36 // the mixin and constructors from the base class. |
| 37 var processedClasses = new Set<Class>(); | 37 var processedClasses = new Set<Class>(); |
| 38 for (var library in program.libraries) { | 38 for (var library in program.libraries) { |
| 39 if (library.isExternal) continue; | 39 if (library.isExternal) continue; |
| 40 | 40 |
| 41 for (var class_ in library.classes) { | 41 for (var class_ in library.classes) { |
| 42 transformClass(processedClasses, transformedClasses, class_); | 42 transformClass(processedClasses, transformedClasses, class_); |
| 43 } | 43 } |
| 44 } | 44 } |
| 45 | 45 |
| 46 hierarchy = new ClassHierarchy(program); | 46 hierarchy = new ClassHierarchy(program); |
| 47 coreTypes = new CoreTypes(program); | |
| 48 | 47 |
| 49 // Resolve all super call expressions and super initializers. | 48 // Resolve all super call expressions and super initializers. |
| 50 for (var library in program.libraries) { | 49 for (var library in program.libraries) { |
| 51 if (library.isExternal) continue; | 50 if (library.isExternal) continue; |
| 52 | 51 |
| 53 for (var class_ in library.classes) { | 52 for (var class_ in library.classes) { |
| 54 final bool hasTransformedSuperclass = | 53 final bool hasTransformedSuperclass = |
| 55 transformedClasses.contains(class_.superclass); | 54 transformedClasses.contains(class_.superclass); |
| 56 | 55 |
| 57 for (var procedure in class_.procedures) { | 56 for (var procedure in class_.procedures) { |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 return null; | 331 return null; |
| 333 } | 332 } |
| 334 } | 333 } |
| 335 | 334 |
| 336 throw new Exception( | 335 throw new Exception( |
| 337 'Could not find a generative constructor named "${constructor.name}" ' | 336 'Could not find a generative constructor named "${constructor.name}" ' |
| 338 'in lookup class "${lookupClass.name}"!'); | 337 'in lookup class "${lookupClass.name}"!'); |
| 339 } | 338 } |
| 340 } | 339 } |
| 341 } | 340 } |
| OLD | NEW |