Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(265)

Side by Side Diff: pkg/compiler/lib/src/js_emitter/sorter.dart

Issue 3005823002: Handle forwarding constructors to unnamed mixin applications (Closed)
Patch Set: Updated cf. comments Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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.js_emitter.sorter; 5 library dart2js.js_emitter.sorter;
6 6
7 import '../elements/elements.dart'; 7 import '../elements/elements.dart';
8 import '../elements/entities.dart'; 8 import '../elements/entities.dart';
9 9
10 /// Sorting strategy for libraries, classes and members. 10 /// Sorting strategy for libraries, classes and members.
(...skipping 14 matching lines...) Expand all
25 class ElementSorter implements Sorter { 25 class ElementSorter implements Sorter {
26 const ElementSorter(); 26 const ElementSorter();
27 27
28 @override 28 @override
29 List<LibraryEntity> sortLibraries(Iterable<LibraryEntity> libraries) { 29 List<LibraryEntity> sortLibraries(Iterable<LibraryEntity> libraries) {
30 return Elements.sortedByPosition(new List.from(libraries, growable: false)); 30 return Elements.sortedByPosition(new List.from(libraries, growable: false));
31 } 31 }
32 32
33 @override 33 @override
34 List<ClassEntity> sortClasses(Iterable<ClassEntity> classes) { 34 List<ClassEntity> sortClasses(Iterable<ClassEntity> classes) {
35 return Elements.sortedByPosition(new List.from(classes, growable: false)); 35 List<ClassElement> regularClasses = <ClassElement>[];
36 List<MixinApplicationElement> unnamedMixins = <MixinApplicationElement>[];
37 for (ClassElement cls in classes) {
38 if (cls.isUnnamedMixinApplication) {
39 unnamedMixins.add(cls);
40 } else {
41 regularClasses.add(cls);
42 }
43 }
44 List<ClassEntity> sorted = <ClassEntity>[];
45 sorted.addAll(Elements.sortedByPosition<ClassElement>(regularClasses));
46 unnamedMixins.sort((a, b) {
47 int result = a.name.compareTo(b.name);
48 if (result != 0) return result;
49 return Elements.compareByPosition(a.mixin, b.mixin);
50 });
51 sorted.addAll(unnamedMixins);
52 return sorted;
36 } 53 }
37 54
38 @override 55 @override
39 Iterable<TypedefEntity> sortTypedefs(Iterable<TypedefEntity> typedefs) { 56 Iterable<TypedefEntity> sortTypedefs(Iterable<TypedefEntity> typedefs) {
40 return Elements.sortedByPosition(new List.from(typedefs, growable: false)); 57 return Elements.sortedByPosition(new List.from(typedefs, growable: false));
41 } 58 }
42 59
43 @override 60 @override
44 List<MemberEntity> sortMembers(Iterable<MemberEntity> members) { 61 List<MemberEntity> sortMembers(Iterable<MemberEntity> members) {
45 return Elements.sortedByPosition(new List.from(members, growable: false)); 62 return Elements.sortedByPosition(new List.from(members, growable: false));
46 } 63 }
47 } 64 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/kernel/env.dart » ('j') | pkg/compiler/lib/src/kernel/kernel_backend_strategy.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698