OLD | NEW |
---|---|
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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.kernel.backend_strategy; | 5 library dart2js.kernel.backend_strategy; |
6 | 6 |
7 import 'package:kernel/ast.dart' as ir; | 7 import 'package:kernel/ast.dart' as ir; |
8 | 8 |
9 import '../backend_strategy.dart'; | 9 import '../backend_strategy.dart'; |
10 import '../common.dart'; | 10 import '../common.dart'; |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
226 if (r != 0) return r; | 226 if (r != 0) return r; |
227 MemberDefinition definition1 = elementMap.getMemberDefinition(member1); | 227 MemberDefinition definition1 = elementMap.getMemberDefinition(member1); |
228 MemberDefinition definition2 = elementMap.getMemberDefinition(member2); | 228 MemberDefinition definition2 = elementMap.getMemberDefinition(member2); |
229 return _compareSourceSpans( | 229 return _compareSourceSpans( |
230 member1, definition1.location, member2, definition2.location); | 230 member1, definition1.location, member2, definition2.location); |
231 }); | 231 }); |
232 } | 232 } |
233 | 233 |
234 @override | 234 @override |
235 Iterable<ClassEntity> sortClasses(Iterable<ClassEntity> classes) { | 235 Iterable<ClassEntity> sortClasses(Iterable<ClassEntity> classes) { |
236 return classes.toList() | 236 int compareClasses(ClassEntity cls1, ClassEntity cls2) { |
237 ..sort((ClassEntity cls1, ClassEntity cls2) { | 237 int r = _compareLibraries(cls1.library, cls2.library); |
238 int r = _compareLibraries(cls1.library, cls2.library); | 238 if (r != 0) return r; |
239 if (r != 0) return r; | 239 ClassDefinition definition1 = elementMap.getClassDefinition(cls1); |
240 ClassDefinition definition1 = elementMap.getClassDefinition(cls1); | 240 ClassDefinition definition2 = elementMap.getClassDefinition(cls2); |
241 ClassDefinition definition2 = elementMap.getClassDefinition(cls2); | 241 return _compareSourceSpans( |
242 return _compareSourceSpans( | 242 cls1, definition1.location, cls2, definition2.location); |
243 cls1, definition1.location, cls2, definition2.location); | 243 } |
244 }); | 244 |
245 List<ClassEntity> regularClasses = <ClassEntity>[]; | |
246 List<ClassEntity> unnamedMixins = <ClassEntity>[]; | |
247 for (ClassEntity cls in classes) { | |
248 if (elementMap.elementEnvironment.isUnnamedMixinApplication(cls)) { | |
249 unnamedMixins.add(cls); | |
250 } else { | |
251 regularClasses.add(cls); | |
252 } | |
253 } | |
254 List<ClassEntity> sorted = <ClassEntity>[]; | |
255 regularClasses.sort(compareClasses); | |
256 sorted.addAll(regularClasses); | |
257 unnamedMixins.sort((a, b) { | |
258 int result = _compareLibraries(a.library, b.library); | |
259 if (result != 0) return result; | |
260 result = a.name.compareTo(b.name); | |
261 assert(result != 0, | |
262 failedAt(a, "Multiple mixins named ${a.name}: $a vs $b.")); | |
Siggi Cherem (dart-lang)
2017/09/01 15:41:49
do we ensure today that if you do A extends Object
Johnni Winther
2017/09/01 16:13:48
We do in the optimized mixin algorithm (ported fro
| |
263 return result; | |
264 }); | |
265 sorted.addAll(unnamedMixins); | |
266 return sorted; | |
245 } | 267 } |
246 | 268 |
247 @override | 269 @override |
248 Iterable<TypedefEntity> sortTypedefs(Iterable<TypedefEntity> typedefs) { | 270 Iterable<TypedefEntity> sortTypedefs(Iterable<TypedefEntity> typedefs) { |
249 // TODO(redemption): Support this. | 271 // TODO(redemption): Support this. |
250 assert(typedefs.isEmpty); | 272 assert(typedefs.isEmpty); |
251 return typedefs; | 273 return typedefs; |
252 } | 274 } |
253 } | 275 } |
OLD | NEW |