OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 elements; | 5 library elements; |
6 | 6 |
7 import '../common.dart'; | 7 import '../common.dart'; |
8 import '../common/resolution.dart' show Resolution; | 8 import '../common/resolution.dart' show Resolution; |
9 import '../constants/constructors.dart'; | 9 import '../constants/constructors.dart'; |
10 import '../constants/expressions.dart'; | 10 import '../constants/expressions.dart'; |
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 if (identical(op, '<<=')) return '<<'; | 637 if (identical(op, '<<=')) return '<<'; |
638 if (identical(op, '>>=')) return '>>'; | 638 if (identical(op, '>>=')) return '>>'; |
639 if (identical(op, '&=')) return '&'; | 639 if (identical(op, '&=')) return '&'; |
640 if (identical(op, '^=')) return '^'; | 640 if (identical(op, '^=')) return '^'; |
641 if (identical(op, '|=')) return '|'; | 641 if (identical(op, '|=')) return '|'; |
642 if (identical(op, '??=')) return '??'; | 642 if (identical(op, '??=')) return '??'; |
643 | 643 |
644 return null; | 644 return null; |
645 } | 645 } |
646 | 646 |
| 647 /// If `true`, injected members are sorted with their corresponding class or |
| 648 /// library. |
| 649 /// |
| 650 /// This is used for ensuring equivalent output order when testing against |
| 651 /// .dill using the patched_dart2js_sdk. |
| 652 // TODO(johnniwinther): Remove this when patching is implemented in |
| 653 // package:front_end. |
| 654 static bool usePatchedDart2jsSdkSorting = false; |
| 655 |
647 /// A `compareTo` function that places [Element]s in a consistent order based | 656 /// A `compareTo` function that places [Element]s in a consistent order based |
648 /// on the source code order. | 657 /// on the source code order. |
649 static int compareByPosition(Element a, Element b) { | 658 static int compareByPosition(Element a, Element b) { |
650 if (identical(a, b)) return 0; | 659 if (identical(a, b)) return 0; |
651 int r = utils.compareLibrariesUris( | 660 int r = utils.compareLibrariesUris( |
652 a.library.canonicalUri, b.library.canonicalUri); | 661 a.library.canonicalUri, b.library.canonicalUri); |
653 if (r != 0) return r; | 662 if (r != 0) return r; |
654 r = utils.compareSourceUris(a.compilationUnit.script.readableUri, | 663 Uri aUri = a.compilationUnit.script.readableUri; |
655 b.compilationUnit.script.readableUri); | 664 Uri bUri = b.compilationUnit.script.readableUri; |
| 665 if (usePatchedDart2jsSdkSorting) { |
| 666 Uri computePatchedDart2jsUri(Element e, Uri uri) { |
| 667 if (!e.isInjected) return uri; |
| 668 if (e.enclosingClass != null) { |
| 669 return e.enclosingClass.compilationUnit.script.readableUri; |
| 670 } else { |
| 671 return e.library.compilationUnit.script.readableUri; |
| 672 } |
| 673 } |
| 674 |
| 675 aUri = computePatchedDart2jsUri(a, aUri); |
| 676 bUri = computePatchedDart2jsUri(b, bUri); |
| 677 } |
| 678 r = utils.compareSourceUris(aUri, bUri); |
656 if (r != 0) return r; | 679 if (r != 0) return r; |
657 return utils.compareEntities(a, a.sourceOffset, -1, b, b.sourceOffset, -1); | 680 return utils.compareEntities(a, a.sourceOffset, -1, b, b.sourceOffset, -1); |
658 } | 681 } |
659 | 682 |
660 static List<E> sortedByPosition<E extends Element>(Iterable<E> elements) { | 683 static List<E> sortedByPosition<E extends Element>(Iterable<E> elements) { |
661 return elements.toList()..sort(compareByPosition); | 684 return elements.toList()..sort(compareByPosition); |
662 } | 685 } |
663 | 686 |
664 static bool isFixedListConstructorCall( | 687 static bool isFixedListConstructorCall( |
665 ConstructorEntity element, Send node, CommonElements commonElements) { | 688 ConstructorEntity element, Send node, CommonElements commonElements) { |
(...skipping 1206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1872 /// by a field. | 1895 /// by a field. |
1873 bool get isDeclaredByField; | 1896 bool get isDeclaredByField; |
1874 | 1897 |
1875 /// Returns `true` if this member is abstract. | 1898 /// Returns `true` if this member is abstract. |
1876 bool get isAbstract; | 1899 bool get isAbstract; |
1877 | 1900 |
1878 /// If abstract, [implementation] points to the overridden concrete member, | 1901 /// If abstract, [implementation] points to the overridden concrete member, |
1879 /// if any. Otherwise [implementation] points to the member itself. | 1902 /// if any. Otherwise [implementation] points to the member itself. |
1880 Member get implementation; | 1903 Member get implementation; |
1881 } | 1904 } |
OLD | NEW |