OLD | NEW |
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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 return _cancelFuture; | 93 return _cancelFuture; |
94 } | 94 } |
95 Future asFuture([var futureValue]) { | 95 Future asFuture([var futureValue]) { |
96 _Future<T> result = new _Future<T>(); | 96 _Future<T> result = new _Future<T>(); |
97 _onDone = () { | 97 _onDone = () { |
98 result._complete(futureValue); | 98 result._complete(futureValue); |
99 } | 99 } |
100 ; | 100 ; |
101 _onError = (error, stackTrace) { | 101 _onError = (error, stackTrace) { |
102 cancel(); | 102 cancel(); |
103 result._completeError(error, DEVC$RT.cast(stackTrace, dynamic, StackTrace, "Cas
tGeneral", """line 212, column 36 of dart:async/stream_impl.dart: """, stackTrac
e is StackTrace, true)); | 103 result._completeError(error, DEVC$RT.cast(stackTrace, dynamic, StackTrace, "Dyn
amicCast", """line 212, column 36 of dart:async/stream_impl.dart: """, stackTrac
e is StackTrace, true)); |
104 } | 104 } |
105 ; | 105 ; |
106 return result; | 106 return result; |
107 } | 107 } |
108 bool get _isInputPaused => (_state & _STATE_INPUT_PAUSED) != 0; | 108 bool get _isInputPaused => (_state & _STATE_INPUT_PAUSED) != 0; |
109 bool get _isClosed => (_state & _STATE_CLOSED) != 0; | 109 bool get _isClosed => (_state & _STATE_CLOSED) != 0; |
110 bool get _isCanceled => (_state & _STATE_CANCELED) != 0; | 110 bool get _isCanceled => (_state & _STATE_CANCELED) != 0; |
111 bool get _waitsForCancel => (_state & _STATE_WAIT_FOR_CANCEL) != 0; | 111 bool get _waitsForCancel => (_state & _STATE_WAIT_FOR_CANCEL) != 0; |
112 bool get _inCallback => (_state & _STATE_IN_CALLBACK) != 0; | 112 bool get _inCallback => (_state & _STATE_IN_CALLBACK) != 0; |
113 bool get _hasPending => (_state & _STATE_HAS_PENDING) != 0; | 113 bool get _hasPending => (_state & _STATE_HAS_PENDING) != 0; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 } | 156 } |
157 } | 157 } |
158 void _onPause() { | 158 void _onPause() { |
159 assert (_isInputPaused);} | 159 assert (_isInputPaused);} |
160 void _onResume() { | 160 void _onResume() { |
161 assert (!_isInputPaused);} | 161 assert (!_isInputPaused);} |
162 Future _onCancel() { | 162 Future _onCancel() { |
163 assert (_isCanceled); return null; | 163 assert (_isCanceled); return null; |
164 } | 164 } |
165 void _addPending(_DelayedEvent event) { | 165 void _addPending(_DelayedEvent event) { |
166 _StreamImplEvents pending = DEVC$RT.cast(_pending, _PendingEvents, _StreamImplEv
ents, "CastGeneral", """line 322, column 33 of dart:async/stream_impl.dart: """,
_pending is _StreamImplEvents, true); | 166 _StreamImplEvents pending = DEVC$RT.cast(_pending, _PendingEvents, _StreamImplEv
ents, "AssignmentCast", """line 322, column 33 of dart:async/stream_impl.dart: "
"", _pending is _StreamImplEvents, true); |
167 if (_pending == null) pending = _pending = new _StreamImplEvents(); | 167 if (_pending == null) pending = _pending = new _StreamImplEvents(); |
168 pending.add(event); | 168 pending.add(event); |
169 if (!_hasPending) { | 169 if (!_hasPending) { |
170 _state |= _STATE_HAS_PENDING; | 170 _state |= _STATE_HAS_PENDING; |
171 if (!_isPaused) { | 171 if (!_isPaused) { |
172 _pending.schedule(this); | 172 _pending.schedule(this); |
173 } | 173 } |
174 } | 174 } |
175 } | 175 } |
176 void _sendData(T data) { | 176 void _sendData(T data) { |
177 assert (!_isCanceled); assert (!_isPaused); assert (!_inCallback); bool wasInput
Paused = _isInputPaused; | 177 assert (!_isCanceled); assert (!_isPaused); assert (!_inCallback); bool wasInput
Paused = _isInputPaused; |
178 _state |= _STATE_IN_CALLBACK; | 178 _state |= _STATE_IN_CALLBACK; |
179 _zone.runUnaryGuarded(_onData, data); | 179 _zone.runUnaryGuarded(_onData, data); |
180 _state &= ~_STATE_IN_CALLBACK; | 180 _state &= ~_STATE_IN_CALLBACK; |
181 _checkState(wasInputPaused); | 181 _checkState(wasInputPaused); |
182 } | 182 } |
183 void _sendError(var error, StackTrace stackTrace) { | 183 void _sendError(var error, StackTrace stackTrace) { |
184 assert (!_isCanceled); assert (!_isPaused); assert (!_inCallback); bool wasInput
Paused = _isInputPaused; | 184 assert (!_isCanceled); assert (!_isPaused); assert (!_inCallback); bool wasInput
Paused = _isInputPaused; |
185 void sendError() { | 185 void sendError() { |
186 if (_isCanceled && !_waitsForCancel) return; _state |= _STATE_IN_CALLBACK; | 186 if (_isCanceled && !_waitsForCancel) return; _state |= _STATE_IN_CALLBACK; |
187 if (_onError is ZoneBinaryCallback) { | 187 if (_onError is ZoneBinaryCallback) { |
188 _zone.runBinaryGuarded(DEVC$RT.cast(_onError, Function, __t95, "CastGeneral",
"""line 358, column 32 of dart:async/stream_impl.dart: """, _onError is __t95, t
rue), error, stackTrace); | 188 _zone.runBinaryGuarded(DEVC$RT.cast(_onError, Function, __t95, "ImplicitCast",
"""line 358, column 32 of dart:async/stream_impl.dart: """, _onError is __t95,
true), error, stackTrace); |
189 } | 189 } |
190 else { | 190 else { |
191 _zone.runUnaryGuarded(DEVC$RT.cast(_onError, Function, __t92, "CastGeneral", "
""line 360, column 31 of dart:async/stream_impl.dart: """, _onError is __t92, tr
ue), error); | 191 _zone.runUnaryGuarded(DEVC$RT.cast(_onError, Function, __t92, "ImplicitCast",
"""line 360, column 31 of dart:async/stream_impl.dart: """, _onError is __t92, t
rue), error); |
192 } | 192 } |
193 _state &= ~_STATE_IN_CALLBACK; | 193 _state &= ~_STATE_IN_CALLBACK; |
194 } | 194 } |
195 if (_cancelOnError) { | 195 if (_cancelOnError) { |
196 _state |= _STATE_WAIT_FOR_CANCEL; | 196 _state |= _STATE_WAIT_FOR_CANCEL; |
197 _cancel(); | 197 _cancel(); |
198 if (_cancelFuture is Future) { | 198 if (_cancelFuture is Future) { |
199 _cancelFuture.whenComplete(sendError); | 199 _cancelFuture.whenComplete(sendError); |
200 } | 200 } |
201 else { | 201 else { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 abstract class _StreamImpl<T> extends Stream<T> {StreamSubscription<T> listen(v
oid onData(T data), { | 260 abstract class _StreamImpl<T> extends Stream<T> {StreamSubscription<T> listen(v
oid onData(T data), { |
261 Function onError, void onDone(), bool cancelOnError} | 261 Function onError, void onDone(), bool cancelOnError} |
262 ) { | 262 ) { |
263 cancelOnError = identical(true, cancelOnError); | 263 cancelOnError = identical(true, cancelOnError); |
264 StreamSubscription subscription = _createSubscription(onData, onError, onDone,
cancelOnError); | 264 StreamSubscription subscription = _createSubscription(onData, onError, onDone,
cancelOnError); |
265 _onListen(subscription); | 265 _onListen(subscription); |
266 return DEVC$RT.cast(subscription, DEVC$RT.type((StreamSubscription<dynamic> _)
{ | 266 return DEVC$RT.cast(subscription, DEVC$RT.type((StreamSubscription<dynamic> _)
{ |
267 } | 267 } |
268 ), DEVC$RT.type((StreamSubscription<T> _) { | 268 ), DEVC$RT.type((StreamSubscription<T> _) { |
269 } | 269 } |
270 ), "CastDynamic", """line 476, column 12 of dart:async/stream_impl.dart: """, su
bscription is StreamSubscription<T>, false); | 270 ), "CompositeCast", """line 476, column 12 of dart:async/stream_impl.dart: """,
subscription is StreamSubscription<T>, false); |
271 } | 271 } |
272 _BufferingStreamSubscription<T> _createSubscription(void onData(T data), Functi
on onError, void onDone(), bool cancelOnError) { | 272 _BufferingStreamSubscription<T> _createSubscription(void onData(T data), Functi
on onError, void onDone(), bool cancelOnError) { |
273 return new _BufferingStreamSubscription<T>(onData, onError, onDone, cancelOnErro
r); | 273 return new _BufferingStreamSubscription<T>(onData, onError, onDone, cancelOnErro
r); |
274 } | 274 } |
275 void _onListen(StreamSubscription subscription) { | 275 void _onListen(StreamSubscription subscription) { |
276 } | 276 } |
277 } | 277 } |
278 typedef _PendingEvents _EventGenerator(); | 278 typedef _PendingEvents _EventGenerator(); |
279 class _GeneratedStreamImpl<T> extends _StreamImpl<T> {final _EventGenerator _pe
nding; | 279 class _GeneratedStreamImpl<T> extends _StreamImpl<T> {final _EventGenerator _pe
nding; |
280 bool _isUsed = false; | 280 bool _isUsed = false; |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 } | 574 } |
575 if (_state == _STATE_MOVING) { | 575 if (_state == _STATE_MOVING) { |
576 throw new StateError("Already waiting for next."); | 576 throw new StateError("Already waiting for next."); |
577 } | 577 } |
578 if (_state == _STATE_FOUND) { | 578 if (_state == _STATE_FOUND) { |
579 _state = _STATE_MOVING; | 579 _state = _STATE_MOVING; |
580 _current = null; | 580 _current = null; |
581 _futureOrPrefetch = new _Future<bool>(); | 581 _futureOrPrefetch = new _Future<bool>(); |
582 return DEVC$RT.cast(_futureOrPrefetch, dynamic, DEVC$RT.type((Future<bool> _) { | 582 return DEVC$RT.cast(_futureOrPrefetch, dynamic, DEVC$RT.type((Future<bool> _) { |
583 } | 583 } |
584 ), "CastGeneral", """line 1000, column 14 of dart:async/stream_impl.dart: """, _
futureOrPrefetch is Future<bool>, false); | 584 ), "CompositeCast", """line 1000, column 14 of dart:async/stream_impl.dart: """,
_futureOrPrefetch is Future<bool>, false); |
585 } | 585 } |
586 else { | 586 else { |
587 assert (_state >= _STATE_EXTRA_DATA); switch (_state) {case _STATE_EXTRA_DATA: _
state = _STATE_FOUND; | 587 assert (_state >= _STATE_EXTRA_DATA); switch (_state) {case _STATE_EXTRA_DATA: _
state = _STATE_FOUND; |
588 _current = DEVC$RT.cast(_futureOrPrefetch, dynamic, T, "CastGeneral", """line 1
006, column 22 of dart:async/stream_impl.dart: """, _futureOrPrefetch is T, fals
e); | 588 _current = DEVC$RT.cast(_futureOrPrefetch, dynamic, T, "CompositeCast", """line
1006, column 22 of dart:async/stream_impl.dart: """, _futureOrPrefetch is T, fa
lse); |
589 _futureOrPrefetch = null; | 589 _futureOrPrefetch = null; |
590 _subscription.resume(); | 590 _subscription.resume(); |
591 return new _Future<bool>.immediate(true); | 591 return new _Future<bool>.immediate(true); |
592 case _STATE_EXTRA_ERROR: AsyncError prefetch = DEVC$RT.cast(_futureOrPrefetch,
dynamic, AsyncError, "CastGeneral", """line 1011, column 33 of dart:async/stream
_impl.dart: """, _futureOrPrefetch is AsyncError, true); | 592 case _STATE_EXTRA_ERROR: AsyncError prefetch = DEVC$RT.cast(_futureOrPrefetch,
dynamic, AsyncError, "DynamicCast", """line 1011, column 33 of dart:async/stream
_impl.dart: """, _futureOrPrefetch is AsyncError, true); |
593 _clear(); | 593 _clear(); |
594 return new _Future<bool>.immediateError(prefetch.error, prefetch.stackTrace); | 594 return new _Future<bool>.immediateError(prefetch.error, prefetch.stackTrace); |
595 case _STATE_EXTRA_DONE: _clear(); | 595 case _STATE_EXTRA_DONE: _clear(); |
596 return new _Future<bool>.immediate(false); | 596 return new _Future<bool>.immediate(false); |
597 } | 597 } |
598 } | 598 } |
599 } | 599 } |
600 void _clear() { | 600 void _clear() { |
601 _subscription = null; | 601 _subscription = null; |
602 _futureOrPrefetch = null; | 602 _futureOrPrefetch = null; |
603 _current = null; | 603 _current = null; |
604 _state = _STATE_DONE; | 604 _state = _STATE_DONE; |
605 } | 605 } |
606 Future cancel() { | 606 Future cancel() { |
607 StreamSubscription subscription = _subscription; | 607 StreamSubscription subscription = _subscription; |
608 if (_state == _STATE_MOVING) { | 608 if (_state == _STATE_MOVING) { |
609 _Future<bool> hasNext = DEVC$RT.cast(_futureOrPrefetch, dynamic, DEVC$RT.type((_
Future<bool> _) { | 609 _Future<bool> hasNext = DEVC$RT.cast(_futureOrPrefetch, dynamic, DEVC$RT.type((_
Future<bool> _) { |
610 } | 610 } |
611 ), "CastGeneral", """line 1033, column 31 of dart:async/stream_impl.dart: """, _
futureOrPrefetch is _Future<bool>, false); | 611 ), "CompositeCast", """line 1033, column 31 of dart:async/stream_impl.dart: """,
_futureOrPrefetch is _Future<bool>, false); |
612 _clear(); | 612 _clear(); |
613 hasNext._complete(false); | 613 hasNext._complete(false); |
614 } | 614 } |
615 else { | 615 else { |
616 _clear(); | 616 _clear(); |
617 } | 617 } |
618 return subscription.cancel(); | 618 return subscription.cancel(); |
619 } | 619 } |
620 void _onData(T data) { | 620 void _onData(T data) { |
621 if (_state == _STATE_MOVING) { | 621 if (_state == _STATE_MOVING) { |
622 _current = data; | 622 _current = data; |
623 _Future<bool> hasNext = DEVC$RT.cast(_futureOrPrefetch, dynamic, DEVC$RT.type((
_Future<bool> _) { | 623 _Future<bool> hasNext = DEVC$RT.cast(_futureOrPrefetch, dynamic, DEVC$RT.type((
_Future<bool> _) { |
624 } | 624 } |
625 ), "CastGeneral", """line 1045, column 31 of dart:async/stream_impl.dart: """, _
futureOrPrefetch is _Future<bool>, false); | 625 ), "CompositeCast", """line 1045, column 31 of dart:async/stream_impl.dart: """,
_futureOrPrefetch is _Future<bool>, false); |
626 _futureOrPrefetch = null; | 626 _futureOrPrefetch = null; |
627 _state = _STATE_FOUND; | 627 _state = _STATE_FOUND; |
628 hasNext._complete(true); | 628 hasNext._complete(true); |
629 return;} | 629 return;} |
630 _subscription.pause(); | 630 _subscription.pause(); |
631 assert (_futureOrPrefetch == null); _futureOrPrefetch = data; | 631 assert (_futureOrPrefetch == null); _futureOrPrefetch = data; |
632 _state = _STATE_EXTRA_DATA; | 632 _state = _STATE_EXTRA_DATA; |
633 } | 633 } |
634 void _onError(Object error, [StackTrace stackTrace]) { | 634 void _onError(Object error, [StackTrace stackTrace]) { |
635 if (_state == _STATE_MOVING) { | 635 if (_state == _STATE_MOVING) { |
636 _Future<bool> hasNext = DEVC$RT.cast(_futureOrPrefetch, dynamic, DEVC$RT.type((_
Future<bool> _) { | 636 _Future<bool> hasNext = DEVC$RT.cast(_futureOrPrefetch, dynamic, DEVC$RT.type((_
Future<bool> _) { |
637 } | 637 } |
638 ), "CastGeneral", """line 1059, column 31 of dart:async/stream_impl.dart: """, _
futureOrPrefetch is _Future<bool>, false); | 638 ), "CompositeCast", """line 1059, column 31 of dart:async/stream_impl.dart: """,
_futureOrPrefetch is _Future<bool>, false); |
639 _clear(); | 639 _clear(); |
640 hasNext._completeError(error, stackTrace); | 640 hasNext._completeError(error, stackTrace); |
641 return;} | 641 return;} |
642 _subscription.pause(); | 642 _subscription.pause(); |
643 assert (_futureOrPrefetch == null); _futureOrPrefetch = new AsyncError(error, s
tackTrace); | 643 assert (_futureOrPrefetch == null); _futureOrPrefetch = new AsyncError(error, s
tackTrace); |
644 _state = _STATE_EXTRA_ERROR; | 644 _state = _STATE_EXTRA_ERROR; |
645 } | 645 } |
646 void _onDone() { | 646 void _onDone() { |
647 if (_state == _STATE_MOVING) { | 647 if (_state == _STATE_MOVING) { |
648 _Future<bool> hasNext = DEVC$RT.cast(_futureOrPrefetch, dynamic, DEVC$RT.type((_
Future<bool> _) { | 648 _Future<bool> hasNext = DEVC$RT.cast(_futureOrPrefetch, dynamic, DEVC$RT.type((_
Future<bool> _) { |
649 } | 649 } |
650 ), "CastGeneral", """line 1073, column 31 of dart:async/stream_impl.dart: """, _
futureOrPrefetch is _Future<bool>, false); | 650 ), "CompositeCast", """line 1073, column 31 of dart:async/stream_impl.dart: """,
_futureOrPrefetch is _Future<bool>, false); |
651 _clear(); | 651 _clear(); |
652 hasNext._complete(false); | 652 hasNext._complete(false); |
653 return;} | 653 return;} |
654 _subscription.pause(); | 654 _subscription.pause(); |
655 _futureOrPrefetch = null; | 655 _futureOrPrefetch = null; |
656 _state = _STATE_EXTRA_DONE; | 656 _state = _STATE_EXTRA_DONE; |
657 } | 657 } |
658 } | 658 } |
659 typedef void __t87<T>(T __u88); | 659 typedef void __t87<T>(T __u88); |
660 typedef void __t89(dynamic __u90); | 660 typedef void __t89(dynamic __u90); |
661 typedef dynamic __t92(dynamic __u93); | 661 typedef dynamic __t92(dynamic __u93); |
662 typedef dynamic __t95(dynamic __u96, dynamic __u97); | 662 typedef dynamic __t95(dynamic __u96, dynamic __u97); |
663 typedef void __t99(StreamSubscription<dynamic> __u100); | 663 typedef void __t99(StreamSubscription<dynamic> __u100); |
OLD | NEW |