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

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

Issue 1122283002: fixes #158, precendence of call and access in new (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: redesgin 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
« no previous file with comments | « lib/runtime/dart/_js_helper.js ('k') | lib/runtime/dart/collection.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.dcall(errorHandler, error, stackTrace); 7 return dart.dcall(errorHandler, error, stackTrace);
8 } else { 8 } else {
9 return dart.dcall(errorHandler, error); 9 return dart.dcall(errorHandler, error);
10 } 10 }
(...skipping 1756 matching lines...) Expand 10 before | Expand all | Expand 10 after
1767 let s = dart.stackTrace(e); 1767 let s = dart.stackTrace(e);
1768 _completeWithErrorCallback(result, e, s); 1768 _completeWithErrorCallback(result, e, s);
1769 } 1769 }
1770 1770
1771 }); 1771 });
1772 return dart.as(result, Future$(T)); 1772 return dart.as(result, Future$(T));
1773 } 1773 }
1774 sync(computation) { 1774 sync(computation) {
1775 try { 1775 try {
1776 let result = computation(); 1776 let result = computation();
1777 return new Future$(T).value(result); 1777 return new (Future$(T)).value(result);
1778 } catch (error) { 1778 } catch (error) {
1779 let stackTrace = dart.stackTrace(error); 1779 let stackTrace = dart.stackTrace(error);
1780 return new Future$(T).error(error, stackTrace); 1780 return new (Future$(T)).error(error, stackTrace);
1781 } 1781 }
1782 1782
1783 } 1783 }
1784 value(value) { 1784 value(value) {
1785 if (value === void 0) 1785 if (value === void 0)
1786 value = null; 1786 value = null;
1787 return new _Future$(T).immediate(value); 1787 return new (_Future$(T)).immediate(value);
1788 } 1788 }
1789 error(error, stackTrace) { 1789 error(error, stackTrace) {
1790 if (stackTrace === void 0) 1790 if (stackTrace === void 0)
1791 stackTrace = null; 1791 stackTrace = null;
1792 error = _nonNullError(error); 1792 error = _nonNullError(error);
1793 if (!dart.notNull(core.identical(Zone.current, _ROOT_ZONE))) { 1793 if (!dart.notNull(core.identical(Zone.current, _ROOT_ZONE))) {
1794 let replacement = Zone.current.errorCallback(error, stackTrace); 1794 let replacement = Zone.current.errorCallback(error, stackTrace);
1795 if (replacement != null) { 1795 if (replacement != null) {
1796 error = _nonNullError(replacement.error); 1796 error = _nonNullError(replacement.error);
1797 stackTrace = replacement.stackTrace; 1797 stackTrace = replacement.stackTrace;
1798 } 1798 }
1799 } 1799 }
1800 return new _Future$(T).immediateError(error, stackTrace); 1800 return new (_Future$(T)).immediateError(error, stackTrace);
1801 } 1801 }
1802 delayed(duration, computation) { 1802 delayed(duration, computation) {
1803 if (computation === void 0) 1803 if (computation === void 0)
1804 computation = null; 1804 computation = null;
1805 let result = new (_Future$(T))(); 1805 let result = new (_Future$(T))();
1806 new Timer(duration, () => { 1806 new Timer(duration, () => {
1807 try { 1807 try {
1808 result[_complete](computation == null ? null : computation()); 1808 result[_complete](computation == null ? null : computation());
1809 } catch (e) { 1809 } catch (e) {
1810 let s = dart.stackTrace(e); 1810 let s = dart.stackTrace(e);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1863 dart.dcall(cleanUp, value); 1863 dart.dcall(cleanUp, value);
1864 }); 1864 });
1865 } 1865 }
1866 if (remaining == 0 && !dart.notNull(eagerError)) { 1866 if (remaining == 0 && !dart.notNull(eagerError)) {
1867 result[_completeError](error, stackTrace); 1867 result[_completeError](error, stackTrace);
1868 } 1868 }
1869 } 1869 }
1870 }, {onError: handleError}); 1870 }, {onError: handleError});
1871 } 1871 }
1872 if (remaining == 0) { 1872 if (remaining == 0) {
1873 return new Future$(core.List).value(dart.const([])); 1873 return new (Future$(core.List)).value(dart.const([]));
1874 } 1874 }
1875 values = new core.List(remaining); 1875 values = new core.List(remaining);
1876 return result; 1876 return result;
1877 } 1877 }
1878 static forEach(input, f) { 1878 static forEach(input, f) {
1879 dart.as(f, dart.functionType(dart.dynamic, [dart.dynamic])); 1879 dart.as(f, dart.functionType(dart.dynamic, [dart.dynamic]));
1880 let iterator = input[core.$iterator]; 1880 let iterator = input[core.$iterator];
1881 return Future.doWhile(() => { 1881 return Future.doWhile(() => {
1882 if (!dart.notNull(iterator.moveNext())) 1882 if (!dart.notNull(iterator.moveNext()))
1883 return false; 1883 return false;
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
2191 whenComplete(action) { 2191 whenComplete(action) {
2192 dart.as(action, dart.functionType(dart.dynamic, [])); 2192 dart.as(action, dart.functionType(dart.dynamic, []));
2193 let result = new (_Future$(T))(); 2193 let result = new (_Future$(T))();
2194 if (!dart.notNull(core.identical(result[_zone], _ROOT_ZONE))) { 2194 if (!dart.notNull(core.identical(result[_zone], _ROOT_ZONE))) {
2195 action = result[_zone].registerCallback(action); 2195 action = result[_zone].registerCallback(action);
2196 } 2196 }
2197 this[_addListener](new _FutureListener.whenComplete(result, action)); 2197 this[_addListener](new _FutureListener.whenComplete(result, action));
2198 return dart.as(result, Future$(T)); 2198 return dart.as(result, Future$(T));
2199 } 2199 }
2200 asStream() { 2200 asStream() {
2201 return new Stream$(T).fromFuture(this); 2201 return new (Stream$(T)).fromFuture(this);
2202 } 2202 }
2203 [_markPendingCompletion]() { 2203 [_markPendingCompletion]() {
2204 if (!dart.notNull(this[_mayComplete])) 2204 if (!dart.notNull(this[_mayComplete]))
2205 throw new core.StateError("Future already completed"); 2205 throw new core.StateError("Future already completed");
2206 this[_state] = _Future._PENDING_COMPLETE; 2206 this[_state] = _Future._PENDING_COMPLETE;
2207 } 2207 }
2208 get [_value]() { 2208 get [_value]() {
2209 dart.assert(dart.notNull(this[_isComplete]) && dart.notNull(this[_hasVal ue])); 2209 dart.assert(dart.notNull(this[_isComplete]) && dart.notNull(this[_hasVal ue]));
2210 return dart.as(this[_resultOrListeners], T); 2210 return dart.as(this[_resultOrListeners], T);
2211 } 2211 }
(...skipping 1471 matching lines...) Expand 10 before | Expand all | Expand 10 after
3683 this[_current] = null; 3683 this[_current] = null;
3684 this[_futureOrPrefetch] = null; 3684 this[_futureOrPrefetch] = null;
3685 this[_state] = _StreamIteratorImpl._STATE_FOUND; 3685 this[_state] = _StreamIteratorImpl._STATE_FOUND;
3686 this[_subscription] = stream.listen(this[_onData].bind(this), {onError: this[_onError].bind(this), onDone: this[_onDone].bind(this), cancelOnError: true }); 3686 this[_subscription] = stream.listen(this[_onData].bind(this), {onError: this[_onError].bind(this), onDone: this[_onDone].bind(this), cancelOnError: true });
3687 } 3687 }
3688 get current() { 3688 get current() {
3689 return this[_current]; 3689 return this[_current];
3690 } 3690 }
3691 moveNext() { 3691 moveNext() {
3692 if (this[_state] == _StreamIteratorImpl._STATE_DONE) { 3692 if (this[_state] == _StreamIteratorImpl._STATE_DONE) {
3693 return new _Future$(core.bool).immediate(false); 3693 return new (_Future$(core.bool)).immediate(false);
3694 } 3694 }
3695 if (this[_state] == _StreamIteratorImpl._STATE_MOVING) { 3695 if (this[_state] == _StreamIteratorImpl._STATE_MOVING) {
3696 throw new core.StateError("Already waiting for next."); 3696 throw new core.StateError("Already waiting for next.");
3697 } 3697 }
3698 if (this[_state] == _StreamIteratorImpl._STATE_FOUND) { 3698 if (this[_state] == _StreamIteratorImpl._STATE_FOUND) {
3699 this[_state] = _StreamIteratorImpl._STATE_MOVING; 3699 this[_state] = _StreamIteratorImpl._STATE_MOVING;
3700 this[_current] = null; 3700 this[_current] = null;
3701 this[_futureOrPrefetch] = new (_Future$(core.bool))(); 3701 this[_futureOrPrefetch] = new (_Future$(core.bool))();
3702 return dart.as(this[_futureOrPrefetch], Future$(core.bool)); 3702 return dart.as(this[_futureOrPrefetch], Future$(core.bool));
3703 } else { 3703 } else {
3704 dart.assert(dart.notNull(this[_state]) >= dart.notNull(_StreamIterator Impl._STATE_EXTRA_DATA)); 3704 dart.assert(dart.notNull(this[_state]) >= dart.notNull(_StreamIterator Impl._STATE_EXTRA_DATA));
3705 switch (this[_state]) { 3705 switch (this[_state]) {
3706 case _StreamIteratorImpl._STATE_EXTRA_DATA: 3706 case _StreamIteratorImpl._STATE_EXTRA_DATA:
3707 { 3707 {
3708 this[_state] = _StreamIteratorImpl._STATE_FOUND; 3708 this[_state] = _StreamIteratorImpl._STATE_FOUND;
3709 this[_current] = dart.as(this[_futureOrPrefetch], T); 3709 this[_current] = dart.as(this[_futureOrPrefetch], T);
3710 this[_futureOrPrefetch] = null; 3710 this[_futureOrPrefetch] = null;
3711 this[_subscription].resume(); 3711 this[_subscription].resume();
3712 return new _Future$(core.bool).immediate(true); 3712 return new (_Future$(core.bool)).immediate(true);
3713 } 3713 }
3714 case _StreamIteratorImpl._STATE_EXTRA_ERROR: 3714 case _StreamIteratorImpl._STATE_EXTRA_ERROR:
3715 { 3715 {
3716 let prefetch = dart.as(this[_futureOrPrefetch], AsyncError); 3716 let prefetch = dart.as(this[_futureOrPrefetch], AsyncError);
3717 this[_clear](); 3717 this[_clear]();
3718 return new _Future$(core.bool).immediateError(prefetch.error, pref etch.stackTrace); 3718 return new (_Future$(core.bool)).immediateError(prefetch.error, pr efetch.stackTrace);
3719 } 3719 }
3720 case _StreamIteratorImpl._STATE_EXTRA_DONE: 3720 case _StreamIteratorImpl._STATE_EXTRA_DONE:
3721 { 3721 {
3722 this[_clear](); 3722 this[_clear]();
3723 return new _Future$(core.bool).immediate(false); 3723 return new (_Future$(core.bool)).immediate(false);
3724 } 3724 }
3725 } 3725 }
3726 } 3726 }
3727 } 3727 }
3728 [_clear]() { 3728 [_clear]() {
3729 this[_subscription] = null; 3729 this[_subscription] = null;
3730 this[_futureOrPrefetch] = null; 3730 this[_futureOrPrefetch] = null;
3731 this[_current] = null; 3731 this[_current] = null;
3732 this[_state] = _StreamIteratorImpl._STATE_DONE; 3732 this[_state] = _StreamIteratorImpl._STATE_DONE;
3733 } 3733 }
(...skipping 1634 matching lines...) Expand 10 before | Expand all | Expand 10 after
5368 exports.ScheduleMicrotaskHandler = ScheduleMicrotaskHandler; 5368 exports.ScheduleMicrotaskHandler = ScheduleMicrotaskHandler;
5369 exports.CreateTimerHandler = CreateTimerHandler; 5369 exports.CreateTimerHandler = CreateTimerHandler;
5370 exports.CreatePeriodicTimerHandler = CreatePeriodicTimerHandler; 5370 exports.CreatePeriodicTimerHandler = CreatePeriodicTimerHandler;
5371 exports.PrintHandler = PrintHandler; 5371 exports.PrintHandler = PrintHandler;
5372 exports.ForkHandler = ForkHandler; 5372 exports.ForkHandler = ForkHandler;
5373 exports.ZoneSpecification = ZoneSpecification; 5373 exports.ZoneSpecification = ZoneSpecification;
5374 exports.ZoneDelegate = ZoneDelegate; 5374 exports.ZoneDelegate = ZoneDelegate;
5375 exports.Zone = Zone; 5375 exports.Zone = Zone;
5376 exports.runZoned = runZoned; 5376 exports.runZoned = runZoned;
5377 })(async || (async = {})); 5377 })(async || (async = {}));
OLDNEW
« no previous file with comments | « lib/runtime/dart/_js_helper.js ('k') | lib/runtime/dart/collection.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698