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

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

Issue 1112403004: SDK fixes (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Formatting fix 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 Stream<T> {Stream(); 2 abstract class Stream<T> {Stream();
3 factory Stream.fromFuture(Future<T> future) { 3 factory Stream.fromFuture(Future<T> future) {
4 _StreamController<T> controller = new StreamController<T>(sync: true); 4 _StreamController<T> controller = ((__x19) => DEVC$RT.cast(__x19, DEVC$RT.type ((StreamController<T> _) {
5 }
6 ), DEVC$RT.type((_StreamController<T> _) {
7 }
8 ), "CastUser", """line 88, column 9 of dart:async/stream.dart: """, __x19 is _ StreamController<T>, false))(new StreamController<T>(sync: true));
5 future.then((value) { 9 future.then((value) {
6 controller._add(DEVC$RT.cast(value, dynamic, T, "CompositeCast", """line 89, column 25 of dart:async/stream.dart: """, value is T, false)); 10 controller._add(DEVC$RT.cast(value, dynamic, T, "CompositeCast", """line 90, column 25 of dart:async/stream.dart: """, value is T, false));
7 controller._closeUnchecked(); 11 controller._closeUnchecked();
8 } 12 }
9 , onError: (error, stackTrace) { 13 , onError: (error, stackTrace) {
10 controller._addError(error, DEVC$RT.cast(stackTrace, dynamic, StackTrace, "D ynamicCast", """line 93, column 37 of dart:async/stream.dart: """, stackTrace is StackTrace, true)); 14 controller._addError(error, DEVC$RT.cast(stackTrace, dynamic, StackTrace, "D ynamicCast", """line 94, column 37 of dart:async/stream.dart: """, stackTrace is StackTrace, true));
11 controller._closeUnchecked(); 15 controller._closeUnchecked();
12 } 16 }
13 ); 17 );
14 return controller.stream; 18 return controller.stream;
15 } 19 }
16 factory Stream.fromIterable(Iterable<T> data) { 20 factory Stream.fromIterable(Iterable<T> data) {
17 return new _GeneratedStreamImpl<T>(() => new _IterablePendingEvents<T>(data)); 21 return new _GeneratedStreamImpl<T>(() => new _IterablePendingEvents<T>(data));
18 } 22 }
19 factory Stream.periodic(Duration period, [T computation(int computationCount)]) { 23 factory Stream.periodic(Duration period, [T computation(int computationCount)]) {
20 if (computation == null) computation = ((__x23) => DEVC$RT.cast(__x23, __CastT ype21, DEVC$RT.type((__CastType19<T> _) { 24 if (computation == null) computation = ((__x24) => DEVC$RT.cast(__x24, __CastT ype22, DEVC$RT.type((__CastType20<T> _) {
21 } 25 }
22 ), "CompositeCast", """line 126, column 44 of dart:async/stream.dart: """, __x 23 is __CastType19<T>, false))(((i) => null)); 26 ), "CompositeCast", """line 127, column 44 of dart:async/stream.dart: """, __x 24 is __CastType20<T>, false))(((i) => null));
23 Timer timer; 27 Timer timer;
24 int computationCount = 0; 28 int computationCount = 0;
25 StreamController<T> controller; 29 StreamController<T> controller;
26 Stopwatch watch = new Stopwatch(); 30 Stopwatch watch = new Stopwatch();
27 void sendEvent() { 31 void sendEvent() {
28 watch.reset(); 32 watch.reset();
29 T data = computation(computationCount++); 33 T data = computation(computationCount++);
30 controller.add(data); 34 controller.add(data);
31 } 35 }
32 void startPeriodicTimer() { 36 void startPeriodicTimer() {
(...skipping 22 matching lines...) Expand all
55 ); 59 );
56 } 60 }
57 , onCancel: () { 61 , onCancel: () {
58 if (timer != null) timer.cancel(); 62 if (timer != null) timer.cancel();
59 timer = null; 63 timer = null;
60 } 64 }
61 ); 65 );
62 return controller.stream; 66 return controller.stream;
63 } 67 }
64 factory Stream.eventTransformed(Stream source, EventSink mapSink(EventSink<T> s ink)) { 68 factory Stream.eventTransformed(Stream source, EventSink mapSink(EventSink<T> s ink)) {
65 return new _BoundSinkStream<dynamic, T>(source, DEVC$RT.cast(mapSink, DEVC$RT. type((__CastType24<T> _) { 69 return new _BoundSinkStream<dynamic, T>(source, DEVC$RT.cast(mapSink, DEVC$RT. type((__CastType25<T> _) {
66 } 70 }
67 ), DEVC$RT.type((_SinkMapper<dynamic, dynamic> _) { 71 ), DEVC$RT.type((_SinkMapper<dynamic, dynamic> _) {
68 } 72 }
69 ), "CompositeCast", """line 216, column 41 of dart:async/stream.dart: """, map Sink is _SinkMapper<dynamic, dynamic>, false)); 73 ), "CompositeCast", """line 217, column 41 of dart:async/stream.dart: """, map Sink is _SinkMapper<dynamic, dynamic>, false));
70 } 74 }
71 bool get isBroadcast => false; 75 bool get isBroadcast => false;
72 Stream<T> asBroadcastStream({ 76 Stream<T> asBroadcastStream({
73 void onListen(StreamSubscription<T> subscription), void onCancel(StreamSubscri ption<T> subscription)} 77 void onListen(StreamSubscription<T> subscription), void onCancel(StreamSubscri ption<T> subscription)}
74 ) { 78 ) {
75 return new _AsBroadcastStream<T>(this, DEVC$RT.cast(onListen, DEVC$RT.type((__ CastType28<T> _) { 79 return new _AsBroadcastStream<T>(this, DEVC$RT.cast(onListen, DEVC$RT.type((__ CastType29<T> _) {
76 } 80 }
77 ), __CastType26, "CompositeCast", """line 248, column 44 of dart:async/stream. dart: """, onListen is __CastType26, false), DEVC$RT.cast(onCancel, DEVC$RT.type ((__CastType28<T> _) { 81 ), __CastType27, "CompositeCast", """line 249, column 44 of dart:async/stream. dart: """, onListen is __CastType27, false), DEVC$RT.cast(onCancel, DEVC$RT.type ((__CastType29<T> _) {
78 } 82 }
79 ), __CastType26, "CompositeCast", """line 248, column 54 of dart:async/stream. dart: """, onCancel is __CastType26, false)); 83 ), __CastType27, "CompositeCast", """line 249, column 54 of dart:async/stream. dart: """, onCancel is __CastType27, false));
80 } 84 }
81 StreamSubscription<T> listen(void onData(T event), { 85 StreamSubscription<T> listen(void onData(T event), {
82 Function onError, void onDone(), bool cancelOnError} 86 Function onError, void onDone(), bool cancelOnError}
83 ); 87 );
84 Stream<T> where(bool test(T event)) { 88 Stream<T> where(bool test(T event)) {
85 return new _WhereStream<T>(this, test); 89 return new _WhereStream<T>(this, test);
86 } 90 }
87 Stream map(convert(T event)) { 91 Stream map(convert(T event)) {
88 return new _MapStream<T, dynamic>(this, convert); 92 return new _MapStream<T, dynamic>(this, convert);
89 } 93 }
(...skipping 13 matching lines...) Expand all
103 controller.addError(e, s); 107 controller.addError(e, s);
104 return;} 108 return;}
105 if (newValue is Future) { 109 if (newValue is Future) {
106 subscription.pause(); 110 subscription.pause();
107 newValue.then(add, onError: addError).whenComplete(subscription.resume) ; 111 newValue.then(add, onError: addError).whenComplete(subscription.resume) ;
108 } 112 }
109 else { 113 else {
110 controller.add(newValue); 114 controller.add(newValue);
111 } 115 }
112 } 116 }
113 , onError: DEVC$RT.cast(addError, dynamic, Function, "DynamicCast", """line 338, column 20 of dart:async/stream.dart: """, addError is Function, true), onDo ne: controller.close); 117 , onError: DEVC$RT.cast(addError, dynamic, Function, "DynamicCast", """line 339, column 20 of dart:async/stream.dart: """, addError is Function, true), onDo ne: controller.close);
114 } 118 }
115 if (this.isBroadcast) { 119 if (this.isBroadcast) {
116 controller = new StreamController.broadcast(onListen: onListen, onCancel: () { 120 controller = new StreamController.broadcast(onListen: onListen, onCancel: () {
117 subscription.cancel(); 121 subscription.cancel();
118 } 122 }
119 , sync: true); 123 , sync: true);
120 } 124 }
121 else { 125 else {
122 controller = new StreamController(onListen: onListen, onPause: () { 126 controller = new StreamController(onListen: onListen, onPause: () {
123 subscription.pause(); 127 subscription.pause();
(...skipping 19 matching lines...) Expand all
143 newStream = convert(event); 147 newStream = convert(event);
144 } 148 }
145 catch (e, s) { 149 catch (e, s) {
146 controller.addError(e, s); 150 controller.addError(e, s);
147 return;} 151 return;}
148 if (newStream != null) { 152 if (newStream != null) {
149 subscription.pause(); 153 subscription.pause();
150 controller.addStream(newStream).whenComplete(subscription.resume); 154 controller.addStream(newStream).whenComplete(subscription.resume);
151 } 155 }
152 } 156 }
153 , onError: DEVC$RT.cast(eventSink._addError, dynamic, Function, "DynamicCast ", """line 395, column 20 of dart:async/stream.dart: """, eventSink._addError is Function, true), onDone: controller.close); 157 , onError: DEVC$RT.cast(eventSink._addError, dynamic, Function, "DynamicCast ", """line 396, column 20 of dart:async/stream.dart: """, eventSink._addError is Function, true), onDone: controller.close);
154 } 158 }
155 if (this.isBroadcast) { 159 if (this.isBroadcast) {
156 controller = new StreamController.broadcast(onListen: onListen, onCancel: () { 160 controller = new StreamController.broadcast(onListen: onListen, onCancel: () {
157 subscription.cancel(); 161 subscription.cancel();
158 } 162 }
159 , sync: true); 163 , sync: true);
160 } 164 }
161 else { 165 else {
162 controller = new StreamController(onListen: onListen, onPause: () { 166 controller = new StreamController(onListen: onListen, onPause: () {
163 subscription.pause(); 167 subscription.pause();
(...skipping 25 matching lines...) Expand all
189 Future<T> reduce(T combine(T previous, T element)) { 193 Future<T> reduce(T combine(T previous, T element)) {
190 _Future<T> result = new _Future<T>(); 194 _Future<T> result = new _Future<T>();
191 bool seenFirst = false; 195 bool seenFirst = false;
192 T value; 196 T value;
193 StreamSubscription subscription; 197 StreamSubscription subscription;
194 subscription = this.listen((T element) { 198 subscription = this.listen((T element) {
195 if (seenFirst) { 199 if (seenFirst) {
196 _runUserCode(() => combine(value, element), (T newValue) { 200 _runUserCode(() => combine(value, element), (T newValue) {
197 value = newValue; 201 value = newValue;
198 } 202 }
199 , ((__x33) => DEVC$RT.cast(__x33, dynamic, __CastType30, "CompositeCast", """line 501, column 24 of dart:async/stream.dart: """, __x33 is __CastType30, fa lse))(_cancelAndErrorClosure(subscription, result))); 203 , ((__x34) => DEVC$RT.cast(__x34, dynamic, __CastType31, "CompositeCast", """line 502, column 24 of dart:async/stream.dart: """, __x34 is __CastType31, fa lse))(_cancelAndErrorClosure(subscription, result)));
200 } 204 }
201 else { 205 else {
202 value = element; 206 value = element;
203 seenFirst = true; 207 seenFirst = true;
204 } 208 }
205 } 209 }
206 , onError: result._completeError, onDone: () { 210 , onError: result._completeError, onDone: () {
207 if (!seenFirst) { 211 if (!seenFirst) {
208 try { 212 try {
209 throw IterableElementError.noElement(); 213 throw IterableElementError.noElement();
(...skipping 10 matching lines...) Expand all
220 return result; 224 return result;
221 } 225 }
222 Future fold(var initialValue, combine(var previous, T element)) { 226 Future fold(var initialValue, combine(var previous, T element)) {
223 _Future result = new _Future(); 227 _Future result = new _Future();
224 var value = initialValue; 228 var value = initialValue;
225 StreamSubscription subscription; 229 StreamSubscription subscription;
226 subscription = this.listen((T element) { 230 subscription = this.listen((T element) {
227 _runUserCode(() => combine(value, element), (newValue) { 231 _runUserCode(() => combine(value, element), (newValue) {
228 value = newValue; 232 value = newValue;
229 } 233 }
230 , ((__x34) => DEVC$RT.cast(__x34, dynamic, __CastType30, "CompositeCast", "" "line 534, column 11 of dart:async/stream.dart: """, __x34 is __CastType30, fals e))(_cancelAndErrorClosure(subscription, result))); 234 , ((__x35) => DEVC$RT.cast(__x35, dynamic, __CastType31, "CompositeCast", "" "line 535, column 11 of dart:async/stream.dart: """, __x35 is __CastType31, fals e))(_cancelAndErrorClosure(subscription, result)));
231 } 235 }
232 , onError: (e, st) { 236 , onError: (e, st) {
233 result._completeError(e, DEVC$RT.cast(st, dynamic, StackTrace, "DynamicCast" , """line 538, column 34 of dart:async/stream.dart: """, st is StackTrace, true) ); 237 result._completeError(e, DEVC$RT.cast(st, dynamic, StackTrace, "DynamicCast" , """line 539, column 34 of dart:async/stream.dart: """, st is StackTrace, true) );
234 } 238 }
235 , onDone: () { 239 , onDone: () {
236 result._complete(value); 240 result._complete(value);
237 } 241 }
238 , cancelOnError: true); 242 , cancelOnError: true);
239 return result; 243 return result;
240 } 244 }
241 Future<String> join([String separator = ""]) { 245 Future<String> join([String separator = ""]) {
242 _Future<String> result = new _Future<String>(); 246 _Future<String> result = new _Future<String>();
243 StringBuffer buffer = new StringBuffer(); 247 StringBuffer buffer = new StringBuffer();
(...skipping 22 matching lines...) Expand all
266 } 270 }
267 Future<bool> contains(Object needle) { 271 Future<bool> contains(Object needle) {
268 _Future<bool> future = new _Future<bool>(); 272 _Future<bool> future = new _Future<bool>();
269 StreamSubscription subscription; 273 StreamSubscription subscription;
270 subscription = this.listen((T element) { 274 subscription = this.listen((T element) {
271 _runUserCode(() => (element == needle), (bool isMatch) { 275 _runUserCode(() => (element == needle), (bool isMatch) {
272 if (isMatch) { 276 if (isMatch) {
273 _cancelAndValue(subscription, future, true); 277 _cancelAndValue(subscription, future, true);
274 } 278 }
275 } 279 }
276 , ((__x35) => DEVC$RT.cast(__x35, dynamic, __CastType30, "CompositeCast", "" "line 602, column 13 of dart:async/stream.dart: """, __x35 is __CastType30, fals e))(_cancelAndErrorClosure(subscription, future))); 280 , ((__x36) => DEVC$RT.cast(__x36, dynamic, __CastType31, "CompositeCast", "" "line 603, column 13 of dart:async/stream.dart: """, __x36 is __CastType31, fals e))(_cancelAndErrorClosure(subscription, future)));
277 } 281 }
278 , onError: future._completeError, onDone: () { 282 , onError: future._completeError, onDone: () {
279 future._complete(false); 283 future._complete(false);
280 } 284 }
281 , cancelOnError: true); 285 , cancelOnError: true);
282 return future; 286 return future;
283 } 287 }
284 Future forEach(void action(T element)) { 288 Future forEach(void action(T element)) {
285 _Future future = new _Future(); 289 _Future future = new _Future();
286 StreamSubscription subscription; 290 StreamSubscription subscription;
287 subscription = this.listen((T element) { 291 subscription = this.listen((T element) {
288 _runUserCode(() => action(element), (_) { 292 _runUserCode(() => action(element), (_) {
289 } 293 }
290 , ((__x36) => DEVC$RT.cast(__x36, dynamic, __CastType30, "CompositeCast", "" "line 628, column 13 of dart:async/stream.dart: """, __x36 is __CastType30, fals e))(_cancelAndErrorClosure(subscription, future))); 294 , ((__x37) => DEVC$RT.cast(__x37, dynamic, __CastType31, "CompositeCast", "" "line 629, column 13 of dart:async/stream.dart: """, __x37 is __CastType31, fals e))(_cancelAndErrorClosure(subscription, future)));
291 } 295 }
292 , onError: future._completeError, onDone: () { 296 , onError: future._completeError, onDone: () {
293 future._complete(null); 297 future._complete(null);
294 } 298 }
295 , cancelOnError: true); 299 , cancelOnError: true);
296 return future; 300 return future;
297 } 301 }
298 Future<bool> every(bool test(T element)) { 302 Future<bool> every(bool test(T element)) {
299 _Future<bool> future = new _Future<bool>(); 303 _Future<bool> future = new _Future<bool>();
300 StreamSubscription subscription; 304 StreamSubscription subscription;
301 subscription = this.listen((T element) { 305 subscription = this.listen((T element) {
302 _runUserCode(() => test(element), (bool isMatch) { 306 _runUserCode(() => test(element), (bool isMatch) {
303 if (!isMatch) { 307 if (!isMatch) {
304 _cancelAndValue(subscription, future, false); 308 _cancelAndValue(subscription, future, false);
305 } 309 }
306 } 310 }
307 , ((__x37) => DEVC$RT.cast(__x37, dynamic, __CastType30, "CompositeCast", "" "line 657, column 13 of dart:async/stream.dart: """, __x37 is __CastType30, fals e))(_cancelAndErrorClosure(subscription, future))); 311 , ((__x38) => DEVC$RT.cast(__x38, dynamic, __CastType31, "CompositeCast", "" "line 658, column 13 of dart:async/stream.dart: """, __x38 is __CastType31, fals e))(_cancelAndErrorClosure(subscription, future)));
308 } 312 }
309 , onError: future._completeError, onDone: () { 313 , onError: future._completeError, onDone: () {
310 future._complete(true); 314 future._complete(true);
311 } 315 }
312 , cancelOnError: true); 316 , cancelOnError: true);
313 return future; 317 return future;
314 } 318 }
315 Future<bool> any(bool test(T element)) { 319 Future<bool> any(bool test(T element)) {
316 _Future<bool> future = new _Future<bool>(); 320 _Future<bool> future = new _Future<bool>();
317 StreamSubscription subscription; 321 StreamSubscription subscription;
318 subscription = this.listen((T element) { 322 subscription = this.listen((T element) {
319 _runUserCode(() => test(element), (bool isMatch) { 323 _runUserCode(() => test(element), (bool isMatch) {
320 if (isMatch) { 324 if (isMatch) {
321 _cancelAndValue(subscription, future, true); 325 _cancelAndValue(subscription, future, true);
322 } 326 }
323 } 327 }
324 , ((__x38) => DEVC$RT.cast(__x38, dynamic, __CastType30, "CompositeCast", "" "line 694, column 13 of dart:async/stream.dart: """, __x38 is __CastType30, fals e))(_cancelAndErrorClosure(subscription, future))); 328 , ((__x39) => DEVC$RT.cast(__x39, dynamic, __CastType31, "CompositeCast", "" "line 695, column 13 of dart:async/stream.dart: """, __x39 is __CastType31, fals e))(_cancelAndErrorClosure(subscription, future)));
325 } 329 }
326 , onError: future._completeError, onDone: () { 330 , onError: future._completeError, onDone: () {
327 future._complete(false); 331 future._complete(false);
328 } 332 }
329 , cancelOnError: true); 333 , cancelOnError: true);
330 return future; 334 return future;
331 } 335 }
332 Future<int> get length { 336 Future<int> get length {
333 _Future<int> future = new _Future<int>(); 337 _Future<int> future = new _Future<int>();
334 int count = 0; 338 int count = 0;
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 Object defaultValue()} 472 Object defaultValue()}
469 ) { 473 ) {
470 _Future<dynamic> future = new _Future(); 474 _Future<dynamic> future = new _Future();
471 StreamSubscription subscription; 475 StreamSubscription subscription;
472 subscription = this.listen((T value) { 476 subscription = this.listen((T value) {
473 _runUserCode(() => test(value), (bool isMatch) { 477 _runUserCode(() => test(value), (bool isMatch) {
474 if (isMatch) { 478 if (isMatch) {
475 _cancelAndValue(subscription, future, value); 479 _cancelAndValue(subscription, future, value);
476 } 480 }
477 } 481 }
478 , ((__x39) => DEVC$RT.cast(__x39, dynamic, __CastType30, "CompositeCast", "" "line 1036, column 11 of dart:async/stream.dart: """, __x39 is __CastType30, fal se))(_cancelAndErrorClosure(subscription, future))); 482 , ((__x40) => DEVC$RT.cast(__x40, dynamic, __CastType31, "CompositeCast", "" "line 1037, column 11 of dart:async/stream.dart: """, __x40 is __CastType31, fal se))(_cancelAndErrorClosure(subscription, future)));
479 } 483 }
480 , onError: future._completeError, onDone: () { 484 , onError: future._completeError, onDone: () {
481 if (defaultValue != null) { 485 if (defaultValue != null) {
482 _runUserCode(defaultValue, future._complete, future._completeError); 486 _runUserCode(defaultValue, future._complete, future._completeError);
483 return;} 487 return;}
484 try { 488 try {
485 throw IterableElementError.noElement(); 489 throw IterableElementError.noElement();
486 } 490 }
487 catch (e, s) { 491 catch (e, s) {
488 _completeWithErrorCallback(future, e, s); 492 _completeWithErrorCallback(future, e, s);
489 } 493 }
490 } 494 }
491 , cancelOnError: true); 495 , cancelOnError: true);
492 return future; 496 return future;
493 } 497 }
494 Future<dynamic> lastWhere(bool test(T element), { 498 Future<dynamic> lastWhere(bool test(T element), {
495 Object defaultValue()} 499 Object defaultValue()}
496 ) { 500 ) {
497 _Future<dynamic> future = new _Future(); 501 _Future<dynamic> future = new _Future();
498 T result = null; 502 T result = null;
499 bool foundResult = false; 503 bool foundResult = false;
500 StreamSubscription subscription; 504 StreamSubscription subscription;
501 subscription = this.listen((T value) { 505 subscription = this.listen((T value) {
502 _runUserCode(() => true == test(value), (bool isMatch) { 506 _runUserCode(() => true == test(value), (bool isMatch) {
503 if (isMatch) { 507 if (isMatch) {
504 foundResult = true; 508 foundResult = true;
505 result = value; 509 result = value;
506 } 510 }
507 } 511 }
508 , ((__x40) => DEVC$RT.cast(__x40, dynamic, __CastType30, "CompositeCast", "" "line 1077, column 11 of dart:async/stream.dart: """, __x40 is __CastType30, fal se))(_cancelAndErrorClosure(subscription, future))); 512 , ((__x41) => DEVC$RT.cast(__x41, dynamic, __CastType31, "CompositeCast", "" "line 1078, column 11 of dart:async/stream.dart: """, __x41 is __CastType31, fal se))(_cancelAndErrorClosure(subscription, future)));
509 } 513 }
510 , onError: future._completeError, onDone: () { 514 , onError: future._completeError, onDone: () {
511 if (foundResult) { 515 if (foundResult) {
512 future._complete(result); 516 future._complete(result);
513 return;} 517 return;}
514 if (defaultValue != null) { 518 if (defaultValue != null) {
515 _runUserCode(defaultValue, future._complete, future._completeError); 519 _runUserCode(defaultValue, future._complete, future._completeError);
516 return;} 520 return;}
517 try { 521 try {
518 throw IterableElementError.noElement(); 522 throw IterableElementError.noElement();
(...skipping 18 matching lines...) Expand all
537 throw IterableElementError.tooMany(); 541 throw IterableElementError.tooMany();
538 } 542 }
539 catch (e, s) { 543 catch (e, s) {
540 _cancelAndErrorWithReplacement(subscription, future, e, s); 544 _cancelAndErrorWithReplacement(subscription, future, e, s);
541 } 545 }
542 return;} 546 return;}
543 foundResult = true; 547 foundResult = true;
544 result = value; 548 result = value;
545 } 549 }
546 } 550 }
547 , ((__x41) => DEVC$RT.cast(__x41, dynamic, __CastType30, "CompositeCast", "" "line 1129, column 11 of dart:async/stream.dart: """, __x41 is __CastType30, fal se))(_cancelAndErrorClosure(subscription, future))); 551 , ((__x42) => DEVC$RT.cast(__x42, dynamic, __CastType31, "CompositeCast", "" "line 1130, column 11 of dart:async/stream.dart: """, __x42 is __CastType31, fal se))(_cancelAndErrorClosure(subscription, future)));
548 } 552 }
549 , onError: future._completeError, onDone: () { 553 , onError: future._completeError, onDone: () {
550 if (foundResult) { 554 if (foundResult) {
551 future._complete(result); 555 future._complete(result);
552 return;} 556 return;}
553 try { 557 try {
554 throw IterableElementError.noElement(); 558 throw IterableElementError.noElement();
555 } 559 }
556 catch (e, s) { 560 catch (e, s) {
557 _completeWithErrorCallback(future, e, s); 561 _completeWithErrorCallback(future, e, s);
(...skipping 23 matching lines...) Expand all
581 void onTimeout(EventSink sink)} 585 void onTimeout(EventSink sink)}
582 ) { 586 ) {
583 StreamController controller; 587 StreamController controller;
584 StreamSubscription<T> subscription; 588 StreamSubscription<T> subscription;
585 Timer timer; 589 Timer timer;
586 Zone zone; 590 Zone zone;
587 Function timeout; 591 Function timeout;
588 void onData(T event) { 592 void onData(T event) {
589 timer.cancel(); 593 timer.cancel();
590 controller.add(event); 594 controller.add(event);
591 timer = zone.createTimer(timeLimit, DEVC$RT.cast(timeout, Function, __CastT ype42, "CompositeCast", """line 1219, column 43 of dart:async/stream.dart: """, timeout is __CastType42, false)); 595 timer = zone.createTimer(timeLimit, DEVC$RT.cast(timeout, Function, __CastT ype43, "CompositeCast", """line 1220, column 43 of dart:async/stream.dart: """, timeout is __CastType43, false));
592 } 596 }
593 void onError(error, StackTrace stackTrace) { 597 void onError(error, StackTrace stackTrace) {
594 timer.cancel(); 598 timer.cancel();
595 assert (controller is _StreamController || controller is _BroadcastStreamCo ntroller); var eventSink = controller; 599 assert (controller is _StreamController || controller is _BroadcastStreamCo ntroller); var eventSink = controller;
596 eventSink._addError(error, stackTrace); 600 eventSink._addError(error, stackTrace);
597 timer = zone.createTimer(timeLimit, DEVC$RT.cast(timeout, Function, __CastT ype42, "CompositeCast", """line 1227, column 43 of dart:async/stream.dart: """, timeout is __CastType42, false)); 601 timer = zone.createTimer(timeLimit, DEVC$RT.cast(timeout, Function, __CastT ype43, "CompositeCast", """line 1228, column 43 of dart:async/stream.dart: """, timeout is __CastType43, false));
598 } 602 }
599 void onDone() { 603 void onDone() {
600 timer.cancel(); 604 timer.cancel();
601 controller.close(); 605 controller.close();
602 } 606 }
603 void onListen() { 607 void onListen() {
604 zone = Zone.current; 608 zone = Zone.current;
605 if (onTimeout == null) { 609 if (onTimeout == null) {
606 timeout = () { 610 timeout = () {
607 controller.addError(new TimeoutException("No stream event", timeLimit), null); 611 controller.addError(new TimeoutException("No stream event", timeLimit), null);
608 } 612 }
609 ; 613 ;
610 } 614 }
611 else { 615 else {
612 onTimeout = ((__x45) => DEVC$RT.cast(__x45, ZoneUnaryCallback, __CastType4 3, "CompositeCast", """line 1245, column 21 of dart:async/stream.dart: """, __x4 5 is __CastType43, false))(zone.registerUnaryCallback(onTimeout)); 616 onTimeout = ((__x46) => DEVC$RT.cast(__x46, ZoneUnaryCallback, __CastType4 4, "CompositeCast", """line 1246, column 21 of dart:async/stream.dart: """, __x4 6 is __CastType44, false))(zone.registerUnaryCallback(onTimeout));
613 _ControllerEventSinkWrapper wrapper = new _ControllerEventSinkWrapper(nul l); 617 _ControllerEventSinkWrapper wrapper = new _ControllerEventSinkWrapper(nul l);
614 timeout = () { 618 timeout = () {
615 wrapper._sink = controller; 619 wrapper._sink = controller;
616 zone.runUnaryGuarded(onTimeout, wrapper); 620 zone.runUnaryGuarded(onTimeout, wrapper);
617 wrapper._sink = null; 621 wrapper._sink = null;
618 } 622 }
619 ; 623 ;
620 } 624 }
621 subscription = this.listen(onData, onError: onError, onDone: onDone); 625 subscription = this.listen(onData, onError: onError, onDone: onDone);
622 timer = zone.createTimer(timeLimit, DEVC$RT.cast(timeout, Function, __CastT ype42, "CompositeCast", """line 1256, column 43 of dart:async/stream.dart: """, timeout is __CastType42, false)); 626 timer = zone.createTimer(timeLimit, DEVC$RT.cast(timeout, Function, __CastT ype43, "CompositeCast", """line 1257, column 43 of dart:async/stream.dart: """, timeout is __CastType43, false));
623 } 627 }
624 Future onCancel() { 628 Future onCancel() {
625 timer.cancel(); 629 timer.cancel();
626 Future result = subscription.cancel(); 630 Future result = subscription.cancel();
627 subscription = null; 631 subscription = null;
628 return result; 632 return result;
629 } 633 }
630 controller = isBroadcast ? new _SyncBroadcastStreamController(onListen, onCan cel) : new _SyncStreamController(onListen, () { 634 controller = isBroadcast ? new _SyncBroadcastStreamController(onListen, onCan cel) : new _SyncStreamController(onListen, () {
631 timer.cancel(); 635 timer.cancel();
632 subscription.pause(); 636 subscription.pause();
633 } 637 }
634 , () { 638 , () {
635 subscription.resume(); 639 subscription.resume();
636 timer = zone.createTimer(timeLimit, DEVC$RT.cast(timeout, Function, __CastT ype42, "CompositeCast", """line 1275, column 53 of dart:async/stream.dart: """, timeout is __CastType42, false)); 640 timer = zone.createTimer(timeLimit, DEVC$RT.cast(timeout, Function, __CastT ype43, "CompositeCast", """line 1276, column 53 of dart:async/stream.dart: """, timeout is __CastType43, false));
637 } 641 }
638 , onCancel); 642 , onCancel);
639 return controller.stream; 643 return controller.stream;
640 } 644 }
641 } 645 }
642 abstract class StreamSubscription<T> {Future cancel(); 646 abstract class StreamSubscription<T> {Future cancel();
643 void onData(void handleData(T data)); 647 void onData(void handleData(T data));
644 void onError(Function handleError); 648 void onError(Function handleError);
645 void onDone(void handleDone()); 649 void onDone(void handleDone());
646 void pause([Future resumeSignal]); 650 void pause([Future resumeSignal]);
647 void resume(); 651 void resume();
648 bool get isPaused; 652 bool get isPaused;
649 Future asFuture([var futureValue]); 653 Future asFuture([var futureValue]);
650 } 654 }
651 abstract class EventSink<T> implements Sink<T> {void add(T event); 655 abstract class EventSink<T> implements Sink<T> {void add(T event);
652 void addError(errorEvent, [StackTrace stackTrace]); 656 void addError(errorEvent, [StackTrace stackTrace]);
653 void close(); 657 void close();
654 } 658 }
655 class StreamView<T> extends Stream<T> {Stream<T> _stream; 659 class StreamView<T> extends Stream<T> {Stream<T> _stream;
656 StreamView(this._stream); 660 StreamView(this._stream);
657 bool get isBroadcast => _stream.isBroadcast; 661 bool get isBroadcast => _stream.isBroadcast;
658 Stream<T> asBroadcastStream({ 662 Stream<T> asBroadcastStream({
659 void onListen(StreamSubscription subscription), void onCancel(StreamSubscription subscription)} 663 void onListen(StreamSubscription<T> subscription), void onCancel(StreamSubscript ion<T> subscription)}
660 ) => _stream.asBroadcastStream(onListen: onListen, onCancel: onCancel); 664 ) => _stream.asBroadcastStream(onListen: onListen, onCancel: onCancel);
661 StreamSubscription<T> listen(void onData(T value), { 665 StreamSubscription<T> listen(void onData(T value), {
662 Function onError, void onDone(), bool cancelOnError} 666 Function onError, void onDone(), bool cancelOnError}
663 ) { 667 ) {
664 return _stream.listen(onData, onError: onError, onDone: onDone, cancelOnError: c ancelOnError); 668 return _stream.listen(onData, onError: onError, onDone: onDone, cancelOnError: c ancelOnError);
665 } 669 }
666 } 670 }
667 abstract class StreamConsumer<S> {Future addStream(Stream<S> stream); 671 abstract class StreamConsumer<S> {Future addStream(Stream<S> stream);
668 Future close(); 672 Future close();
669 } 673 }
(...skipping 16 matching lines...) Expand all
686 void add(T data) { 690 void add(T data) {
687 _sink.add(data); 691 _sink.add(data);
688 } 692 }
689 void addError(error, [StackTrace stackTrace]) { 693 void addError(error, [StackTrace stackTrace]) {
690 _sink.addError(error, stackTrace); 694 _sink.addError(error, stackTrace);
691 } 695 }
692 void close() { 696 void close() {
693 _sink.close(); 697 _sink.close();
694 } 698 }
695 } 699 }
696 typedef T __CastType19<T>(int __u20); 700 typedef T __CastType20<T>(int __u21);
697 typedef dynamic __CastType21(dynamic __u22); 701 typedef dynamic __CastType22(dynamic __u23);
698 typedef EventSink<dynamic> __CastType24<T>(EventSink<T> __u25); 702 typedef EventSink<dynamic> __CastType25<T>(EventSink<T> __u26);
699 typedef void __CastType26(StreamSubscription<dynamic> __u27); 703 typedef void __CastType27(StreamSubscription<dynamic> __u28);
700 typedef void __CastType28<T>(StreamSubscription<T> __u29); 704 typedef void __CastType29<T>(StreamSubscription<T> __u30);
701 typedef dynamic __CastType30(dynamic __u31, StackTrace __u32); 705 typedef dynamic __CastType31(dynamic __u32, StackTrace __u33);
702 typedef void __CastType42(); 706 typedef void __CastType43();
703 typedef void __CastType43(EventSink<dynamic> __u44); 707 typedef void __CastType44(EventSink<dynamic> __u45);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698