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

Side by Side Diff: frog/leg/elements/elements.dart

Issue 9873012: Move member-iterating code into ClassElement. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 8 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/leg/compile_time_constants.dart ('k') | frog/leg/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 761 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 /** 772 /**
773 * Returns the super class, if any. 773 * Returns the super class, if any.
774 * 774 *
775 * The returned element may not be resolved yet. 775 * The returned element may not be resolved yet.
776 */ 776 */
777 ClassElement get superclass() { 777 ClassElement get superclass() {
778 assert(isResolved); 778 assert(isResolved);
779 return supertype === null ? null : supertype.element; 779 return supertype === null ? null : supertype.element;
780 } 780 }
781 781
782 /**
783 * Runs through all members of this class.
784 *
785 * The enclosing class is passed to the callback. This is useful when
786 * [includeSuperMembers] is [:true:].
787 */
788 void forEachMember([void f(ClassElement enclosingClass, Element member),
789 includeBackendMembers = false,
790 includeSuperMembers = false]) {
791 ClassElement classElement = this;
792 do {
793 for (Element element in classElement.members) {
794 f(classElement, element);
795 }
796 if (includeBackendMembers) {
797 for (Element element in classElement.backendMembers) {
798 f(classElement, element);
799 }
800 }
801
karlklose 2012/03/29 10:48:04 I would remove this line, the structure of the loo
floitsch 2012/03/29 22:44:50 Done.
802 classElement = includeSuperMembers ? classElement.superclass : null;
803 } while(classElement !== null);
804 }
805
806 /**
807 * Runs through all instance-field members of this class.
808 *
809 * The enclosing class is passed to the callback. This is useful when
810 * [includeSuperMembers] is [:true:].
811 *
812 * When [includeBackendMembers] and [includeSuperMembers] are both [:true:]
813 * then the fields are visited in the same order as they need to be given
814 * to the JavaScript constructor.
815 */
816 void forEachInstanceField([void f(ClassElement enclosingClass, Element field),
817 includeBackendMembers = false,
818 includeSuperMembers = false]) {
819 forEachMember((ClassElement enclosingClass, Element member) {
820 if (member.isInstanceMember() && member.kind == ElementKind.FIELD) {
821 f(enclosingClass, member);
822 }
823 }, includeBackendMembers,
824 includeSuperMembers);
karlklose 2012/03/29 10:48:04 This indentation looks strange. Use the parameter
floitsch 2012/03/29 22:44:50 Moved function out of the call. If you disagree wi
825 }
826
782 bool isInterface() => false; 827 bool isInterface() => false;
783 bool isNative() => nativeName != null; 828 bool isNative() => nativeName != null;
784 SourceString nativeName; 829 SourceString nativeName;
785 } 830 }
786 831
787 class Elements { 832 class Elements {
788 static bool isLocal(Element element) { 833 static bool isLocal(Element element) {
789 return ((element !== null) 834 return ((element !== null)
790 && !element.isInstanceMember() 835 && !element.isInstanceMember()
791 && !isStaticOrTopLevelField(element) 836 && !isStaticOrTopLevelField(element)
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
960 final Node node; 1005 final Node node;
961 Type bound; 1006 Type bound;
962 Type type; 1007 Type type;
963 TypeVariableElement(name, Element enclosing, this.node, this.type, 1008 TypeVariableElement(name, Element enclosing, this.node, this.type,
964 [this.bound]) 1009 [this.bound])
965 : super(name, ElementKind.TYPE_VARIABLE, enclosing); 1010 : super(name, ElementKind.TYPE_VARIABLE, enclosing);
966 Type computeType(compiler) => type; 1011 Type computeType(compiler) => type;
967 Node parseNode(compiler) => node; 1012 Node parseNode(compiler) => node;
968 toString() => "${enclosingElement.toString()}.${name.slowToString()}"; 1013 toString() => "${enclosingElement.toString()}.${name.slowToString()}";
969 } 1014 }
OLDNEW
« no previous file with comments | « frog/leg/compile_time_constants.dart ('k') | frog/leg/emitter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698