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 '../compiler.dart' show Compiler; | 9 import '../compiler.dart' show Compiler; |
10 import '../constants/constructors.dart'; | 10 import '../constants/constructors.dart'; |
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 if (identical(op, '>>=')) return '>>'; | 668 if (identical(op, '>>=')) return '>>'; |
669 if (identical(op, '&=')) return '&'; | 669 if (identical(op, '&=')) return '&'; |
670 if (identical(op, '^=')) return '^'; | 670 if (identical(op, '^=')) return '^'; |
671 if (identical(op, '|=')) return '|'; | 671 if (identical(op, '|=')) return '|'; |
672 if (identical(op, '??=')) return '??'; | 672 if (identical(op, '??=')) return '??'; |
673 | 673 |
674 return null; | 674 return null; |
675 } | 675 } |
676 | 676 |
677 static bool isNumberOrStringSupertype(Element element, Compiler compiler) { | 677 static bool isNumberOrStringSupertype(Element element, Compiler compiler) { |
678 LibraryElement coreLibrary = compiler.coreLibrary; | 678 LibraryElement coreLibrary = compiler.commonElements.coreLibrary; |
679 return (element == coreLibrary.find('Comparable')); | 679 return (element == coreLibrary.find('Comparable')); |
680 } | 680 } |
681 | 681 |
682 static bool isStringOnlySupertype(Element element, Compiler compiler) { | 682 static bool isStringOnlySupertype(Element element, Compiler compiler) { |
683 LibraryElement coreLibrary = compiler.coreLibrary; | 683 LibraryElement coreLibrary = compiler.commonElements.coreLibrary; |
684 return element == coreLibrary.find('Pattern'); | 684 return element == coreLibrary.find('Pattern'); |
685 } | 685 } |
686 | 686 |
687 static bool isListSupertype(Element element, Compiler compiler) { | 687 static bool isListSupertype(Element element, Compiler compiler) { |
688 LibraryElement coreLibrary = compiler.coreLibrary; | 688 LibraryElement coreLibrary = compiler.commonElements.coreLibrary; |
689 return element == coreLibrary.find('Iterable'); | 689 return element == coreLibrary.find('Iterable'); |
690 } | 690 } |
691 | 691 |
692 /// A `compareTo` function that places [Element]s in a consistent order based | 692 /// A `compareTo` function that places [Element]s in a consistent order based |
693 /// on the source code order. | 693 /// on the source code order. |
694 static int compareByPosition(Element a, Element b) { | 694 static int compareByPosition(Element a, Element b) { |
695 if (identical(a, b)) return 0; | 695 if (identical(a, b)) return 0; |
696 int r = _compareLibraries(a.library, b.library); | 696 int r = _compareLibraries(a.library, b.library); |
697 if (r != 0) return r; | 697 if (r != 0) return r; |
698 r = _compareCompilationUnits(a.compilationUnit, b.compilationUnit); | 698 r = _compareCompilationUnits(a.compilationUnit, b.compilationUnit); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
787 Element element, Send node, Compiler compiler) { | 787 Element element, Send node, Compiler compiler) { |
788 return element == compiler.filledListConstructor && | 788 return element == compiler.filledListConstructor && |
789 node.isCall && | 789 node.isCall && |
790 !node.arguments.isEmpty && | 790 !node.arguments.isEmpty && |
791 !node.arguments.tail.isEmpty && | 791 !node.arguments.tail.isEmpty && |
792 node.arguments.tail.tail.isEmpty; | 792 node.arguments.tail.tail.isEmpty; |
793 } | 793 } |
794 | 794 |
795 static bool isConstructorOfTypedArraySubclass( | 795 static bool isConstructorOfTypedArraySubclass( |
796 Element element, Compiler compiler) { | 796 Element element, Compiler compiler) { |
797 if (compiler.typedDataLibrary == null) return false; | 797 if (compiler.commonElements.typedDataLibrary == null) return false; |
798 if (!element.isConstructor) return false; | 798 if (!element.isConstructor) return false; |
799 ConstructorElement constructor = element.implementation; | 799 ConstructorElement constructor = element.implementation; |
800 constructor = constructor.effectiveTarget; | 800 constructor = constructor.effectiveTarget; |
801 ClassElement cls = constructor.enclosingClass; | 801 ClassElement cls = constructor.enclosingClass; |
802 return cls.library == compiler.typedDataLibrary && | 802 return cls.library == compiler.commonElements.typedDataLibrary && |
803 compiler.backend.isNative(cls) && | 803 compiler.backend.isNative(cls) && |
804 compiler.world.isSubtypeOf(cls, compiler.typedDataClass) && | 804 compiler.world |
| 805 .isSubtypeOf(cls, compiler.commonElements.typedDataClass) && |
805 compiler.world.isSubtypeOf(cls, compiler.coreClasses.listClass) && | 806 compiler.world.isSubtypeOf(cls, compiler.coreClasses.listClass) && |
806 constructor.name == ''; | 807 constructor.name == ''; |
807 } | 808 } |
808 | 809 |
809 static bool switchStatementHasContinue( | 810 static bool switchStatementHasContinue( |
810 SwitchStatement node, TreeElements elements) { | 811 SwitchStatement node, TreeElements elements) { |
811 for (SwitchCase switchCase in node.cases) { | 812 for (SwitchCase switchCase in node.cases) { |
812 for (Node labelOrCase in switchCase.labelsAndCases) { | 813 for (Node labelOrCase in switchCase.labelsAndCases) { |
813 Node label = labelOrCase.asLabel(); | 814 Node label = labelOrCase.asLabel(); |
814 if (label != null) { | 815 if (label != null) { |
(...skipping 1092 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1907 /// by a field. | 1908 /// by a field. |
1908 bool get isDeclaredByField; | 1909 bool get isDeclaredByField; |
1909 | 1910 |
1910 /// Returns `true` if this member is abstract. | 1911 /// Returns `true` if this member is abstract. |
1911 bool get isAbstract; | 1912 bool get isAbstract; |
1912 | 1913 |
1913 /// If abstract, [implementation] points to the overridden concrete member, | 1914 /// If abstract, [implementation] points to the overridden concrete member, |
1914 /// if any. Otherwise [implementation] points to the member itself. | 1915 /// if any. Otherwise [implementation] points to the member itself. |
1915 Member get implementation; | 1916 Member get implementation; |
1916 } | 1917 } |
OLD | NEW |