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

Unified Diff: sdk/lib/_internal/compiler/implementation/mirrors/mirrors_util.dart

Issue 11783009: Big merge from experimental to bleeding edge. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 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
Index: sdk/lib/_internal/compiler/implementation/mirrors/mirrors_util.dart
diff --git a/sdk/lib/_internal/compiler/implementation/mirrors/mirrors_util.dart b/sdk/lib/_internal/compiler/implementation/mirrors/mirrors_util.dart
index cede225be99a109917dbbcaa04c9047e58434ebd..8614d9d6df1619ceb7c322a5acc65f33fb01a419 100644
--- a/sdk/lib/_internal/compiler/implementation/mirrors/mirrors_util.dart
+++ b/sdk/lib/_internal/compiler/implementation/mirrors/mirrors_util.dart
@@ -53,14 +53,14 @@ LibraryMirror findLibrary(MemberMirror member) {
throw new Exception('Unexpected owner: ${owner}');
}
-class HierarchyIterable implements Iterable<ClassMirror> {
+class HierarchyIterable extends Iterable<ClassMirror> {
final bool includeType;
final ClassMirror type;
HierarchyIterable(this.type, {bool includeType})
: this.includeType = includeType;
- Iterator<ClassMirror> iterator() =>
+ Iterator<ClassMirror> get iterator =>
new HierarchyIterator(type, includeType: includeType);
}
@@ -68,7 +68,7 @@ class HierarchyIterable implements Iterable<ClassMirror> {
* [HierarchyIterator] iterates through the class hierarchy of the provided
* type.
*
- * First is the superclass relation is traversed, skipping [Object], next the
+ * First the superclass relation is traversed, skipping [Object], next the
* superinterface relation and finally is [Object] visited. The supertypes are
* visited in breadth first order and a superinterface is visited more than once
* if implemented through multiple supertypes.
@@ -76,6 +76,7 @@ class HierarchyIterable implements Iterable<ClassMirror> {
class HierarchyIterator implements Iterator<ClassMirror> {
final Queue<ClassMirror> queue = new Queue<ClassMirror>();
ClassMirror object;
+ ClassMirror _current;
HierarchyIterator(ClassMirror type, {bool includeType}) {
if (includeType) {
@@ -97,19 +98,18 @@ class HierarchyIterator implements Iterator<ClassMirror> {
return type;
}
- ClassMirror next() {
- ClassMirror type;
+ ClassMirror get current => _current;
+
+ bool moveNext() {
+ _current = null;
if (queue.isEmpty) {
- if (object == null) {
- throw new StateError("No more elements");
- }
- type = object;
+ if (object == null) return false;
+ _current = object;
object = null;
- return type;
+ return true;
} else {
- return push(queue.removeFirst());
+ _current = push(queue.removeFirst());
+ return true;
}
}
-
- bool get hasNext => !queue.isEmpty || object != null;
}

Powered by Google App Engine
This is Rietveld 408576698