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

Unified Diff: lib/runtime/dart/collection.js

Issue 1126713002: fixes #130, accept anything with `iterator` in for loops (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: fix iterator Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | lib/runtime/dart/core.js » ('j') | lib/src/codegen/js_codegen.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/runtime/dart/collection.js
diff --git a/lib/runtime/dart/collection.js b/lib/runtime/dart/collection.js
index a54af9a2a5921508dd11435d66c65d38748b9e73..28fa8f25fa9cb5f89647b0f75ce75d45bd17cbaa 100644
--- a/lib/runtime/dart/collection.js
+++ b/lib/runtime/dart/collection.js
@@ -109,6 +109,9 @@ var collection;
let _newSet = Symbol('_newSet');
let SetMixin$ = dart.generic(function(E) {
class SetMixin extends core.Object {
+ [Symbol.iterator]() {
+ return new dart.JsIterator(this[core.$iterator]);
+ }
get [core.$isEmpty]() {
return this[core.$length] == 0;
}
@@ -454,6 +457,9 @@ var collection;
result.add(e);
return result;
}
+ [Symbol.iterator]() {
+ return new dart.JsIterator(this[core.$iterator]);
+ }
}
HashSet[dart.implements] = () => [core.Set$(E)];
dart.defineNamedConstructor(HashSet, 'identity');
@@ -677,6 +683,9 @@ var collection;
toString() {
return IterableBase.iterableToShortString(this, '(', ')');
}
+ [Symbol.iterator]() {
+ return new dart.JsIterator(this[core.$iterator]);
+ }
}
IterableMixin[dart.implements] = () => [core.Iterable$(E)];
return IterableMixin;
@@ -1020,6 +1029,9 @@ var collection;
parts[core.$add](penultimateString);
parts[core.$add](ultimateString);
}
+ [Symbol.iterator]() {
+ return new dart.JsIterator(this[core.$iterator]);
+ }
}
IterableBase[dart.implements] = () => [core.Iterable$(E)];
dart.defineLazyProperties(IterableBase, {
@@ -1185,6 +1197,9 @@ var collection;
}
return result;
}
+ [Symbol.iterator]() {
+ return new dart.JsIterator(this[core.$iterator]);
+ }
}
LinkedHashSet[dart.implements] = () => [HashSet$(E)];
dart.defineNamedConstructor(LinkedHashSet, 'identity');
@@ -1396,6 +1411,9 @@ var collection;
get [core.$iterator]() {
return new (_internal.ListIterator$(E))(this);
}
+ [Symbol.iterator]() {
+ return new dart.JsIterator(this[core.$iterator]);
+ }
[core.$elementAt](index) {
return this[core.$get](index);
}
@@ -2212,6 +2230,9 @@ var collection;
from(elements) {
return new ListQueue$(E).from(elements);
}
+ [Symbol.iterator]() {
+ return new dart.JsIterator(this[core.$iterator]);
+ }
}
Queue[dart.implements] = () => [core.Iterable$(E), _internal.EfficientLength];
dart.defineNamedConstructor(Queue, 'from');
« no previous file with comments | « no previous file | lib/runtime/dart/core.js » ('j') | lib/src/codegen/js_codegen.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698