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

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

Issue 1083763003: refactor emitMemberName to be used more consistently (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: 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 unified diff | Download patch
OLDNEW
1 var async; 1 var async;
2 (function(exports) { 2 (function(exports) {
3 'use strict'; 3 'use strict';
4 // Function _invokeErrorHandler: (Function, Object, StackTrace) → dynamic 4 // Function _invokeErrorHandler: (Function, Object, StackTrace) → dynamic
5 function _invokeErrorHandler(errorHandler, error, stackTrace) { 5 function _invokeErrorHandler(errorHandler, error, stackTrace) {
6 if (dart.is(errorHandler, ZoneBinaryCallback)) { 6 if (dart.is(errorHandler, ZoneBinaryCallback)) {
7 return dart.dinvokef(errorHandler, error, stackTrace); 7 return dart.dinvokef(errorHandler, error, stackTrace);
8 } else { 8 } else {
9 return dart.dinvokef(errorHandler, error); 9 return dart.dinvokef(errorHandler, error);
10 } 10 }
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 } 149 }
150 map(convert) { 150 map(convert) {
151 return new (_MapStream$(T, dart.dynamic))(this, convert); 151 return new (_MapStream$(T, dart.dynamic))(this, convert);
152 } 152 }
153 asyncMap(convert) { 153 asyncMap(convert) {
154 let controller = null; 154 let controller = null;
155 let subscription = null; 155 let subscription = null;
156 // Function onListen: () → void 156 // Function onListen: () → void
157 function onListen() { 157 function onListen() {
158 let add = controller.add; 158 let add = controller.add;
159 dart.assert(dart.notNull(dart.is(controller, _StreamController)) || da rt.notNull(dart.is(controller, _BroadcastStreamController))); 159 dart.assert(dart.is(controller, _StreamController) || dart.is(controll er, _BroadcastStreamController));
160 let eventSink = controller; 160 let eventSink = controller;
161 let addError = eventSink[_addError]; 161 let addError = eventSink[_addError];
162 subscription = this.listen(event => { 162 subscription = this.listen(event => {
163 let newValue = null; 163 let newValue = null;
164 try { 164 try {
165 newValue = convert(event); 165 newValue = convert(event);
166 } catch (e) { 166 } catch (e) {
167 let s = dart.stackTrace(e); 167 let s = dart.stackTrace(e);
168 controller.addError(e, s); 168 controller.addError(e, s);
169 return; 169 return;
170 } 170 }
171 171
172 if (dart.is(newValue, Future)) { 172 if (dart.is(newValue, Future)) {
173 subscription.pause(); 173 subscription.pause();
174 dart.dinvoke(dart.dinvoke(newValue, 'then', add, {onError: addErro r}), 'whenComplete', subscription.resume); 174 dart.dsend(dart.dsend(newValue, 'then', add, {onError: addError}), 'whenComplete', subscription.resume);
175 } else { 175 } else {
176 controller.add(newValue); 176 controller.add(newValue);
177 } 177 }
178 }, {onError: dart.as(addError, core.Function), onDone: controller.clos e}); 178 }, {onError: dart.as(addError, core.Function), onDone: controller.clos e});
179 } 179 }
180 if (this.isBroadcast) { 180 if (this.isBroadcast) {
181 controller = new StreamController.broadcast({ 181 controller = new StreamController.broadcast({
182 onListen: onListen, 182 onListen: onListen,
183 onCancel: () => { 183 onCancel: () => {
184 subscription.cancel(); 184 subscription.cancel();
(...skipping 15 matching lines...) Expand all
200 sync: true 200 sync: true
201 }); 201 });
202 } 202 }
203 return controller.stream; 203 return controller.stream;
204 } 204 }
205 asyncExpand(convert) { 205 asyncExpand(convert) {
206 let controller = null; 206 let controller = null;
207 let subscription = null; 207 let subscription = null;
208 // Function onListen: () → void 208 // Function onListen: () → void
209 function onListen() { 209 function onListen() {
210 dart.assert(dart.notNull(dart.is(controller, _StreamController)) || da rt.notNull(dart.is(controller, _BroadcastStreamController))); 210 dart.assert(dart.is(controller, _StreamController) || dart.is(controll er, _BroadcastStreamController));
211 let eventSink = controller; 211 let eventSink = controller;
212 subscription = this.listen(event => { 212 subscription = this.listen(event => {
213 let newStream = null; 213 let newStream = null;
214 try { 214 try {
215 newStream = convert(event); 215 newStream = convert(event);
216 } catch (e) { 216 } catch (e) {
217 let s = dart.stackTrace(e); 217 let s = dart.stackTrace(e);
218 controller.addError(e, s); 218 controller.addError(e, s);
219 return; 219 return;
220 } 220 }
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 let s = dart.stackTrace(e); 676 let s = dart.stackTrace(e);
677 _completeWithErrorCallback(future, e, s); 677 _completeWithErrorCallback(future, e, s);
678 } 678 }
679 679
680 }, 680 },
681 cancelOnError: true 681 cancelOnError: true
682 }); 682 });
683 return future; 683 return future;
684 } 684 }
685 elementAt(index) { 685 elementAt(index) {
686 if (dart.notNull(!(typeof index == 'number')) || dart.notNull(index) < 0 ) 686 if (!(typeof index == 'number') || dart.notNull(index) < 0)
687 throw new core.ArgumentError(index); 687 throw new core.ArgumentError(index);
688 let future = new (_Future$(T))(); 688 let future = new (_Future$(T))();
689 let subscription = null; 689 let subscription = null;
690 let elementIndex = 0; 690 let elementIndex = 0;
691 subscription = this.listen(value => { 691 subscription = this.listen(value => {
692 if (index == elementIndex) { 692 if (index == elementIndex) {
693 _cancelAndValue(subscription, future, value); 693 _cancelAndValue(subscription, future, value);
694 return; 694 return;
695 } 695 }
696 elementIndex = dart.notNull(elementIndex) + 1; 696 elementIndex = dart.notNull(elementIndex) + 1;
(...skipping 15 matching lines...) Expand all
712 let timeout = null; 712 let timeout = null;
713 // Function onData: (T) → void 713 // Function onData: (T) → void
714 function onData(event) { 714 function onData(event) {
715 timer.cancel(); 715 timer.cancel();
716 controller.add(event); 716 controller.add(event);
717 timer = zone.createTimer(timeLimit, dart.as(timeout, dart.functionType (dart.void, []))); 717 timer = zone.createTimer(timeLimit, dart.as(timeout, dart.functionType (dart.void, [])));
718 } 718 }
719 // Function onError: (dynamic, StackTrace) → void 719 // Function onError: (dynamic, StackTrace) → void
720 function onError(error, stackTrace) { 720 function onError(error, stackTrace) {
721 timer.cancel(); 721 timer.cancel();
722 dart.assert(dart.notNull(dart.is(controller, _StreamController)) || da rt.notNull(dart.is(controller, _BroadcastStreamController))); 722 dart.assert(dart.is(controller, _StreamController) || dart.is(controll er, _BroadcastStreamController));
723 let eventSink = controller; 723 let eventSink = controller;
724 dart.dinvoke(eventSink, '_addError', error, stackTrace); 724 dart.dsend(eventSink, _addError, error, stackTrace);
725 timer = zone.createTimer(timeLimit, dart.as(timeout, dart.functionType (dart.void, []))); 725 timer = zone.createTimer(timeLimit, dart.as(timeout, dart.functionType (dart.void, [])));
726 } 726 }
727 // Function onDone: () → void 727 // Function onDone: () → void
728 function onDone() { 728 function onDone() {
729 timer.cancel(); 729 timer.cancel();
730 controller.close(); 730 controller.close();
731 } 731 }
732 // Function onListen: () → void 732 // Function onListen: () → void
733 function onListen() { 733 function onListen() {
734 zone = Zone.current; 734 zone = Zone.current;
(...skipping 1626 matching lines...) Expand 10 before | Expand all | Expand 10 after
2361 listenerValueOrError = new AsyncError(e, s); 2361 listenerValueOrError = new AsyncError(e, s);
2362 } 2362 }
2363 listenerHasValue = false; 2363 listenerHasValue = false;
2364 return; 2364 return;
2365 } 2365 }
2366 2366
2367 if (dart.is(completeResult, Future)) { 2367 if (dart.is(completeResult, Future)) {
2368 let result = listener.result; 2368 let result = listener.result;
2369 result[_isChained] = true; 2369 result[_isChained] = true;
2370 isPropagationAborted = true; 2370 isPropagationAborted = true;
2371 dart.dinvoke(completeResult, 'then', ignored => { 2371 dart.dsend(completeResult, 'then', ignored => {
2372 _Future[_propagateToListeners](source, new _FutureListener.cha in(result)); 2372 _Future[_propagateToListeners](source, new _FutureListener.cha in(result));
2373 }, { 2373 }, {
2374 onError: (error, stackTrace) => { 2374 onError: (error, stackTrace) => {
2375 if (stackTrace === void 0) 2375 if (stackTrace === void 0)
2376 stackTrace = null; 2376 stackTrace = null;
2377 if (!dart.is(completeResult, _Future)) { 2377 if (!dart.is(completeResult, _Future)) {
2378 completeResult = new _Future(); 2378 completeResult = new _Future();
2379 dart.dinvoke(completeResult, '_setError', error, stackTrac e); 2379 dart.dsend(completeResult, _setError, error, stackTrace);
2380 } 2380 }
2381 _Future[_propagateToListeners](dart.as(completeResult, _Futu re), new _FutureListener.chain(result)); 2381 _Future[_propagateToListeners](dart.as(completeResult, _Futu re), new _FutureListener.chain(result));
2382 } 2382 }
2383 }); 2383 });
2384 } 2384 }
2385 } 2385 }
2386 if (!dart.notNull(hasError)) { 2386 if (!dart.notNull(hasError)) {
2387 if (listener.handlesValue) { 2387 if (listener.handlesValue) {
2388 listenerHasValue = handleValueCallback(); 2388 listenerHasValue = handleValueCallback();
2389 } 2389 }
2390 } else { 2390 } else {
2391 handleError(); 2391 handleError();
2392 } 2392 }
2393 if (listener.handlesComplete) { 2393 if (listener.handlesComplete) {
2394 handleWhenCompleteCallback(); 2394 handleWhenCompleteCallback();
2395 } 2395 }
2396 if (oldZone != null) 2396 if (oldZone != null)
2397 Zone[_leave](oldZone); 2397 Zone[_leave](oldZone);
2398 if (isPropagationAborted) 2398 if (isPropagationAborted)
2399 return; 2399 return;
2400 if (dart.notNull(listenerHasValue) && !dart.notNull(core.identical(s ourceValue, listenerValueOrError)) && dart.notNull(dart.is(listenerValueOrError, Future))) { 2400 if (dart.notNull(listenerHasValue) && !dart.notNull(core.identical(s ourceValue, listenerValueOrError)) && dart.is(listenerValueOrError, Future)) {
2401 let chainSource = dart.as(listenerValueOrError, Future); 2401 let chainSource = dart.as(listenerValueOrError, Future);
2402 let result = listener.result; 2402 let result = listener.result;
2403 if (dart.is(chainSource, _Future)) { 2403 if (dart.is(chainSource, _Future)) {
2404 if (chainSource[_isComplete]) { 2404 if (chainSource[_isComplete]) {
2405 result[_isChained] = true; 2405 result[_isChained] = true;
2406 source = chainSource; 2406 source = chainSource;
2407 listeners = new _FutureListener.chain(result); 2407 listeners = new _FutureListener.chain(result);
2408 continue; 2408 continue;
2409 } else { 2409 } else {
2410 _Future[_chainCoreFuture](chainSource, result); 2410 _Future[_chainCoreFuture](chainSource, result);
(...skipping 1586 matching lines...) Expand 10 before | Expand all | Expand 10 after
3997 } 3997 }
3998 } 3998 }
3999 return _TakeWhileStream; 3999 return _TakeWhileStream;
4000 }); 4000 });
4001 let _TakeWhileStream = _TakeWhileStream$(); 4001 let _TakeWhileStream = _TakeWhileStream$();
4002 let _SkipStream$ = dart.generic(function(T) { 4002 let _SkipStream$ = dart.generic(function(T) {
4003 class _SkipStream extends _ForwardingStream$(T, T) { 4003 class _SkipStream extends _ForwardingStream$(T, T) {
4004 _SkipStream(source, count) { 4004 _SkipStream(source, count) {
4005 this[_remaining] = count; 4005 this[_remaining] = count;
4006 super._ForwardingStream(source); 4006 super._ForwardingStream(source);
4007 if (dart.notNull(!(typeof count == 'number')) || dart.notNull(count) < 0 ) 4007 if (!(typeof count == 'number') || dart.notNull(count) < 0)
4008 throw new core.ArgumentError(count); 4008 throw new core.ArgumentError(count);
4009 } 4009 }
4010 [_handleData](inputEvent, sink) { 4010 [_handleData](inputEvent, sink) {
4011 if (dart.notNull(this[_remaining]) > 0) { 4011 if (dart.notNull(this[_remaining]) > 0) {
4012 this[_remaining] = dart.notNull(this[_remaining]) - 1; 4012 this[_remaining] = dart.notNull(this[_remaining]) - 1;
4013 return; 4013 return;
4014 } 4014 }
4015 sink[_add](inputEvent); 4015 sink[_add](inputEvent);
4016 } 4016 }
4017 } 4017 }
(...skipping 1178 matching lines...) Expand 10 before | Expand all | Expand 10 after
5196 exports.ScheduleMicrotaskHandler = ScheduleMicrotaskHandler; 5196 exports.ScheduleMicrotaskHandler = ScheduleMicrotaskHandler;
5197 exports.CreateTimerHandler = CreateTimerHandler; 5197 exports.CreateTimerHandler = CreateTimerHandler;
5198 exports.CreatePeriodicTimerHandler = CreatePeriodicTimerHandler; 5198 exports.CreatePeriodicTimerHandler = CreatePeriodicTimerHandler;
5199 exports.PrintHandler = PrintHandler; 5199 exports.PrintHandler = PrintHandler;
5200 exports.ForkHandler = ForkHandler; 5200 exports.ForkHandler = ForkHandler;
5201 exports.ZoneSpecification = ZoneSpecification; 5201 exports.ZoneSpecification = ZoneSpecification;
5202 exports.ZoneDelegate = ZoneDelegate; 5202 exports.ZoneDelegate = ZoneDelegate;
5203 exports.Zone = Zone; 5203 exports.Zone = Zone;
5204 exports.runZoned = runZoned; 5204 exports.runZoned = runZoned;
5205 })(async || (async = {})); 5205 })(async || (async = {}));
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698