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

Side by Side Diff: test/dart_codegen/expect/async/stream_impl.dart

Issue 1122313002: Typing fixes to eliminate casts/dcalls (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Rebase Created 5 years, 7 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 part of dart.async; 1 part of dart.async;
2 abstract class _EventSink<T> {void _add(T data); 2 abstract class _EventSink<T> {void _add(T data);
3 void _addError(Object error, StackTrace stackTrace); 3 void _addError(Object error, StackTrace stackTrace);
4 void _close(); 4 void _close();
5 } 5 }
6 abstract class _EventDispatch<T> {void _sendData(T data); 6 abstract class _EventDispatch<T> {void _sendData(T data);
7 void _sendError(Object error, StackTrace stackTrace); 7 void _sendError(Object error, StackTrace stackTrace);
8 void _sendDone(); 8 void _sendDone();
9 } 9 }
10 class _BufferingStreamSubscription<T> implements StreamSubscription<T>, _EventS ink<T>, _EventDispatch<T> {static const int _STATE_CANCEL_ON_ERROR = 1; 10 class _BufferingStreamSubscription<T> implements StreamSubscription<T>, _EventS ink<T>, _EventDispatch<T> {static const int _STATE_CANCEL_ON_ERROR = 1;
(...skipping 23 matching lines...) Expand all
34 _state |= _STATE_HAS_PENDING; 34 _state |= _STATE_HAS_PENDING;
35 _pending.schedule(this); 35 _pending.schedule(this);
36 } 36 }
37 } 37 }
38 _PendingEvents _extractPending() { 38 _PendingEvents _extractPending() {
39 assert (_isCanceled); _PendingEvents events = _pending; 39 assert (_isCanceled); _PendingEvents events = _pending;
40 _pending = null; 40 _pending = null;
41 return events; 41 return events;
42 } 42 }
43 void onData(void handleData(T event)) { 43 void onData(void handleData(T event)) {
44 if (handleData == null) handleData = DEVC$RT.cast(_nullDataHandler, __CastType52 , DEVC$RT.type((__CastType50<T> _) { 44 if (handleData == null) handleData = DEVC$RT.cast(_nullDataHandler, __CastType47 , DEVC$RT.type((__CastType45<T> _) {
45 } 45 }
46 ), "CompositeCast", """line 153, column 42 of dart:async/stream_impl.dart: """, _nullDataHandler is __CastType50<T>, false); 46 ), "CompositeCast", """line 153, column 42 of dart:async/stream_impl.dart: """, _nullDataHandler is __CastType45<T>, false);
47 _onData = ((__x54) => DEVC$RT.cast(__x54, ZoneUnaryCallback, DEVC$RT.type((_Dat aHandler<T> _) { 47 _onData = ((__x49) => DEVC$RT.cast(__x49, ZoneUnaryCallback, DEVC$RT.type((_Dat aHandler<T> _) {
48 } 48 }
49 ), "CompositeCast", """line 154, column 15 of dart:async/stream_impl.dart: """, __x54 is _DataHandler<T>, false))(_zone.registerUnaryCallback(handleData)); 49 ), "CompositeCast", """line 154, column 15 of dart:async/stream_impl.dart: """, __x49 is _DataHandler<T>, false))(_zone.registerUnaryCallback(handleData));
50 } 50 }
51 void onError(Function handleError) { 51 void onError(Function handleError) {
52 if (handleError == null) handleError = _nullErrorHandler; 52 if (handleError == null) handleError = _nullErrorHandler;
53 _onError = _registerErrorHandler(handleError, _zone); 53 _onError = _registerErrorHandler(handleError, _zone);
54 } 54 }
55 void onDone(void handleDone()) { 55 void onDone(void handleDone()) {
56 if (handleDone == null) handleDone = _nullDoneHandler; 56 if (handleDone == null) handleDone = _nullDoneHandler;
57 _onDone = _zone.registerCallback(handleDone); 57 _onDone = _zone.registerCallback(handleDone);
58 } 58 }
59 void pause([Future resumeSignal]) { 59 void pause([Future resumeSignal]) {
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 _state |= _STATE_IN_CALLBACK; 170 _state |= _STATE_IN_CALLBACK;
171 _zone.runUnaryGuarded(_onData, data); 171 _zone.runUnaryGuarded(_onData, data);
172 _state &= ~_STATE_IN_CALLBACK; 172 _state &= ~_STATE_IN_CALLBACK;
173 _checkState(wasInputPaused); 173 _checkState(wasInputPaused);
174 } 174 }
175 void _sendError(Object error, StackTrace stackTrace) { 175 void _sendError(Object error, StackTrace stackTrace) {
176 assert (!_isCanceled); assert (!_isPaused); assert (!_inCallback); bool wasInput Paused = _isInputPaused; 176 assert (!_isCanceled); assert (!_isPaused); assert (!_inCallback); bool wasInput Paused = _isInputPaused;
177 void sendError() { 177 void sendError() {
178 if (_isCanceled && !_waitsForCancel) return; _state |= _STATE_IN_CALLBACK; 178 if (_isCanceled && !_waitsForCancel) return; _state |= _STATE_IN_CALLBACK;
179 if (_onError is ZoneBinaryCallback) { 179 if (_onError is ZoneBinaryCallback) {
180 _zone.runBinaryGuarded(DEVC$RT.cast(_onError, Function, __CastType55, "Implici tCast", """line 358, column 32 of dart:async/stream_impl.dart: """, _onError is __CastType55, true), error, stackTrace); 180 _zone.runBinaryGuarded(DEVC$RT.cast(_onError, Function, __CastType50, "Implici tCast", """line 358, column 32 of dart:async/stream_impl.dart: """, _onError is __CastType50, true), error, stackTrace);
181 } 181 }
182 else { 182 else {
183 _zone.runUnaryGuarded(DEVC$RT.cast(_onError, Function, __CastType58, "Implicit Cast", """line 360, column 31 of dart:async/stream_impl.dart: """, _onError is _ _CastType58, true), error); 183 _zone.runUnaryGuarded(DEVC$RT.cast(_onError, Function, __CastType53, "Implicit Cast", """line 360, column 31 of dart:async/stream_impl.dart: """, _onError is _ _CastType53, true), error);
184 } 184 }
185 _state &= ~_STATE_IN_CALLBACK; 185 _state &= ~_STATE_IN_CALLBACK;
186 } 186 }
187 if (_cancelOnError) { 187 if (_cancelOnError) {
188 _state |= _STATE_WAIT_FOR_CANCEL; 188 _state |= _STATE_WAIT_FOR_CANCEL;
189 _cancel(); 189 _cancel();
190 if (_cancelFuture is Future) { 190 if (_cancelFuture is Future) {
191 _cancelFuture.whenComplete(sendError); 191 _cancelFuture.whenComplete(sendError);
192 } 192 }
193 else { 193 else {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 void _onListen(StreamSubscription subscription) { 267 void _onListen(StreamSubscription subscription) {
268 } 268 }
269 } 269 }
270 typedef _PendingEvents _EventGenerator(); 270 typedef _PendingEvents _EventGenerator();
271 class _GeneratedStreamImpl<T> extends _StreamImpl<T> {final _EventGenerator _pe nding; 271 class _GeneratedStreamImpl<T> extends _StreamImpl<T> {final _EventGenerator _pe nding;
272 bool _isUsed = false; 272 bool _isUsed = false;
273 _GeneratedStreamImpl(this._pending); 273 _GeneratedStreamImpl(this._pending);
274 StreamSubscription<T> _createSubscription(void onData(T data), Function onError , void onDone(), bool cancelOnError) { 274 StreamSubscription<T> _createSubscription(void onData(T data), Function onError , void onDone(), bool cancelOnError) {
275 if (_isUsed) throw new StateError("Stream has already been listened to."); 275 if (_isUsed) throw new StateError("Stream has already been listened to.");
276 _isUsed = true; 276 _isUsed = true;
277 return ((__x60) => DEVC$RT.cast(__x60, DEVC$RT.type((_BufferingStreamSubscripti on<dynamic> _) { 277 return ((__x55) => DEVC$RT.cast(__x55, DEVC$RT.type((_BufferingStreamSubscripti on<dynamic> _) {
278 } 278 }
279 ), DEVC$RT.type((StreamSubscription<T> _) { 279 ), DEVC$RT.type((StreamSubscription<T> _) {
280 } 280 }
281 ), "CompositeCast", """line 515, column 12 of dart:async/stream_impl.dart: """, __x60 is StreamSubscription<T>, false))(new _BufferingStreamSubscription(onData, onError, onDone, cancelOnError).._setPendingEvents(_pending())); 281 ), "CompositeCast", """line 515, column 12 of dart:async/stream_impl.dart: """, __x55 is StreamSubscription<T>, false))(new _BufferingStreamSubscription(onData, onError, onDone, cancelOnError).._setPendingEvents(_pending()));
282 } 282 }
283 } 283 }
284 class _IterablePendingEvents<T> extends _PendingEvents {Iterator<T> _iterator; 284 class _IterablePendingEvents<T> extends _PendingEvents {Iterator<T> _iterator;
285 _IterablePendingEvents(Iterable<T> data) : _iterator = data.iterator; 285 _IterablePendingEvents(Iterable<T> data) : _iterator = data.iterator;
286 bool get isEmpty => _iterator == null; 286 bool get isEmpty => _iterator == null;
287 void handleNext(_EventDispatch dispatch) { 287 void handleNext(_EventDispatch dispatch) {
288 if (_iterator == null) { 288 if (_iterator == null) {
289 throw new StateError("No events pending."); 289 throw new StateError("No events pending.");
290 } 290 }
291 bool isDone; 291 bool isDone;
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 if (isPaused) return; _state |= _DONE_SENT; 457 if (isPaused) return; _state |= _DONE_SENT;
458 if (_onDone != null) _zone.runGuarded(_onDone); 458 if (_onDone != null) _zone.runGuarded(_onDone);
459 } 459 }
460 } 460 }
461 class _AsBroadcastStream<T> extends Stream<T> {final Stream<T> _source; 461 class _AsBroadcastStream<T> extends Stream<T> {final Stream<T> _source;
462 final _broadcastCallback _onListenHandler; 462 final _broadcastCallback _onListenHandler;
463 final _broadcastCallback _onCancelHandler; 463 final _broadcastCallback _onCancelHandler;
464 final Zone _zone; 464 final Zone _zone;
465 _AsBroadcastStreamController<T> _controller; 465 _AsBroadcastStreamController<T> _controller;
466 StreamSubscription<T> _subscription; 466 StreamSubscription<T> _subscription;
467 _AsBroadcastStream(this._source, void onListenHandler(StreamSubscription subscr iption), void onCancelHandler(StreamSubscription subscription)) : _onListenHandl er = ((__x61) => DEVC$RT.cast(__x61, ZoneUnaryCallback, _broadcastCallback, "Com positeCast", """line 813, column 28 of dart:async/stream_impl.dart: """, __x61 i s _broadcastCallback, false))(Zone.current.registerUnaryCallback(onListenHandler )), _onCancelHandler = ((__x62) => DEVC$RT.cast(__x62, ZoneUnaryCallback, _broad castCallback, "CompositeCast", """line 814, column 28 of dart:async/stream_impl. dart: """, __x62 is _broadcastCallback, false))(Zone.current.registerUnaryCallba ck(onCancelHandler)), _zone = Zone.current { 467 _AsBroadcastStream(this._source, void onListenHandler(StreamSubscription subscr iption), void onCancelHandler(StreamSubscription subscription)) : _onListenHandl er = ((__x56) => DEVC$RT.cast(__x56, ZoneUnaryCallback, _broadcastCallback, "Com positeCast", """line 813, column 28 of dart:async/stream_impl.dart: """, __x56 i s _broadcastCallback, false))(Zone.current.registerUnaryCallback(onListenHandler )), _onCancelHandler = ((__x57) => DEVC$RT.cast(__x57, ZoneUnaryCallback, _broad castCallback, "CompositeCast", """line 814, column 28 of dart:async/stream_impl. dart: """, __x57 is _broadcastCallback, false))(Zone.current.registerUnaryCallba ck(onCancelHandler)), _zone = Zone.current {
468 _controller = new _AsBroadcastStreamController<T>(_onListen, _onCancel); 468 _controller = new _AsBroadcastStreamController<T>(_onListen, _onCancel);
469 } 469 }
470 bool get isBroadcast => true; 470 bool get isBroadcast => true;
471 StreamSubscription<T> listen(void onData(T data), { 471 StreamSubscription<T> listen(void onData(T data), {
472 Function onError, void onDone(), bool cancelOnError} 472 Function onError, void onDone(), bool cancelOnError}
473 ) { 473 ) {
474 if (_controller == null || _controller.isClosed) { 474 if (_controller == null || _controller.isClosed) {
475 return new _DoneStreamSubscription<T>(onDone); 475 return new _DoneStreamSubscription<T>(onDone);
476 } 476 }
477 if (_subscription == null) { 477 if (_subscription == null) {
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 } 637 }
638 ), "CompositeCast", """line 1073, column 31 of dart:async/stream_impl.dart: """, _futureOrPrefetch is _Future<bool>, false); 638 ), "CompositeCast", """line 1073, column 31 of dart:async/stream_impl.dart: """, _futureOrPrefetch is _Future<bool>, false);
639 _clear(); 639 _clear();
640 hasNext._complete(false); 640 hasNext._complete(false);
641 return;} 641 return;}
642 _subscription.pause(); 642 _subscription.pause();
643 _futureOrPrefetch = null; 643 _futureOrPrefetch = null;
644 _state = _STATE_EXTRA_DONE; 644 _state = _STATE_EXTRA_DONE;
645 } 645 }
646 } 646 }
647 typedef void __CastType50<T>(T __u51); 647 typedef void __CastType45<T>(T __u46);
648 typedef void __CastType52(dynamic __u53); 648 typedef void __CastType47(dynamic __u48);
649 typedef dynamic __CastType55(dynamic __u56, dynamic __u57); 649 typedef dynamic __CastType50(dynamic __u51, dynamic __u52);
650 typedef dynamic __CastType58(dynamic __u59); 650 typedef dynamic __CastType53(dynamic __u54);
OLDNEW
« no previous file with comments | « test/dart_codegen/expect/async/stream_controller.dart ('k') | test/dart_codegen/expect/async/stream_pipe.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698