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

Unified 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, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « frog/leg/compile_time_constants.dart ('k') | frog/leg/emitter.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: frog/leg/elements/elements.dart
diff --git a/frog/leg/elements/elements.dart b/frog/leg/elements/elements.dart
index 2db8b5c485eac375f3e0cb55e1bbefc1ea37af46..c738f335abf750e09743e65df42ee5a647b43f33 100644
--- a/frog/leg/elements/elements.dart
+++ b/frog/leg/elements/elements.dart
@@ -779,6 +779,51 @@ 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),
+ 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);
+ }
+ }
+
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.
+ 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),
+ includeBackendMembers = false,
+ includeSuperMembers = false]) {
+ forEachMember((ClassElement enclosingClass, Element member) {
+ if (member.isInstanceMember() && member.kind == ElementKind.FIELD) {
+ f(enclosingClass, member);
+ }
+ }, includeBackendMembers,
+ 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
+ }
+
bool isInterface() => false;
bool isNative() => nativeName != null;
SourceString nativeName;
« 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