| 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 '../type_algebra.dart'; | 10 import '../type_algebra.dart'; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 } | 71 } |
| 72 } | 72 } |
| 73 | 73 |
| 74 transformClass(Set<Class> processedClasses, Set<Class> transformedClasses, | 74 transformClass(Set<Class> processedClasses, Set<Class> transformedClasses, |
| 75 Class class_) { | 75 Class class_) { |
| 76 // If this class was already handled then so were all classes up to the | 76 // If this class was already handled then so were all classes up to the |
| 77 // [Object] class. | 77 // [Object] class. |
| 78 if (!processedClasses.add(class_)) return; | 78 if (!processedClasses.add(class_)) return; |
| 79 | 79 |
| 80 // Ensure super classes have been transformed before this class. | 80 // Ensure super classes have been transformed before this class. |
| 81 if (class_.superclass != null) { | 81 if (class_.superclass != null && |
| 82 class_.superclass.level.index >= ClassLevel.Mixin.index) { |
| 82 transformClass(processedClasses, transformedClasses, class_.superclass); | 83 transformClass(processedClasses, transformedClasses, class_.superclass); |
| 83 } | 84 } |
| 84 | 85 |
| 85 // If this is not a mixin application we don't need to make forwarding | 86 // If this is not a mixin application we don't need to make forwarding |
| 86 // constructors in this class. | 87 // constructors in this class. |
| 87 if (!class_.isMixinApplication) return; | 88 if (!class_.isMixinApplication) return; |
| 88 | 89 |
| 89 if (class_.mixedInClass.level != ClassLevel.Body) { | 90 if (class_.mixedInClass.level.index < ClassLevel.Mixin.index) { |
| 90 throw new Exception( | 91 throw new Exception( |
| 91 'Class "${class_.name}" mixes in "${class_.mixedInClass.name}" from' | 92 'Class "${class_.name}" mixes in "${class_.mixedInClass.name}" from' |
| 92 ' an external library. Did you forget --link?'); | 93 ' an external library. Did you forget --link?'); |
| 93 } | 94 } |
| 94 | 95 |
| 95 transformedClasses.add(class_); | 96 transformedClasses.add(class_); |
| 96 | 97 |
| 97 // Clone fields and methods from the mixin class. | 98 // Clone fields and methods from the mixin class. |
| 98 var substitution = getSubstitutionMap(class_.mixedInType); | 99 var substitution = getSubstitutionMap(class_.mixedInType); |
| 99 var cloner = new CloneVisitor(typeSubstitution: substitution); | 100 var cloner = new CloneVisitor(typeSubstitution: substitution); |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 return null; | 371 return null; |
| 371 } | 372 } |
| 372 } | 373 } |
| 373 | 374 |
| 374 throw new Exception( | 375 throw new Exception( |
| 375 'Could not find a generative constructor named "${constructor.name}" ' | 376 'Could not find a generative constructor named "${constructor.name}" ' |
| 376 'in lookup class "${lookupClass.name}"!'); | 377 'in lookup class "${lookupClass.name}"!'); |
| 377 } | 378 } |
| 378 } | 379 } |
| 379 } | 380 } |
| OLD | NEW |