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

Side by Side Diff: lib/runtime/dart/async.js

Issue 1169473003: fixes #43, remove => workaround (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 6 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 unified diff | Download patch
« no previous file with comments | « lib/runtime/dart/_js_helper.js ('k') | lib/runtime/dart/collection.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 var async = dart.defineLibrary(async, {}); 1 var async = dart.defineLibrary(async, {});
2 var core = dart.import(core); 2 var core = dart.import(core);
3 var _internal = dart.import(_internal); 3 var _internal = dart.import(_internal);
4 var _js_helper = dart.lazyImport(_js_helper); 4 var _js_helper = dart.lazyImport(_js_helper);
5 var _isolate_helper = dart.lazyImport(_isolate_helper); 5 var _isolate_helper = dart.lazyImport(_isolate_helper);
6 var collection = dart.import(collection); 6 var collection = dart.import(collection);
7 (function(exports, core, _internal, _js_helper, _isolate_helper, collection) { 7 (function(exports, core, _internal, _js_helper, _isolate_helper, collection) {
8 'use strict'; 8 'use strict';
9 function _invokeErrorHandler(errorHandler, error, stackTrace) { 9 function _invokeErrorHandler(errorHandler, error, stackTrace) {
10 if (dart.is(errorHandler, ZoneBinaryCallback)) { 10 if (dart.is(errorHandler, ZoneBinaryCallback)) {
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 return new (_WhereStream$(T))(this, test); 152 return new (_WhereStream$(T))(this, test);
153 } 153 }
154 map(convert) { 154 map(convert) {
155 dart.as(convert, dart.functionType(core.Object, [T])); 155 dart.as(convert, dart.functionType(core.Object, [T]));
156 return new (_MapStream$(T, core.Object))(this, convert); 156 return new (_MapStream$(T, core.Object))(this, convert);
157 } 157 }
158 asyncMap(convert) { 158 asyncMap(convert) {
159 dart.as(convert, dart.functionType(core.Object, [T])); 159 dart.as(convert, dart.functionType(core.Object, [T]));
160 let controller = null; 160 let controller = null;
161 let subscription = null; 161 let subscription = null;
162 let onListen = (() => { 162 let onListen = () => {
163 let add = dart.bind(controller, 'add'); 163 let add = dart.bind(controller, 'add');
164 dart.assert(dart.is(controller, _StreamController) || dart.is(controll er, _BroadcastStreamController)); 164 dart.assert(dart.is(controller, _StreamController) || dart.is(controll er, _BroadcastStreamController));
165 let eventSink = controller; 165 let eventSink = controller;
166 let addError = eventSink[_addError]; 166 let addError = eventSink[_addError];
167 subscription = this.listen(dart.fn(event => { 167 subscription = this.listen(dart.fn(event => {
168 dart.as(event, T); 168 dart.as(event, T);
169 let newValue = null; 169 let newValue = null;
170 try { 170 try {
171 newValue = convert(event); 171 newValue = convert(event);
172 } catch (e) { 172 } catch (e) {
173 let s = dart.stackTrace(e); 173 let s = dart.stackTrace(e);
174 controller.addError(e, s); 174 controller.addError(e, s);
175 return; 175 return;
176 } 176 }
177 177
178 if (dart.is(newValue, Future)) { 178 if (dart.is(newValue, Future)) {
179 subscription.pause(); 179 subscription.pause();
180 dart.dsend(dart.dsend(newValue, 'then', add, {onError: addError}), 'whenComplete', dart.bind(subscription, 'resume')); 180 dart.dsend(dart.dsend(newValue, 'then', add, {onError: addError}), 'whenComplete', dart.bind(subscription, 'resume'));
181 } else { 181 } else {
182 controller.add(newValue); 182 controller.add(newValue);
183 } 183 }
184 }, core.Object, [T]), {onError: dart.as(addError, core.Function), onDo ne: dart.bind(controller, 'close')}); 184 }, core.Object, [T]), {onError: dart.as(addError, core.Function), onDo ne: dart.bind(controller, 'close')});
185 }).bind(this); 185 };
186 dart.fn(onListen, dart.void, []); 186 dart.fn(onListen, dart.void, []);
187 if (this.isBroadcast) { 187 if (this.isBroadcast) {
188 controller = StreamController.broadcast({onListen: onListen, onCancel: dart.fn(() => { 188 controller = StreamController.broadcast({onListen: onListen, onCancel: dart.fn(() => {
189 subscription.cancel(); 189 subscription.cancel();
190 }), sync: true}); 190 }), sync: true});
191 } else { 191 } else {
192 controller = StreamController.new({onListen: onListen, onPause: dart.f n(() => { 192 controller = StreamController.new({onListen: onListen, onPause: dart.f n(() => {
193 subscription.pause(); 193 subscription.pause();
194 }), onResume: dart.fn(() => { 194 }), onResume: dart.fn(() => {
195 subscription.resume(); 195 subscription.resume();
196 }), onCancel: dart.fn(() => { 196 }), onCancel: dart.fn(() => {
197 subscription.cancel(); 197 subscription.cancel();
198 }), sync: true}); 198 }), sync: true});
199 } 199 }
200 return controller.stream; 200 return controller.stream;
201 } 201 }
202 asyncExpand(convert) { 202 asyncExpand(convert) {
203 dart.as(convert, dart.functionType(Stream$(), [T])); 203 dart.as(convert, dart.functionType(Stream$(), [T]));
204 let controller = null; 204 let controller = null;
205 let subscription = null; 205 let subscription = null;
206 let onListen = (() => { 206 let onListen = () => {
207 dart.assert(dart.is(controller, _StreamController) || dart.is(controll er, _BroadcastStreamController)); 207 dart.assert(dart.is(controller, _StreamController) || dart.is(controll er, _BroadcastStreamController));
208 let eventSink = controller; 208 let eventSink = controller;
209 subscription = this.listen(dart.fn(event => { 209 subscription = this.listen(dart.fn(event => {
210 dart.as(event, T); 210 dart.as(event, T);
211 let newStream = null; 211 let newStream = null;
212 try { 212 try {
213 newStream = convert(event); 213 newStream = convert(event);
214 } catch (e) { 214 } catch (e) {
215 let s = dart.stackTrace(e); 215 let s = dart.stackTrace(e);
216 controller.addError(e, s); 216 controller.addError(e, s);
217 return; 217 return;
218 } 218 }
219 219
220 if (newStream != null) { 220 if (newStream != null) {
221 subscription.pause(); 221 subscription.pause();
222 controller.addStream(newStream).whenComplete(dart.bind(subscriptio n, 'resume')); 222 controller.addStream(newStream).whenComplete(dart.bind(subscriptio n, 'resume'));
223 } 223 }
224 }, core.Object, [T]), {onError: dart.as(eventSink[_addError], core.Fun ction), onDone: dart.bind(controller, 'close')}); 224 }, core.Object, [T]), {onError: dart.as(eventSink[_addError], core.Fun ction), onDone: dart.bind(controller, 'close')});
225 }).bind(this); 225 };
226 dart.fn(onListen, dart.void, []); 226 dart.fn(onListen, dart.void, []);
227 if (this.isBroadcast) { 227 if (this.isBroadcast) {
228 controller = StreamController.broadcast({onListen: onListen, onCancel: dart.fn(() => { 228 controller = StreamController.broadcast({onListen: onListen, onCancel: dart.fn(() => {
229 subscription.cancel(); 229 subscription.cancel();
230 }), sync: true}); 230 }), sync: true});
231 } else { 231 } else {
232 controller = StreamController.new({onListen: onListen, onPause: dart.f n(() => { 232 controller = StreamController.new({onListen: onListen, onPause: dart.f n(() => {
233 subscription.pause(); 233 subscription.pause();
234 }), onResume: dart.fn(() => { 234 }), onResume: dart.fn(() => {
235 subscription.resume(); 235 subscription.resume();
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 let future = new (_Future$(T))(); 642 let future = new (_Future$(T))();
643 let subscription = null; 643 let subscription = null;
644 let elementIndex = 0; 644 let elementIndex = 0;
645 subscription = this.listen(dart.fn(value => { 645 subscription = this.listen(dart.fn(value => {
646 dart.as(value, T); 646 dart.as(value, T);
647 if (index == elementIndex) { 647 if (index == elementIndex) {
648 _cancelAndValue(subscription, future, value); 648 _cancelAndValue(subscription, future, value);
649 return; 649 return;
650 } 650 }
651 elementIndex = dart.notNull(elementIndex) + 1; 651 elementIndex = dart.notNull(elementIndex) + 1;
652 }, core.Object, [T]), {onError: dart.bind(future, _completeError), onDon e: dart.fn((() => { 652 }, core.Object, [T]), {onError: dart.bind(future, _completeError), onDon e: dart.fn(() => {
653 future[_completeError](core.RangeError.index(index, this, "index", n ull, elementIndex)); 653 future[_completeError](core.RangeError.index(index, this, "index", n ull, elementIndex));
654 }).bind(this)), cancelOnError: true}); 654 }), cancelOnError: true});
655 return future; 655 return future;
656 } 656 }
657 timeout(timeLimit, opts) { 657 timeout(timeLimit, opts) {
658 let onTimeout = opts && 'onTimeout' in opts ? opts.onTimeout : null; 658 let onTimeout = opts && 'onTimeout' in opts ? opts.onTimeout : null;
659 dart.as(onTimeout, dart.functionType(dart.void, [EventSink])); 659 dart.as(onTimeout, dart.functionType(dart.void, [EventSink]));
660 let controller = null; 660 let controller = null;
661 let subscription = null; 661 let subscription = null;
662 let timer = null; 662 let timer = null;
663 let zone = null; 663 let zone = null;
664 let timeout = null; 664 let timeout = null;
(...skipping 10 matching lines...) Expand all
675 let eventSink = controller; 675 let eventSink = controller;
676 dart.dcall(eventSink[_addError], error, stackTrace); 676 dart.dcall(eventSink[_addError], error, stackTrace);
677 timer = zone.createTimer(timeLimit, dart.as(timeout, dart.functionType (dart.void, []))); 677 timer = zone.createTimer(timeLimit, dart.as(timeout, dart.functionType (dart.void, [])));
678 }; 678 };
679 dart.fn(onError, dart.void, [core.Object, core.StackTrace]); 679 dart.fn(onError, dart.void, [core.Object, core.StackTrace]);
680 let onDone = () => { 680 let onDone = () => {
681 timer.cancel(); 681 timer.cancel();
682 controller.close(); 682 controller.close();
683 }; 683 };
684 dart.fn(onDone, dart.void, []); 684 dart.fn(onDone, dart.void, []);
685 let onListen = (() => { 685 let onListen = () => {
686 zone = Zone.current; 686 zone = Zone.current;
687 if (onTimeout == null) { 687 if (onTimeout == null) {
688 timeout = dart.fn(() => { 688 timeout = dart.fn(() => {
689 controller.addError(new TimeoutException("No stream event", timeLi mit), null); 689 controller.addError(new TimeoutException("No stream event", timeLi mit), null);
690 }); 690 });
691 } else { 691 } else {
692 onTimeout = dart.as(zone.registerUnaryCallback(onTimeout), __CastTyp e18); 692 onTimeout = dart.as(zone.registerUnaryCallback(onTimeout), __CastTyp e18);
693 let wrapper = new _ControllerEventSinkWrapper(null); 693 let wrapper = new _ControllerEventSinkWrapper(null);
694 timeout = dart.fn(() => { 694 timeout = dart.fn(() => {
695 wrapper[_sink] = controller; 695 wrapper[_sink] = controller;
696 zone.runUnaryGuarded(onTimeout, wrapper); 696 zone.runUnaryGuarded(onTimeout, wrapper);
697 wrapper[_sink] = null; 697 wrapper[_sink] = null;
698 }); 698 });
699 } 699 }
700 subscription = this.listen(onData, {onError: onError, onDone: onDone}) ; 700 subscription = this.listen(onData, {onError: onError, onDone: onDone}) ;
701 timer = zone.createTimer(timeLimit, dart.as(timeout, dart.functionType (dart.void, []))); 701 timer = zone.createTimer(timeLimit, dart.as(timeout, dart.functionType (dart.void, [])));
702 }).bind(this); 702 };
703 dart.fn(onListen, dart.void, []); 703 dart.fn(onListen, dart.void, []);
704 let onCancel = () => { 704 let onCancel = () => {
705 timer.cancel(); 705 timer.cancel();
706 let result = subscription.cancel(); 706 let result = subscription.cancel();
707 subscription = null; 707 subscription = null;
708 return result; 708 return result;
709 }; 709 };
710 dart.fn(onCancel, Future, []); 710 dart.fn(onCancel, Future, []);
711 controller = this.isBroadcast ? new _SyncBroadcastStreamController(onLis ten, onCancel) : new _SyncStreamController(onListen, dart.fn(() => { 711 controller = this.isBroadcast ? new _SyncBroadcastStreamController(onLis ten, onCancel) : new _SyncStreamController(onListen, dart.fn(() => {
712 timer.cancel(); 712 timer.cancel();
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 this[_cancel](); 971 this[_cancel]();
972 return this[_cancelFuture]; 972 return this[_cancelFuture];
973 } 973 }
974 asFuture(futureValue) { 974 asFuture(futureValue) {
975 if (futureValue === void 0) 975 if (futureValue === void 0)
976 futureValue = null; 976 futureValue = null;
977 let result = new (_Future$(T))(); 977 let result = new (_Future$(T))();
978 this[_onDone] = dart.fn(() => { 978 this[_onDone] = dart.fn(() => {
979 result[_complete](futureValue); 979 result[_complete](futureValue);
980 }); 980 });
981 this[_onError] = dart.fn(((error, stackTrace) => { 981 this[_onError] = dart.fn((error, stackTrace) => {
982 this.cancel(); 982 this.cancel();
983 result[_completeError](error, dart.as(stackTrace, core.StackTrace)); 983 result[_completeError](error, dart.as(stackTrace, core.StackTrace));
984 }).bind(this)); 984 });
985 return result; 985 return result;
986 } 986 }
987 get [_isInputPaused]() { 987 get [_isInputPaused]() {
988 return (dart.notNull(this[_state]) & dart.notNull(_BufferingStreamSubscr iption$()._STATE_INPUT_PAUSED)) != 0; 988 return (dart.notNull(this[_state]) & dart.notNull(_BufferingStreamSubscr iption$()._STATE_INPUT_PAUSED)) != 0;
989 } 989 }
990 get [_isClosed]() { 990 get [_isClosed]() {
991 return (dart.notNull(this[_state]) & dart.notNull(_BufferingStreamSubscr iption$()._STATE_CLOSED)) != 0; 991 return (dart.notNull(this[_state]) & dart.notNull(_BufferingStreamSubscr iption$()._STATE_CLOSED)) != 0;
992 } 992 }
993 get [_isCanceled]() { 993 get [_isCanceled]() {
994 return (dart.notNull(this[_state]) & dart.notNull(_BufferingStreamSubscr iption$()._STATE_CANCELED)) != 0; 994 return (dart.notNull(this[_state]) & dart.notNull(_BufferingStreamSubscr iption$()._STATE_CANCELED)) != 0;
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1095 this[_state] = dart.notNull(this[_state]) | dart.notNull(_BufferingStrea mSubscription$()._STATE_IN_CALLBACK); 1095 this[_state] = dart.notNull(this[_state]) | dart.notNull(_BufferingStrea mSubscription$()._STATE_IN_CALLBACK);
1096 this[_zone].runUnaryGuarded(this[_onData], data); 1096 this[_zone].runUnaryGuarded(this[_onData], data);
1097 this[_state] = dart.notNull(this[_state]) & ~dart.notNull(_BufferingStre amSubscription$()._STATE_IN_CALLBACK); 1097 this[_state] = dart.notNull(this[_state]) & ~dart.notNull(_BufferingStre amSubscription$()._STATE_IN_CALLBACK);
1098 this[_checkState](wasInputPaused); 1098 this[_checkState](wasInputPaused);
1099 } 1099 }
1100 [_sendError](error, stackTrace) { 1100 [_sendError](error, stackTrace) {
1101 dart.assert(!dart.notNull(this[_isCanceled])); 1101 dart.assert(!dart.notNull(this[_isCanceled]));
1102 dart.assert(!dart.notNull(this[_isPaused])); 1102 dart.assert(!dart.notNull(this[_isPaused]));
1103 dart.assert(!dart.notNull(this[_inCallback])); 1103 dart.assert(!dart.notNull(this[_inCallback]));
1104 let wasInputPaused = this[_isInputPaused]; 1104 let wasInputPaused = this[_isInputPaused];
1105 let sendError = (() => { 1105 let sendError = () => {
1106 if (dart.notNull(this[_isCanceled]) && !dart.notNull(this[_waitsForCan cel])) 1106 if (dart.notNull(this[_isCanceled]) && !dart.notNull(this[_waitsForCan cel]))
1107 return; 1107 return;
1108 this[_state] = dart.notNull(this[_state]) | dart.notNull(_BufferingStr eamSubscription$()._STATE_IN_CALLBACK); 1108 this[_state] = dart.notNull(this[_state]) | dart.notNull(_BufferingStr eamSubscription$()._STATE_IN_CALLBACK);
1109 if (dart.is(this[_onError], ZoneBinaryCallback)) { 1109 if (dart.is(this[_onError], ZoneBinaryCallback)) {
1110 this[_zone].runBinaryGuarded(dart.as(this[_onError], __CastType22), error, stackTrace); 1110 this[_zone].runBinaryGuarded(dart.as(this[_onError], __CastType22), error, stackTrace);
1111 } else { 1111 } else {
1112 this[_zone].runUnaryGuarded(dart.as(this[_onError], __CastType25), e rror); 1112 this[_zone].runUnaryGuarded(dart.as(this[_onError], __CastType25), e rror);
1113 } 1113 }
1114 this[_state] = dart.notNull(this[_state]) & ~dart.notNull(_BufferingSt reamSubscription$()._STATE_IN_CALLBACK); 1114 this[_state] = dart.notNull(this[_state]) & ~dart.notNull(_BufferingSt reamSubscription$()._STATE_IN_CALLBACK);
1115 }).bind(this); 1115 };
1116 dart.fn(sendError, dart.void, []); 1116 dart.fn(sendError, dart.void, []);
1117 if (this[_cancelOnError]) { 1117 if (this[_cancelOnError]) {
1118 this[_state] = dart.notNull(this[_state]) | dart.notNull(_BufferingStr eamSubscription$()._STATE_WAIT_FOR_CANCEL); 1118 this[_state] = dart.notNull(this[_state]) | dart.notNull(_BufferingStr eamSubscription$()._STATE_WAIT_FOR_CANCEL);
1119 this[_cancel](); 1119 this[_cancel]();
1120 if (dart.is(this[_cancelFuture], Future)) { 1120 if (dart.is(this[_cancelFuture], Future)) {
1121 this[_cancelFuture].whenComplete(sendError); 1121 this[_cancelFuture].whenComplete(sendError);
1122 } else { 1122 } else {
1123 sendError(); 1123 sendError();
1124 } 1124 }
1125 } else { 1125 } else {
1126 sendError(); 1126 sendError();
1127 this[_checkState](wasInputPaused); 1127 this[_checkState](wasInputPaused);
1128 } 1128 }
1129 } 1129 }
1130 [_sendDone]() { 1130 [_sendDone]() {
1131 dart.assert(!dart.notNull(this[_isCanceled])); 1131 dart.assert(!dart.notNull(this[_isCanceled]));
1132 dart.assert(!dart.notNull(this[_isPaused])); 1132 dart.assert(!dart.notNull(this[_isPaused]));
1133 dart.assert(!dart.notNull(this[_inCallback])); 1133 dart.assert(!dart.notNull(this[_inCallback]));
1134 let sendDone = (() => { 1134 let sendDone = () => {
1135 if (!dart.notNull(this[_waitsForCancel])) 1135 if (!dart.notNull(this[_waitsForCancel]))
1136 return; 1136 return;
1137 this[_state] = dart.notNull(this[_state]) | dart.notNull(_BufferingStr eamSubscription$()._STATE_CANCELED) | dart.notNull(_BufferingStreamSubscription$ ()._STATE_CLOSED) | dart.notNull(_BufferingStreamSubscription$()._STATE_IN_CALLB ACK); 1137 this[_state] = dart.notNull(this[_state]) | dart.notNull(_BufferingStr eamSubscription$()._STATE_CANCELED) | dart.notNull(_BufferingStreamSubscription$ ()._STATE_CLOSED) | dart.notNull(_BufferingStreamSubscription$()._STATE_IN_CALLB ACK);
1138 this[_zone].runGuarded(this[_onDone]); 1138 this[_zone].runGuarded(this[_onDone]);
1139 this[_state] = dart.notNull(this[_state]) & ~dart.notNull(_BufferingSt reamSubscription$()._STATE_IN_CALLBACK); 1139 this[_state] = dart.notNull(this[_state]) & ~dart.notNull(_BufferingSt reamSubscription$()._STATE_IN_CALLBACK);
1140 }).bind(this); 1140 };
1141 dart.fn(sendDone, dart.void, []); 1141 dart.fn(sendDone, dart.void, []);
1142 this[_cancel](); 1142 this[_cancel]();
1143 this[_state] = dart.notNull(this[_state]) | dart.notNull(_BufferingStrea mSubscription$()._STATE_WAIT_FOR_CANCEL); 1143 this[_state] = dart.notNull(this[_state]) | dart.notNull(_BufferingStrea mSubscription$()._STATE_WAIT_FOR_CANCEL);
1144 if (dart.is(this[_cancelFuture], Future)) { 1144 if (dart.is(this[_cancelFuture], Future)) {
1145 this[_cancelFuture].whenComplete(sendDone); 1145 this[_cancelFuture].whenComplete(sendDone);
1146 } else { 1146 } else {
1147 sendDone(); 1147 sendDone();
1148 } 1148 }
1149 } 1149 }
1150 [_guardCallback](callback) { 1150 [_guardCallback](callback) {
(...skipping 1175 matching lines...) Expand 10 before | Expand all | Expand 10 after
2326 dart.assert(!dart.notNull(this[_isComplete])); 2326 dart.assert(!dart.notNull(this[_isComplete]));
2327 this[_state] = _Future$()._ERROR; 2327 this[_state] = _Future$()._ERROR;
2328 this[_resultOrListeners] = error; 2328 this[_resultOrListeners] = error;
2329 } 2329 }
2330 [_setError](error, stackTrace) { 2330 [_setError](error, stackTrace) {
2331 this[_setErrorObject](new AsyncError(error, stackTrace)); 2331 this[_setErrorObject](new AsyncError(error, stackTrace));
2332 } 2332 }
2333 [_addListener](listener) { 2333 [_addListener](listener) {
2334 dart.assert(listener[_nextListener] == null); 2334 dart.assert(listener[_nextListener] == null);
2335 if (this[_isComplete]) { 2335 if (this[_isComplete]) {
2336 this[_zone].scheduleMicrotask(dart.fn((() => { 2336 this[_zone].scheduleMicrotask(dart.fn(() => {
2337 _Future$()._propagateToListeners(this, listener); 2337 _Future$()._propagateToListeners(this, listener);
2338 }).bind(this))); 2338 }));
2339 } else { 2339 } else {
2340 listener[_nextListener] = dart.as(this[_resultOrListeners], _FutureLis tener); 2340 listener[_nextListener] = dart.as(this[_resultOrListeners], _FutureLis tener);
2341 this[_resultOrListeners] = listener; 2341 this[_resultOrListeners] = listener;
2342 } 2342 }
2343 } 2343 }
2344 [_removeListeners]() { 2344 [_removeListeners]() {
2345 dart.assert(!dart.notNull(this[_isComplete])); 2345 dart.assert(!dart.notNull(this[_isComplete]));
2346 let current = dart.as(this[_resultOrListeners], _FutureListener); 2346 let current = dart.as(this[_resultOrListeners], _FutureListener);
2347 this[_resultOrListeners] = null; 2347 this[_resultOrListeners] = null;
2348 let prev = null; 2348 let prev = null;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
2410 } 2410 }
2411 [_asyncComplete](value) { 2411 [_asyncComplete](value) {
2412 dart.assert(!dart.notNull(this[_isComplete])); 2412 dart.assert(!dart.notNull(this[_isComplete]));
2413 if (value == null) { 2413 if (value == null) {
2414 } else if (dart.is(value, Future)) { 2414 } else if (dart.is(value, Future)) {
2415 let typedFuture = dart.as(value, Future$(T)); 2415 let typedFuture = dart.as(value, Future$(T));
2416 if (dart.is(typedFuture, _Future$())) { 2416 if (dart.is(typedFuture, _Future$())) {
2417 let coreFuture = dart.as(typedFuture, _Future$(T)); 2417 let coreFuture = dart.as(typedFuture, _Future$(T));
2418 if (dart.notNull(coreFuture[_isComplete]) && dart.notNull(coreFuture [_hasError])) { 2418 if (dart.notNull(coreFuture[_isComplete]) && dart.notNull(coreFuture [_hasError])) {
2419 this[_markPendingCompletion](); 2419 this[_markPendingCompletion]();
2420 this[_zone].scheduleMicrotask(dart.fn((() => { 2420 this[_zone].scheduleMicrotask(dart.fn(() => {
2421 _Future$()._chainCoreFuture(coreFuture, this); 2421 _Future$()._chainCoreFuture(coreFuture, this);
2422 }).bind(this))); 2422 }));
2423 } else { 2423 } else {
2424 _Future$()._chainCoreFuture(coreFuture, this); 2424 _Future$()._chainCoreFuture(coreFuture, this);
2425 } 2425 }
2426 } else { 2426 } else {
2427 _Future$()._chainForeignFuture(typedFuture, this); 2427 _Future$()._chainForeignFuture(typedFuture, this);
2428 } 2428 }
2429 return; 2429 return;
2430 } else { 2430 } else {
2431 let typedValue = dart.as(value, T); 2431 let typedValue = dart.as(value, T);
2432 } 2432 }
2433 this[_markPendingCompletion](); 2433 this[_markPendingCompletion]();
2434 this[_zone].scheduleMicrotask(dart.fn((() => { 2434 this[_zone].scheduleMicrotask(dart.fn(() => {
2435 this[_completeWithValue](value); 2435 this[_completeWithValue](value);
2436 }).bind(this))); 2436 }));
2437 } 2437 }
2438 [_asyncCompleteError](error, stackTrace) { 2438 [_asyncCompleteError](error, stackTrace) {
2439 dart.assert(!dart.notNull(this[_isComplete])); 2439 dart.assert(!dart.notNull(this[_isComplete]));
2440 this[_markPendingCompletion](); 2440 this[_markPendingCompletion]();
2441 this[_zone].scheduleMicrotask(dart.fn((() => { 2441 this[_zone].scheduleMicrotask(dart.fn(() => {
2442 this[_completeError](error, stackTrace); 2442 this[_completeError](error, stackTrace);
2443 }).bind(this))); 2443 }));
2444 } 2444 }
2445 static _propagateToListeners(source, listeners) { 2445 static _propagateToListeners(source, listeners) {
2446 while (true) { 2446 while (true) {
2447 dart.assert(source[_isComplete]); 2447 dart.assert(source[_isComplete]);
2448 let hasError = source[_hasError]; 2448 let hasError = source[_hasError];
2449 if (listeners == null) { 2449 if (listeners == null) {
2450 if (hasError) { 2450 if (hasError) {
2451 let asyncError = source[_error]; 2451 let asyncError = source[_error];
2452 source[_zone].handleUncaughtError(asyncError.error, asyncError.sta ckTrace); 2452 source[_zone].handleUncaughtError(asyncError.error, asyncError.sta ckTrace);
2453 } 2453 }
(...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after
3176 let pendingEvents = this[_pendingEvents]; 3176 let pendingEvents = this[_pendingEvents];
3177 this[_state] = dart.notNull(this[_state]) | dart.notNull(_StreamControll er$()._STATE_SUBSCRIBED); 3177 this[_state] = dart.notNull(this[_state]) | dart.notNull(_StreamControll er$()._STATE_SUBSCRIBED);
3178 if (this[_isAddingStream]) { 3178 if (this[_isAddingStream]) {
3179 let addState = dart.as(this[_varData], _StreamControllerAddStreamState ); 3179 let addState = dart.as(this[_varData], _StreamControllerAddStreamState );
3180 addState.varData = subscription; 3180 addState.varData = subscription;
3181 addState.resume(); 3181 addState.resume();
3182 } else { 3182 } else {
3183 this[_varData] = subscription; 3183 this[_varData] = subscription;
3184 } 3184 }
3185 subscription[_setPendingEvents](pendingEvents); 3185 subscription[_setPendingEvents](pendingEvents);
3186 subscription[_guardCallback](dart.fn((() => { 3186 subscription[_guardCallback](dart.fn(() => {
3187 _runGuarded(this[_onListen]); 3187 _runGuarded(this[_onListen]);
3188 }).bind(this))); 3188 }));
3189 return dart.as(subscription, StreamSubscription$(T)); 3189 return dart.as(subscription, StreamSubscription$(T));
3190 } 3190 }
3191 [_recordCancel](subscription) { 3191 [_recordCancel](subscription) {
3192 dart.as(subscription, StreamSubscription$(T)); 3192 dart.as(subscription, StreamSubscription$(T));
3193 let result = null; 3193 let result = null;
3194 if (this[_isAddingStream]) { 3194 if (this[_isAddingStream]) {
3195 let addState = dart.as(this[_varData], _StreamControllerAddStreamState ); 3195 let addState = dart.as(this[_varData], _StreamControllerAddStreamState );
3196 result = addState.cancel(); 3196 result = addState.cancel();
3197 } 3197 }
3198 this[_varData] = null; 3198 this[_varData] = null;
3199 this[_state] = dart.notNull(this[_state]) & ~(dart.notNull(_StreamContro ller$()._STATE_SUBSCRIBED) | dart.notNull(_StreamController$()._STATE_ADDSTREAM) ) | dart.notNull(_StreamController$()._STATE_CANCELED); 3199 this[_state] = dart.notNull(this[_state]) & ~(dart.notNull(_StreamContro ller$()._STATE_SUBSCRIBED) | dart.notNull(_StreamController$()._STATE_ADDSTREAM) ) | dart.notNull(_StreamController$()._STATE_CANCELED);
3200 if (this[_onCancel] != null) { 3200 if (this[_onCancel] != null) {
3201 if (result == null) { 3201 if (result == null) {
3202 try { 3202 try {
3203 result = dart.as(this[_onCancel](), Future); 3203 result = dart.as(this[_onCancel](), Future);
3204 } catch (e) { 3204 } catch (e) {
3205 let s = dart.stackTrace(e); 3205 let s = dart.stackTrace(e);
3206 result = new _Future(); 3206 result = new _Future();
3207 result[_asyncCompleteError](e, s); 3207 result[_asyncCompleteError](e, s);
3208 } 3208 }
3209 3209
3210 } else { 3210 } else {
3211 result = result.whenComplete(this[_onCancel]); 3211 result = result.whenComplete(this[_onCancel]);
3212 } 3212 }
3213 } 3213 }
3214 let complete = (() => { 3214 let complete = () => {
3215 if (dart.notNull(this[_doneFuture] != null) && dart.notNull(this[_done Future][_mayComplete])) { 3215 if (dart.notNull(this[_doneFuture] != null) && dart.notNull(this[_done Future][_mayComplete])) {
3216 this[_doneFuture][_asyncComplete](null); 3216 this[_doneFuture][_asyncComplete](null);
3217 } 3217 }
3218 }).bind(this); 3218 };
3219 dart.fn(complete, dart.void, []); 3219 dart.fn(complete, dart.void, []);
3220 if (result != null) { 3220 if (result != null) {
3221 result = result.whenComplete(complete); 3221 result = result.whenComplete(complete);
3222 } else { 3222 } else {
3223 complete(); 3223 complete();
3224 } 3224 }
3225 return result; 3225 return result;
3226 } 3226 }
3227 [_recordPause](subscription) { 3227 [_recordPause](subscription) {
3228 dart.as(subscription, StreamSubscription$(T)); 3228 dart.as(subscription, StreamSubscription$(T));
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
3440 } 3440 }
3441 resume() { 3441 resume() {
3442 this.addSubscription.resume(); 3442 this.addSubscription.resume();
3443 } 3443 }
3444 cancel() { 3444 cancel() {
3445 let cancel = this.addSubscription.cancel(); 3445 let cancel = this.addSubscription.cancel();
3446 if (cancel == null) { 3446 if (cancel == null) {
3447 this.addStreamFuture[_asyncComplete](null); 3447 this.addStreamFuture[_asyncComplete](null);
3448 return null; 3448 return null;
3449 } 3449 }
3450 return cancel.whenComplete(dart.fn((() => { 3450 return cancel.whenComplete(dart.fn(() => {
3451 this.addStreamFuture[_asyncComplete](null); 3451 this.addStreamFuture[_asyncComplete](null);
3452 }).bind(this))); 3452 }));
3453 } 3453 }
3454 complete() { 3454 complete() {
3455 this.addStreamFuture[_asyncComplete](null); 3455 this.addStreamFuture[_asyncComplete](null);
3456 } 3456 }
3457 } 3457 }
3458 dart.setSignature(_AddStreamState, { 3458 dart.setSignature(_AddStreamState, {
3459 constructors: () => ({_AddStreamState: [_AddStreamState$(T), [_EventSink$( T), Stream, core.bool]]}), 3459 constructors: () => ({_AddStreamState: [_AddStreamState$(T), [_EventSink$( T), Stream, core.bool]]}),
3460 methods: () => ({ 3460 methods: () => ({
3461 pause: [dart.void, []], 3461 pause: [dart.void, []],
3462 resume: [dart.void, []], 3462 resume: [dart.void, []],
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
3515 [_createSubscription](onData, onError, onDone, cancelOnError) { 3515 [_createSubscription](onData, onError, onDone, cancelOnError) {
3516 dart.as(onData, dart.functionType(dart.void, [T])); 3516 dart.as(onData, dart.functionType(dart.void, [T]));
3517 dart.as(onDone, dart.functionType(dart.void, [])); 3517 dart.as(onDone, dart.functionType(dart.void, []));
3518 if (this[_isUsed]) 3518 if (this[_isUsed])
3519 throw new core.StateError("Stream has already been listened to."); 3519 throw new core.StateError("Stream has already been listened to.");
3520 this[_isUsed] = true; 3520 this[_isUsed] = true;
3521 return dart.as((() => { 3521 return dart.as((() => {
3522 let _ = new _BufferingStreamSubscription(onData, onError, onDone, canc elOnError); 3522 let _ = new _BufferingStreamSubscription(onData, onError, onDone, canc elOnError);
3523 _[_setPendingEvents](this[_pending]()); 3523 _[_setPendingEvents](this[_pending]());
3524 return _; 3524 return _;
3525 }).bind(this)(), StreamSubscription$(T)); 3525 })(), StreamSubscription$(T));
3526 } 3526 }
3527 } 3527 }
3528 dart.setSignature(_GeneratedStreamImpl, { 3528 dart.setSignature(_GeneratedStreamImpl, {
3529 constructors: () => ({_GeneratedStreamImpl: [_GeneratedStreamImpl$(T), [_E ventGenerator]]}), 3529 constructors: () => ({_GeneratedStreamImpl: [_GeneratedStreamImpl$(T), [_E ventGenerator]]}),
3530 methods: () => ({[_createSubscription]: [StreamSubscription$(T), [dart.fun ctionType(dart.void, [T]), core.Function, dart.functionType(dart.void, []), core .bool]]}) 3530 methods: () => ({[_createSubscription]: [StreamSubscription$(T), [dart.fun ctionType(dart.void, [T]), core.Function, dart.functionType(dart.void, []), core .bool]]})
3531 }); 3531 });
3532 return _GeneratedStreamImpl; 3532 return _GeneratedStreamImpl;
3533 }); 3533 });
3534 let _GeneratedStreamImpl = _GeneratedStreamImpl$(); 3534 let _GeneratedStreamImpl = _GeneratedStreamImpl$();
3535 let _eventScheduled = Symbol('_eventScheduled'); 3535 let _eventScheduled = Symbol('_eventScheduled');
3536 class _PendingEvents extends core.Object { 3536 class _PendingEvents extends core.Object {
3537 _PendingEvents() { 3537 _PendingEvents() {
3538 this[_state] = _PendingEvents._STATE_UNSCHEDULED; 3538 this[_state] = _PendingEvents._STATE_UNSCHEDULED;
3539 } 3539 }
3540 get isScheduled() { 3540 get isScheduled() {
3541 return this[_state] == _PendingEvents._STATE_SCHEDULED; 3541 return this[_state] == _PendingEvents._STATE_SCHEDULED;
3542 } 3542 }
3543 get [_eventScheduled]() { 3543 get [_eventScheduled]() {
3544 return dart.notNull(this[_state]) >= dart.notNull(_PendingEvents._STATE_SC HEDULED); 3544 return dart.notNull(this[_state]) >= dart.notNull(_PendingEvents._STATE_SC HEDULED);
3545 } 3545 }
3546 schedule(dispatch) { 3546 schedule(dispatch) {
3547 if (this.isScheduled) 3547 if (this.isScheduled)
3548 return; 3548 return;
3549 dart.assert(!dart.notNull(this.isEmpty)); 3549 dart.assert(!dart.notNull(this.isEmpty));
3550 if (this[_eventScheduled]) { 3550 if (this[_eventScheduled]) {
3551 dart.assert(this[_state] == _PendingEvents._STATE_CANCELED); 3551 dart.assert(this[_state] == _PendingEvents._STATE_CANCELED);
3552 this[_state] = _PendingEvents._STATE_SCHEDULED; 3552 this[_state] = _PendingEvents._STATE_SCHEDULED;
3553 return; 3553 return;
3554 } 3554 }
3555 scheduleMicrotask(dart.fn((() => { 3555 scheduleMicrotask(dart.fn(() => {
3556 let oldState = this[_state]; 3556 let oldState = this[_state];
3557 this[_state] = _PendingEvents._STATE_UNSCHEDULED; 3557 this[_state] = _PendingEvents._STATE_UNSCHEDULED;
3558 if (oldState == _PendingEvents._STATE_CANCELED) 3558 if (oldState == _PendingEvents._STATE_CANCELED)
3559 return; 3559 return;
3560 this.handleNext(dispatch); 3560 this.handleNext(dispatch);
3561 }).bind(this))); 3561 }));
3562 this[_state] = _PendingEvents._STATE_SCHEDULED; 3562 this[_state] = _PendingEvents._STATE_SCHEDULED;
3563 } 3563 }
3564 cancelSchedule() { 3564 cancelSchedule() {
3565 if (this.isScheduled) 3565 if (this.isScheduled)
3566 this[_state] = _PendingEvents._STATE_CANCELED; 3566 this[_state] = _PendingEvents._STATE_CANCELED;
3567 } 3567 }
3568 } 3568 }
3569 dart.setSignature(_PendingEvents, { 3569 dart.setSignature(_PendingEvents, {
3570 methods: () => ({ 3570 methods: () => ({
3571 schedule: [dart.void, [_EventDispatch]], 3571 schedule: [dart.void, [_EventDispatch]],
(...skipping 1664 matching lines...) Expand 10 before | Expand all | Expand 10 after
5236 return _rootRunBinary(null, null, this, f, arg1, arg2); 5236 return _rootRunBinary(null, null, this, f, arg1, arg2);
5237 } catch (e) { 5237 } catch (e) {
5238 let s = dart.stackTrace(e); 5238 let s = dart.stackTrace(e);
5239 return this.handleUncaughtError(e, s); 5239 return this.handleUncaughtError(e, s);
5240 } 5240 }
5241 5241
5242 } 5242 }
5243 bindCallback(f, opts) { 5243 bindCallback(f, opts) {
5244 let runGuarded = opts && 'runGuarded' in opts ? opts.runGuarded : true; 5244 let runGuarded = opts && 'runGuarded' in opts ? opts.runGuarded : true;
5245 if (runGuarded) { 5245 if (runGuarded) {
5246 return dart.fn((() => this.runGuarded(f)).bind(this)); 5246 return dart.fn(() => this.runGuarded(f));
5247 } else { 5247 } else {
5248 return dart.fn((() => this.run(f)).bind(this)); 5248 return dart.fn(() => this.run(f));
5249 } 5249 }
5250 } 5250 }
5251 bindUnaryCallback(f, opts) { 5251 bindUnaryCallback(f, opts) {
5252 let runGuarded = opts && 'runGuarded' in opts ? opts.runGuarded : true; 5252 let runGuarded = opts && 'runGuarded' in opts ? opts.runGuarded : true;
5253 if (runGuarded) { 5253 if (runGuarded) {
5254 return dart.fn((arg => this.runUnaryGuarded(f, arg)).bind(this)); 5254 return dart.fn(arg => this.runUnaryGuarded(f, arg));
5255 } else { 5255 } else {
5256 return dart.fn((arg => this.runUnary(f, arg)).bind(this)); 5256 return dart.fn(arg => this.runUnary(f, arg));
5257 } 5257 }
5258 } 5258 }
5259 bindBinaryCallback(f, opts) { 5259 bindBinaryCallback(f, opts) {
5260 let runGuarded = opts && 'runGuarded' in opts ? opts.runGuarded : true; 5260 let runGuarded = opts && 'runGuarded' in opts ? opts.runGuarded : true;
5261 if (runGuarded) { 5261 if (runGuarded) {
5262 return dart.fn(((arg1, arg2) => this.runBinaryGuarded(f, arg1, arg2)).bi nd(this)); 5262 return dart.fn((arg1, arg2) => this.runBinaryGuarded(f, arg1, arg2));
5263 } else { 5263 } else {
5264 return dart.fn(((arg1, arg2) => this.runBinary(f, arg1, arg2)).bind(this )); 5264 return dart.fn((arg1, arg2) => this.runBinary(f, arg1, arg2));
5265 } 5265 }
5266 } 5266 }
5267 get(key) { 5267 get(key) {
5268 return null; 5268 return null;
5269 } 5269 }
5270 handleUncaughtError(error, stackTrace) { 5270 handleUncaughtError(error, stackTrace) {
5271 return _rootHandleUncaughtError(null, null, this, error, stackTrace); 5271 return _rootHandleUncaughtError(null, null, this, error, stackTrace);
5272 } 5272 }
5273 fork(opts) { 5273 fork(opts) {
5274 let specification = opts && 'specification' in opts ? opts.specification : null; 5274 let specification = opts && 'specification' in opts ? opts.specification : null;
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
5508 } catch (e) { 5508 } catch (e) {
5509 let s = dart.stackTrace(e); 5509 let s = dart.stackTrace(e);
5510 return this.handleUncaughtError(e, s); 5510 return this.handleUncaughtError(e, s);
5511 } 5511 }
5512 5512
5513 } 5513 }
5514 bindCallback(f, opts) { 5514 bindCallback(f, opts) {
5515 let runGuarded = opts && 'runGuarded' in opts ? opts.runGuarded : true; 5515 let runGuarded = opts && 'runGuarded' in opts ? opts.runGuarded : true;
5516 let registered = this.registerCallback(f); 5516 let registered = this.registerCallback(f);
5517 if (runGuarded) { 5517 if (runGuarded) {
5518 return dart.fn((() => this.runGuarded(registered)).bind(this)); 5518 return dart.fn(() => this.runGuarded(registered));
5519 } else { 5519 } else {
5520 return dart.fn((() => this.run(registered)).bind(this)); 5520 return dart.fn(() => this.run(registered));
5521 } 5521 }
5522 } 5522 }
5523 bindUnaryCallback(f, opts) { 5523 bindUnaryCallback(f, opts) {
5524 let runGuarded = opts && 'runGuarded' in opts ? opts.runGuarded : true; 5524 let runGuarded = opts && 'runGuarded' in opts ? opts.runGuarded : true;
5525 let registered = this.registerUnaryCallback(f); 5525 let registered = this.registerUnaryCallback(f);
5526 if (runGuarded) { 5526 if (runGuarded) {
5527 return dart.fn((arg => this.runUnaryGuarded(registered, arg)).bind(this) ); 5527 return dart.fn(arg => this.runUnaryGuarded(registered, arg));
5528 } else { 5528 } else {
5529 return dart.fn((arg => this.runUnary(registered, arg)).bind(this)); 5529 return dart.fn(arg => this.runUnary(registered, arg));
5530 } 5530 }
5531 } 5531 }
5532 bindBinaryCallback(f, opts) { 5532 bindBinaryCallback(f, opts) {
5533 let runGuarded = opts && 'runGuarded' in opts ? opts.runGuarded : true; 5533 let runGuarded = opts && 'runGuarded' in opts ? opts.runGuarded : true;
5534 let registered = this.registerBinaryCallback(f); 5534 let registered = this.registerBinaryCallback(f);
5535 if (runGuarded) { 5535 if (runGuarded) {
5536 return dart.fn(((arg1, arg2) => this.runBinaryGuarded(registered, arg1, arg2)).bind(this)); 5536 return dart.fn((arg1, arg2) => this.runBinaryGuarded(registered, arg1, a rg2));
5537 } else { 5537 } else {
5538 return dart.fn(((arg1, arg2) => this.runBinary(registered, arg1, arg2)). bind(this)); 5538 return dart.fn((arg1, arg2) => this.runBinary(registered, arg1, arg2));
5539 } 5539 }
5540 } 5540 }
5541 get(key) { 5541 get(key) {
5542 let result = this[_map].get(key); 5542 let result = this[_map].get(key);
5543 if (dart.notNull(result != null) || dart.notNull(this[_map].containsKey(ke y))) 5543 if (dart.notNull(result != null) || dart.notNull(this[_map].containsKey(ke y)))
5544 return result; 5544 return result;
5545 if (this.parent != null) { 5545 if (this.parent != null) {
5546 let value = this.parent.get(key); 5546 let value = this.parent.get(key);
5547 if (value != null) { 5547 if (value != null) {
5548 this[_map].set(key, value); 5548 this[_map].set(key, value);
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
5901 exports.ScheduleMicrotaskHandler = ScheduleMicrotaskHandler; 5901 exports.ScheduleMicrotaskHandler = ScheduleMicrotaskHandler;
5902 exports.CreateTimerHandler = CreateTimerHandler; 5902 exports.CreateTimerHandler = CreateTimerHandler;
5903 exports.CreatePeriodicTimerHandler = CreatePeriodicTimerHandler; 5903 exports.CreatePeriodicTimerHandler = CreatePeriodicTimerHandler;
5904 exports.PrintHandler = PrintHandler; 5904 exports.PrintHandler = PrintHandler;
5905 exports.ForkHandler = ForkHandler; 5905 exports.ForkHandler = ForkHandler;
5906 exports.ZoneSpecification = ZoneSpecification; 5906 exports.ZoneSpecification = ZoneSpecification;
5907 exports.ZoneDelegate = ZoneDelegate; 5907 exports.ZoneDelegate = ZoneDelegate;
5908 exports.Zone = Zone; 5908 exports.Zone = Zone;
5909 exports.runZoned = runZoned; 5909 exports.runZoned = runZoned;
5910 })(async, core, _internal, _js_helper, _isolate_helper, collection); 5910 })(async, core, _internal, _js_helper, _isolate_helper, collection);
OLDNEW
« no previous file with comments | « lib/runtime/dart/_js_helper.js ('k') | lib/runtime/dart/collection.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698