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

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

Issue 1052383003: Disable closure wrapping by default (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 8 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 typedef dynamic _FutureOnValue<T>(T value); 2 typedef dynamic _FutureOnValue<T>(T value);
3 typedef bool _FutureErrorTest(var error); 3 typedef bool _FutureErrorTest(var error);
4 typedef _FutureAction(); 4 typedef _FutureAction();
5 abstract class _Completer<T> implements Completer<T> {final _Future<T> future = new _Future<T>(); 5 abstract class _Completer<T> implements Completer<T> {final _Future<T> future = new _Future<T>();
6 void complete([value]); 6 void complete([value]);
7 void completeError(Object error, [StackTrace stackTrace]) { 7 void completeError(Object error, [StackTrace stackTrace]) {
8 error = _nonNullError(error); 8 error = _nonNullError(error);
9 if (!future._mayComplete) throw new StateError("Future already completed"); 9 if (!future._mayComplete) throw new StateError("Future already completed");
10 AsyncError replacement = Zone.current.errorCallback(error, stackTrace); 10 AsyncError replacement = Zone.current.errorCallback(error, stackTrace);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 _FutureListener.then(this.result, _FutureOnValue onValue, Function errorCallbac k) : callback = onValue, errorCallback = errorCallback, state = (errorCallback = = null) ? STATE_THEN : STATE_THEN_ONERROR; 51 _FutureListener.then(this.result, _FutureOnValue onValue, Function errorCallbac k) : callback = onValue, errorCallback = errorCallback, state = (errorCallback = = null) ? STATE_THEN : STATE_THEN_ONERROR;
52 _FutureListener.catchError(this.result, this.errorCallback, _FutureErrorTest te st) : callback = test, state = (test == null) ? STATE_CATCHERROR : STATE_CATCHER ROR_TEST; 52 _FutureListener.catchError(this.result, this.errorCallback, _FutureErrorTest te st) : callback = test, state = (test == null) ? STATE_CATCHERROR : STATE_CATCHER ROR_TEST;
53 _FutureListener.whenComplete(this.result, _FutureAction onComplete) : callback = onComplete, errorCallback = null, state = STATE_WHENCOMPLETE; 53 _FutureListener.whenComplete(this.result, _FutureAction onComplete) : callback = onComplete, errorCallback = null, state = STATE_WHENCOMPLETE;
54 _FutureListener.chain(this.result) : callback = null, errorCallback = null, sta te = STATE_CHAIN; 54 _FutureListener.chain(this.result) : callback = null, errorCallback = null, sta te = STATE_CHAIN;
55 Zone get _zone => result._zone; 55 Zone get _zone => result._zone;
56 bool get handlesValue => (state & MASK_VALUE != 0); 56 bool get handlesValue => (state & MASK_VALUE != 0);
57 bool get handlesError => (state & MASK_ERROR != 0); 57 bool get handlesError => (state & MASK_ERROR != 0);
58 bool get hasErrorTest => (state == STATE_CATCHERROR_TEST); 58 bool get hasErrorTest => (state == STATE_CATCHERROR_TEST);
59 bool get handlesComplete => (state == STATE_WHENCOMPLETE); 59 bool get handlesComplete => (state == STATE_WHENCOMPLETE);
60 _FutureOnValue get _onValue { 60 _FutureOnValue get _onValue {
61 assert (handlesValue); return DEVC$RT.cast(callback, Function, __t11, "ImplicitC ast", """line 112, column 12 of dart:async/future_impl.dart: """, callback is __ t11, true); 61 assert (handlesValue); return DEVC$RT.cast(callback, Function, __t10, "ImplicitC ast", """line 112, column 12 of dart:async/future_impl.dart: """, callback is __ t10, true);
62 } 62 }
63 Function get _onError => errorCallback; 63 Function get _onError => errorCallback;
64 _FutureErrorTest get _errorTest { 64 _FutureErrorTest get _errorTest {
65 assert (hasErrorTest); return DEVC$RT.cast(callback, Function, __t13, "Composite Cast", """line 117, column 12 of dart:async/future_impl.dart: """, callback is _ _t13, false); 65 assert (hasErrorTest); return DEVC$RT.cast(callback, Function, __t12, "Composite Cast", """line 117, column 12 of dart:async/future_impl.dart: """, callback is _ _t12, false);
66 } 66 }
67 _FutureAction get _whenCompleteAction { 67 _FutureAction get _whenCompleteAction {
68 assert (handlesComplete); return DEVC$RT.cast(callback, Function, __t15, "Implic itCast", """line 121, column 12 of dart:async/future_impl.dart: """, callback is __t15, true); 68 assert (handlesComplete); return DEVC$RT.cast(callback, Function, __t14, "Implic itCast", """line 121, column 12 of dart:async/future_impl.dart: """, callback is __t14, true);
69 } 69 }
70 } 70 }
71 class _Future<T> implements Future<T> {static const int _INCOMPLETE = 0; 71 class _Future<T> implements Future<T> {static const int _INCOMPLETE = 0;
72 static const int _PENDING_COMPLETE = 1; 72 static const int _PENDING_COMPLETE = 1;
73 static const int _CHAINED = 2; 73 static const int _CHAINED = 2;
74 static const int _VALUE = 4; 74 static const int _VALUE = 4;
75 static const int _ERROR = 8; 75 static const int _ERROR = 8;
76 int _state = _INCOMPLETE; 76 int _state = _INCOMPLETE;
77 final Zone _zone = Zone.current; 77 final Zone _zone = Zone.current;
78 var _resultOrListeners; 78 var _resultOrListeners;
(...skipping 15 matching lines...) Expand all
94 } 94 }
95 else { 95 else {
96 assert (_isChained); _state = _INCOMPLETE; 96 assert (_isChained); _state = _INCOMPLETE;
97 } 97 }
98 } 98 }
99 Future then(f(T value), { 99 Future then(f(T value), {
100 Function onError} 100 Function onError}
101 ) { 101 ) {
102 _Future result = new _Future(); 102 _Future result = new _Future();
103 if (!identical(result._zone, _ROOT_ZONE)) { 103 if (!identical(result._zone, _ROOT_ZONE)) {
104 f = ((__x19) => DEVC$RT.wrap((dynamic f(dynamic __u16)) { 104 f = ((__x17) => DEVC$RT.cast(__x17, __t10, DEVC$RT.type((__t15<T> _) {
105 dynamic c(dynamic x0) => f(x0);
106 return f == null ? null : c;
107 } 105 }
108 , __x19, __t11, DEVC$RT.type((__t17<T> _) { 106 ), "CompositeCast", """line 208, column 11 of dart:async/future_impl.dart: """, __x17 is __t15<T>, false))(result._zone.registerUnaryCallback(f));
109 }
110 ), "Wrap", """line 208, column 11 of dart:async/future_impl.dart: """, __x19 is __t17<T>))(result._zone.registerUnaryCallback(f));
111 if (onError != null) { 107 if (onError != null) {
112 onError = _registerErrorHandler(onError, result._zone); 108 onError = _registerErrorHandler(onError, result._zone);
113 } 109 }
114 } 110 }
115 _addListener(new _FutureListener.then(result, f, onError)); 111 _addListener(new _FutureListener.then(result, f, onError));
116 return result; 112 return result;
117 } 113 }
118 Future catchError(Function onError, { 114 Future catchError(Function onError, {
119 bool test(error)} 115 bool test(error)}
120 ) { 116 ) {
121 _Future result = new _Future(); 117 _Future result = new _Future();
122 if (!identical(result._zone, _ROOT_ZONE)) { 118 if (!identical(result._zone, _ROOT_ZONE)) {
123 onError = _registerErrorHandler(onError, result._zone); 119 onError = _registerErrorHandler(onError, result._zone);
124 if (test != null) test = ((__x22) => DEVC$RT.wrap((dynamic f(dynamic __u21)) { 120 if (test != null) test = ((__x18) => DEVC$RT.cast(__x18, __t10, __t12, "Composi teCast", """line 221, column 32 of dart:async/future_impl.dart: """, __x18 is __ t12, false))(result._zone.registerUnaryCallback(test));
125 dynamic c(dynamic x0) => ((__x20) => DEVC$RT.cast(__x20, dynamic, bool, "CastRes ult", """line 221, column 32 of dart:async/future_impl.dart: """, __x20 is bool, true))(f(x0));
126 return f == null ? null : c;
127 }
128 , __x22, __t11, __t13, "Wrap", """line 221, column 32 of dart:async/future_impl. dart: """, __x22 is __t13))(result._zone.registerUnaryCallback(test));
129 } 121 }
130 _addListener(new _FutureListener.catchError(result, onError, test)); 122 _addListener(new _FutureListener.catchError(result, onError, test));
131 return result; 123 return result;
132 } 124 }
133 Future<T> whenComplete(action()) { 125 Future<T> whenComplete(action()) {
134 _Future result = new _Future<T>(); 126 _Future result = new _Future<T>();
135 if (!identical(result._zone, _ROOT_ZONE)) { 127 if (!identical(result._zone, _ROOT_ZONE)) {
136 action = result._zone.registerCallback(action); 128 action = result._zone.registerCallback(action);
137 } 129 }
138 _addListener(new _FutureListener.whenComplete(result, action)); 130 _addListener(new _FutureListener.whenComplete(result, action));
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 listenerValueOrError = new AsyncError(e, s); 312 listenerValueOrError = new AsyncError(e, s);
321 return false; 313 return false;
322 } 314 }
323 } 315 }
324 void handleError() { 316 void handleError() {
325 AsyncError asyncError = source._error; 317 AsyncError asyncError = source._error;
326 bool matchesTest = true; 318 bool matchesTest = true;
327 if (listener.hasErrorTest) { 319 if (listener.hasErrorTest) {
328 _FutureErrorTest test = listener._errorTest; 320 _FutureErrorTest test = listener._errorTest;
329 try { 321 try {
330 matchesTest = ((__x23) => DEVC$RT.cast(__x23, dynamic, bool, "DynamicCast", """line 499, column 29 of dart:async/future_impl.dart: """, __x23 is bool, true) )(zone.runUnary(test, asyncError.error)); 322 matchesTest = ((__x19) => DEVC$RT.cast(__x19, dynamic, bool, "DynamicCast", """line 499, column 29 of dart:async/future_impl.dart: """, __x19 is bool, true) )(zone.runUnary(test, asyncError.error));
331 } 323 }
332 catch (e, s) { 324 catch (e, s) {
333 listenerValueOrError = identical(asyncError.error, e) ? asyncError : new Asy ncError(e, s); 325 listenerValueOrError = identical(asyncError.error, e) ? asyncError : new Asy ncError(e, s);
334 listenerHasValue = false; 326 listenerHasValue = false;
335 return;} 327 return;}
336 } 328 }
337 Function errorCallback = listener._onError; 329 Function errorCallback = listener._onError;
338 if (matchesTest && errorCallback != null) { 330 if (matchesTest && errorCallback != null) {
339 try { 331 try {
340 if (errorCallback is ZoneBinaryCallback) { 332 if (errorCallback is ZoneBinaryCallback) {
341 listenerValueOrError = zone.runBinary(errorCallback, asyncError.error, asy ncError.stackTrace); 333 listenerValueOrError = zone.runBinary(errorCallback, asyncError.error, asy ncError.stackTrace);
342 } 334 }
343 else { 335 else {
344 listenerValueOrError = zone.runUnary(DEVC$RT.cast(errorCallback, Function, __t11, "ImplicitCast", """line 515, column 54 of dart:async/future_impl.dart: " "", errorCallback is __t11, true), asyncError.error); 336 listenerValueOrError = zone.runUnary(DEVC$RT.cast(errorCallback, Function, __t10, "ImplicitCast", """line 515, column 54 of dart:async/future_impl.dart: " "", errorCallback is __t10, true), asyncError.error);
345 } 337 }
346 } 338 }
347 catch (e, s) { 339 catch (e, s) {
348 listenerValueOrError = identical(asyncError.error, e) ? asyncError : new Asy ncError(e, s); 340 listenerValueOrError = identical(asyncError.error, e) ? asyncError : new Asy ncError(e, s);
349 listenerHasValue = false; 341 listenerHasValue = false;
350 return;} 342 return;}
351 listenerHasValue = true; 343 listenerHasValue = true;
352 } 344 }
353 else { 345 else {
354 listenerValueOrError = asyncError; 346 listenerValueOrError = asyncError;
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 , onError: (e, s) { 459 , onError: (e, s) {
468 if (timer.isActive) { 460 if (timer.isActive) {
469 timer.cancel(); 461 timer.cancel();
470 result._completeError(e, DEVC$RT.cast(s, dynamic, StackTrace, "DynamicCast", "" "line 646, column 34 of dart:async/future_impl.dart: """, s is StackTrace, true) ); 462 result._completeError(e, DEVC$RT.cast(s, dynamic, StackTrace, "DynamicCast", "" "line 646, column 34 of dart:async/future_impl.dart: """, s is StackTrace, true) );
471 } 463 }
472 } 464 }
473 ); 465 );
474 return result; 466 return result;
475 } 467 }
476 } 468 }
477 typedef dynamic __t11(dynamic __u12); 469 typedef dynamic __t10(dynamic __u11);
478 typedef bool __t13(dynamic __u14); 470 typedef bool __t12(dynamic __u13);
479 typedef dynamic __t15(); 471 typedef dynamic __t14();
480 typedef dynamic __t17<T>(T __u18); 472 typedef dynamic __t15<T>(T __u16);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698