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

Side by Side Diff: lib/compiler/implementation/elements/elements.dart

Issue 10310040: Sort the output (for now just the classes and instance members). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add test. Created 8 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « frog/tests/leg/parser_helper.dart ('k') | lib/compiler/implementation/emitter.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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('../tree/tree.dart'); 7 #import('../tree/tree.dart');
8 #import('../scanner/scannerlib.dart'); 8 #import('../scanner/scannerlib.dart');
9 #import('../leg.dart'); // TODO(karlklose): we only need type. 9 #import('../leg.dart'); // TODO(karlklose): we only need type.
10 #import('../util/util.dart'); 10 #import('../util/util.dart');
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 658
659 class SynthesizedConstructorElement extends FunctionElement { 659 class SynthesizedConstructorElement extends FunctionElement {
660 SynthesizedConstructorElement(Element enclosing) 660 SynthesizedConstructorElement(Element enclosing)
661 : super(enclosing.name, ElementKind.GENERATIVE_CONSTRUCTOR, 661 : super(enclosing.name, ElementKind.GENERATIVE_CONSTRUCTOR,
662 null, enclosing); 662 null, enclosing);
663 663
664 Token position() => enclosingElement.position(); 664 Token position() => enclosingElement.position();
665 } 665 }
666 666
667 class ClassElement extends ContainerElement { 667 class ClassElement extends ContainerElement {
668 final int id;
668 Type type; 669 Type type;
669 Type supertype; 670 Type supertype;
670 Type defaultClass; 671 Type defaultClass;
671 Link<Element> members = const EmptyLink<Element>(); 672 Link<Element> members = const EmptyLink<Element>();
672 Map<SourceString, Element> localMembers; 673 Map<SourceString, Element> localMembers;
673 Map<SourceString, Element> constructors; 674 Map<SourceString, Element> constructors;
674 Link<Type> interfaces = const EmptyLink<Type>(); 675 Link<Type> interfaces = const EmptyLink<Type>();
675 LinkedHashMap<SourceString, TypeVariableElement> typeParameters; 676 LinkedHashMap<SourceString, TypeVariableElement> typeParameters;
676 bool isResolved = false; 677 bool isResolved = false;
677 bool isBeingResolved = false; 678 bool isBeingResolved = false;
678 // backendMembers are members that have been added by the backend to simplify 679 // backendMembers are members that have been added by the backend to simplify
679 // compilation. They don't have any user-side counter-part. 680 // compilation. They don't have any user-side counter-part.
680 Link<Element> backendMembers = const EmptyLink<Element>(); 681 Link<Element> backendMembers = const EmptyLink<Element>();
681 682
682 Link<Type> allSupertypes; 683 Link<Type> allSupertypes;
683 684
684 ClassElement(SourceString name, CompilationUnitElement enclosing) 685 ClassElement(SourceString name, CompilationUnitElement enclosing, this.id)
685 : localMembers = new Map<SourceString, Element>(), 686 : localMembers = new Map<SourceString, Element>(),
686 constructors = new Map<SourceString, Element>(), 687 constructors = new Map<SourceString, Element>(),
687 typeParameters = new LinkedHashMap<SourceString, TypeVariableElement>(), 688 typeParameters = new LinkedHashMap<SourceString, TypeVariableElement>(),
688 super(name, ElementKind.CLASS, enclosing); 689 super(name, ElementKind.CLASS, enclosing);
689 690
690 void addMember(Element element, DiagnosticListener listener) { 691 void addMember(Element element, DiagnosticListener listener) {
691 members = members.prepend(element); 692 members = members.prepend(element);
692 if (element.kind == ElementKind.GENERATIVE_CONSTRUCTOR || 693 if (element.kind == ElementKind.GENERATIVE_CONSTRUCTOR ||
693 element.modifiers.isFactory()) { 694 element.modifiers.isFactory()) {
694 constructors[element.name] = element; 695 constructors[element.name] = element;
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 bool isSubclassOf(ClassElement cls) { 846 bool isSubclassOf(ClassElement cls) {
846 for (ClassElement s = this; s != null; s = s.superclass) { 847 for (ClassElement s = this; s != null; s = s.superclass) {
847 if (s === cls) return true; 848 if (s === cls) return true;
848 } 849 }
849 return false; 850 return false;
850 } 851 }
851 852
852 bool isInterface() => false; 853 bool isInterface() => false;
853 bool isNative() => nativeName != null; 854 bool isNative() => nativeName != null;
854 SourceString nativeName; 855 SourceString nativeName;
856 int hashCode() => id;
855 } 857 }
856 858
857 class Elements { 859 class Elements {
858 static bool isLocal(Element element) { 860 static bool isLocal(Element element) {
859 return ((element !== null) 861 return ((element !== null)
860 && !element.isInstanceMember() 862 && !element.isInstanceMember()
861 && !isStaticOrTopLevelField(element) 863 && !isStaticOrTopLevelField(element)
862 && !isStaticOrTopLevelFunction(element) 864 && !isStaticOrTopLevelFunction(element)
863 && (element.kind === ElementKind.VARIABLE || 865 && (element.kind === ElementKind.VARIABLE ||
864 element.kind === ElementKind.PARAMETER || 866 element.kind === ElementKind.PARAMETER ||
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
1030 final Node node; 1032 final Node node;
1031 Type bound; 1033 Type bound;
1032 Type type; 1034 Type type;
1033 TypeVariableElement(name, Element enclosing, this.node, this.type, 1035 TypeVariableElement(name, Element enclosing, this.node, this.type,
1034 [this.bound]) 1036 [this.bound])
1035 : super(name, ElementKind.TYPE_VARIABLE, enclosing); 1037 : super(name, ElementKind.TYPE_VARIABLE, enclosing);
1036 Type computeType(compiler) => type; 1038 Type computeType(compiler) => type;
1037 Node parseNode(compiler) => node; 1039 Node parseNode(compiler) => node;
1038 toString() => "${enclosingElement.toString()}.${name.slowToString()}"; 1040 toString() => "${enclosingElement.toString()}.${name.slowToString()}";
1039 } 1041 }
OLDNEW
« no previous file with comments | « frog/tests/leg/parser_helper.dart ('k') | lib/compiler/implementation/emitter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698