Chromium Code Reviews| Index: lib/compiler/implementation/elements/elements.dart |
| diff --git a/lib/compiler/implementation/elements/elements.dart b/lib/compiler/implementation/elements/elements.dart |
| index 2db8b5c485eac375f3e0cb55e1bbefc1ea37af46..c1da9dc56336a3824608c1280028f9d14e37012b 100644 |
| --- a/lib/compiler/implementation/elements/elements.dart |
| +++ b/lib/compiler/implementation/elements/elements.dart |
| @@ -779,6 +779,52 @@ class ClassElement extends ContainerElement { |
| return supertype === null ? null : supertype.element; |
| } |
| + /** |
| + * Runs through all members of this class. |
| + * |
| + * The enclosing class is passed to the callback. This is useful when |
| + * [includeSuperMembers] is [:true:]. |
| + */ |
| + void forEachMember([void f(ClassElement enclosingClass, Element member), |
|
ahe
2012/04/19 10:02:31
Why is f optional?
floitsch
2012/04/19 10:41:32
So that you can give it a name and put it last.
It
ahe
2012/04/19 10:43:58
I see.
|
| + includeBackendMembers = false, |
| + includeSuperMembers = false]) { |
| + ClassElement classElement = this; |
| + do { |
| + for (Element element in classElement.members) { |
| + f(classElement, element); |
| + } |
| + if (includeBackendMembers) { |
| + for (Element element in classElement.backendMembers) { |
| + f(classElement, element); |
| + } |
| + } |
| + classElement = includeSuperMembers ? classElement.superclass : null; |
| + } while(classElement !== null); |
| + } |
| + |
| + /** |
| + * Runs through all instance-field members of this class. |
| + * |
| + * The enclosing class is passed to the callback. This is useful when |
| + * [includeSuperMembers] is [:true:]. |
| + * |
| + * When [includeBackendMembers] and [includeSuperMembers] are both [:true:] |
| + * then the fields are visited in the same order as they need to be given |
| + * to the JavaScript constructor. |
| + */ |
| + void forEachInstanceField([void f(ClassElement enclosingClass, Element field), |
|
ahe
2012/04/19 10:02:31
Ditto.
|
| + includeBackendMembers = false, |
| + includeSuperMembers = false]) { |
| + // Filters so that [f] is only invoked with instance fields. |
| + void fieldFilter(ClassElement enclosingClass, Element member) { |
| + if (member.isInstanceMember() && member.kind == ElementKind.FIELD) { |
| + f(enclosingClass, member); |
| + } |
| + } |
| + |
| + forEachMember(fieldFilter, includeBackendMembers, includeSuperMembers); |
| + } |
| + |
| bool isInterface() => false; |
| bool isNative() => nativeName != null; |
| SourceString nativeName; |