| OLD | NEW |
| 1 dart_library.library('dart/_runtime', null, /* Imports */[ | 1 dart_library.library('dart/_runtime', null, /* Imports */[ |
| 2 ], /* Lazy imports */[ | 2 ], /* Lazy imports */[ |
| 3 'dart/core', | 3 'dart/core', |
| 4 'dart/_interceptors', | 4 'dart/_interceptors', |
| 5 'dart/_js_helper', | 5 'dart/_js_helper', |
| 6 'dart/async', | 6 'dart/async', |
| 7 'dart/collection' | 7 'dart/collection' |
| 8 ], function(exports, core, _interceptors, _js_helper, async, collection) { | 8 ], function(exports, core, _interceptors, _js_helper, async, collection) { |
| 9 'use strict'; | 9 'use strict'; |
| 10 function mixin(base, ...mixins) { | 10 function mixin(base, ...mixins) { |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 } | 267 } |
| 268 const _AsyncStarStreamController = class _AsyncStarStreamController { | 268 const _AsyncStarStreamController = class _AsyncStarStreamController { |
| 269 constructor(generator, T, args) { | 269 constructor(generator, T, args) { |
| 270 this.isAdding = false; | 270 this.isAdding = false; |
| 271 this.isWaiting = false; | 271 this.isWaiting = false; |
| 272 this.isScheduled = false; | 272 this.isScheduled = false; |
| 273 this.isSuspendedAtYield = false; | 273 this.isSuspendedAtYield = false; |
| 274 this.canceler = null; | 274 this.canceler = null; |
| 275 this.iterator = generator(this, ...args)[Symbol.iterator](); | 275 this.iterator = generator(this, ...args)[Symbol.iterator](); |
| 276 this.controller = getGenericClass(async.StreamController)(T).new({ | 276 this.controller = getGenericClass(async.StreamController)(T).new({ |
| 277 onListen: (() => this.scheduleGenerator()).bind(this), | 277 onListen: () => this.scheduleGenerator(), |
| 278 onResume: (() => this.onResume()).bind(this), | 278 onResume: () => this.onResume(), |
| 279 onCancel: (() => this.onCancel()).bind(this) | 279 onCancel: () => this.onCancel() |
| 280 }); | 280 }); |
| 281 } | 281 } |
| 282 onResume() { | 282 onResume() { |
| 283 if (this.isSuspendedAtYield) { | 283 if (this.isSuspendedAtYield) { |
| 284 this.scheduleGenerator(); | 284 this.scheduleGenerator(); |
| 285 } | 285 } |
| 286 } | 286 } |
| 287 onCancel() { | 287 onCancel() { |
| 288 if (this.controller.isClosed) { | 288 if (this.controller.isClosed) { |
| 289 return null; | 289 return null; |
| 290 } | 290 } |
| 291 if (this.canceler == null) { | 291 if (this.canceler == null) { |
| 292 this.canceler = async.Completer.new(); | 292 this.canceler = async.Completer.new(); |
| 293 this.scheduleGenerator(); | 293 this.scheduleGenerator(); |
| 294 } | 294 } |
| 295 return this.canceler.future; | 295 return this.canceler.future; |
| 296 } | 296 } |
| 297 close() { | 297 close() { |
| 298 if (this.canceler != null && !this.canceler.isCompleted) { | 298 if (this.canceler != null && !this.canceler.isCompleted) { |
| 299 this.canceler.complete(); | 299 this.canceler.complete(); |
| 300 } | 300 } |
| 301 this.controller.close(); | 301 this.controller.close(); |
| 302 } | 302 } |
| 303 scheduleGenerator() { | 303 scheduleGenerator() { |
| 304 if (this.isScheduled || this.controller.isPaused || this.isAdding || this.
isWaiting) { | 304 if (this.isScheduled || this.controller.isPaused || this.isAdding || this.
isWaiting) { |
| 305 return; | 305 return; |
| 306 } | 306 } |
| 307 this.isScheduled = true; | 307 this.isScheduled = true; |
| 308 async.scheduleMicrotask((() => this.runBody()).bind(this)); | 308 async.scheduleMicrotask(() => this.runBody()); |
| 309 } | 309 } |
| 310 runBody(opt_awaitValue) { | 310 runBody(opt_awaitValue) { |
| 311 this.isScheduled = false; | 311 this.isScheduled = false; |
| 312 this.isSuspendedAtYield = false; | 312 this.isSuspendedAtYield = false; |
| 313 this.isWaiting = false; | 313 this.isWaiting = false; |
| 314 let iter; | 314 let iter; |
| 315 try { | 315 try { |
| 316 iter = this.iterator.next(opt_awaitValue); | 316 iter = this.iterator.next(opt_awaitValue); |
| 317 } catch (e) { | 317 } catch (e) { |
| 318 this.addError(e, stackTrace(e)); | 318 this.addError(e, stackTrace(e)); |
| 319 this.close(); | 319 this.close(); |
| 320 return; | 320 return; |
| 321 } | 321 } |
| 322 | 322 |
| 323 if (iter.done) { | 323 if (iter.done) { |
| 324 this.close(); | 324 this.close(); |
| 325 return; | 325 return; |
| 326 } | 326 } |
| 327 if (this.isSuspendedAtYield || this.isAdding) return; | 327 if (this.isSuspendedAtYield || this.isAdding) return; |
| 328 this.isWaiting = true; | 328 this.isWaiting = true; |
| 329 let future = iter.value; | 329 let future = iter.value; |
| 330 if (!instanceOf(future, getGenericClass(async.Future))) { | 330 if (!instanceOf(future, getGenericClass(async.Future))) { |
| 331 future = async.Future.value(future); | 331 future = async.Future.value(future); |
| 332 } | 332 } |
| 333 return future.then((x => this.runBody(x)).bind(this), { | 333 return future.then(x => this.runBody(x), { |
| 334 onError: ((e, s) => this.throwError(e, s)).bind(this) | 334 onError: (e, s) => this.throwError(e, s) |
| 335 }); | 335 }); |
| 336 } | 336 } |
| 337 add(event) { | 337 add(event) { |
| 338 if (!this.controller.hasListener) return true; | 338 if (!this.controller.hasListener) return true; |
| 339 this.controller.add(event); | 339 this.controller.add(event); |
| 340 this.scheduleGenerator(); | 340 this.scheduleGenerator(); |
| 341 this.isSuspendedAtYield = true; | 341 this.isSuspendedAtYield = true; |
| 342 return false; | 342 return false; |
| 343 } | 343 } |
| 344 addStream(stream) { | 344 addStream(stream) { |
| 345 if (!this.controller.hasListener) return true; | 345 if (!this.controller.hasListener) return true; |
| 346 this.isAdding = true; | 346 this.isAdding = true; |
| 347 this.controller.addStream(stream, {cancelOnError: false}).then((() => { | 347 this.controller.addStream(stream, {cancelOnError: false}).then(() => { |
| 348 this.isAdding = false; | 348 this.isAdding = false; |
| 349 this.scheduleGenerator(); | 349 this.scheduleGenerator(); |
| 350 }).bind(this), { | 350 }, { |
| 351 onError: ((e, s) => this.throwError(e, s)).bind(this) | 351 onError: (e, s) => this.throwError(e, s) |
| 352 }); | 352 }); |
| 353 } | 353 } |
| 354 throwError(error, stackTrace) { | 354 throwError(error, stackTrace) { |
| 355 try { | 355 try { |
| 356 this.iterator.throw(error); | 356 this.iterator.throw(error); |
| 357 } catch (e) { | 357 } catch (e) { |
| 358 this.addError(e, stackTrace); | 358 this.addError(e, stackTrace); |
| 359 } | 359 } |
| 360 | 360 |
| 361 } | 361 } |
| (...skipping 932 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1294 exports.copyProperties = copyProperties; | 1294 exports.copyProperties = copyProperties; |
| 1295 exports.export = export_; | 1295 exports.export = export_; |
| 1296 exports.defineLazyClass = defineLazyClass; | 1296 exports.defineLazyClass = defineLazyClass; |
| 1297 exports.defineLazyProperties = defineLazyProperties; | 1297 exports.defineLazyProperties = defineLazyProperties; |
| 1298 exports.defineLazyClassGeneric = defineLazyClassGeneric; | 1298 exports.defineLazyClassGeneric = defineLazyClassGeneric; |
| 1299 exports.as = as_; | 1299 exports.as = as_; |
| 1300 exports.is = is_; | 1300 exports.is = is_; |
| 1301 exports.global = global_; | 1301 exports.global = global_; |
| 1302 exports.JsSymbol = JsSymbol; | 1302 exports.JsSymbol = JsSymbol; |
| 1303 }); | 1303 }); |
| OLD | NEW |