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

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

Issue 1243503007: fixes #221, initial sync*, async, async* implementation (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 5 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 | « lib/runtime/dart/_isolate_helper.js ('k') | lib/runtime/dart/async.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/runtime/dart/_js_helper.js
diff --git a/lib/runtime/dart/_js_helper.js b/lib/runtime/dart/_js_helper.js
index 8d42bc3de5f8275dca0eab4c4be2ffcbbc01a05f..66bc8f6908f12ecb9ece013f4fbe5ec44a288a9e 100644
--- a/lib/runtime/dart/_js_helper.js
+++ b/lib/runtime/dart/_js_helper.js
@@ -1137,6 +1137,54 @@ dart_library.library('dart/_js_helper', null, /* Imports */[
return JSON.stringify(string);
}
dart.fn(jsonEncodeNative, core.String, [core.String]);
+ let _jsIterator = Symbol('_jsIterator');
+ let SyncIterator$ = dart.generic(function(E) {
+ class SyncIterator extends core.Object {
+ SyncIterator(jsIterator) {
+ this[_jsIterator] = jsIterator;
+ this[_current] = null;
+ }
+ get current() {
+ return this[_current];
+ }
+ moveNext() {
+ let ret = this[_jsIterator].next();
+ this[_current] = dart.as(ret.value, E);
+ return !ret.done;
+ }
+ }
+ SyncIterator[dart.implements] = () => [core.Iterator$(E)];
+ dart.setSignature(SyncIterator, {
+ constructors: () => ({SyncIterator: [SyncIterator$(E), [dart.dynamic]]}),
+ methods: () => ({moveNext: [core.bool, []]})
+ });
+ return SyncIterator;
+ });
+ let SyncIterator = SyncIterator$();
+ let _generator = Symbol('_generator');
+ let _args = Symbol('_args');
+ let SyncIterable$ = dart.generic(function(E) {
+ class SyncIterable extends collection.IterableBase$(E) {
+ SyncIterable(generator, args) {
+ this[_generator] = generator;
+ this[_args] = args;
+ super.IterableBase();
+ }
+ [_jsIterator]() {
+ return this[_generator](...this[_args]);
+ }
+ get iterator() {
+ return new (SyncIterator$(E))(this[_jsIterator]());
+ }
+ }
+ dart.setSignature(SyncIterable, {
+ constructors: () => ({SyncIterable: [SyncIterable$(E), [dart.dynamic, dart.dynamic]]}),
+ methods: () => ({[_jsIterator]: [dart.dynamic, []]})
+ });
+ dart.defineExtensionMembers(SyncIterable, ['iterator']);
+ return SyncIterable;
+ });
+ let SyncIterable = SyncIterable$();
// Exports:
exports.NoThrows = NoThrows;
exports.NoInline = NoInline;
@@ -1196,4 +1244,8 @@ dart_library.library('dart/_js_helper', null, /* Imports */[
exports.RuntimeError = RuntimeError;
exports.random64 = random64;
exports.jsonEncodeNative = jsonEncodeNative;
+ exports.SyncIterator$ = SyncIterator$;
+ exports.SyncIterator = SyncIterator;
+ exports.SyncIterable$ = SyncIterable$;
+ exports.SyncIterable = SyncIterable;
});
« no previous file with comments | « lib/runtime/dart/_isolate_helper.js ('k') | lib/runtime/dart/async.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698