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

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

Issue 1070453002: Refactor reifier to make it less dart_codegen specific. (Closed) Base URL: git@github.com:dart-lang/dart-dev-compiler.git@master
Patch Set: Address comments, rebase 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, __t10, "ImplicitC ast", """line 112, column 12 of dart:async/future_impl.dart: """, callback is __ t10, true); 61 assert (handlesValue); return DEVC$RT.cast(callback, Function, DEVC$RT.type((_Fu tureOnValue<dynamic> _) {
62 }
63 ), "ImplicitCast", """line 112, column 12 of dart:async/future_impl.dart: """, c allback is _FutureOnValue<dynamic>, true);
62 } 64 }
63 Function get _onError => errorCallback; 65 Function get _onError => errorCallback;
64 _FutureErrorTest get _errorTest { 66 _FutureErrorTest get _errorTest {
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); 67 assert (hasErrorTest); return DEVC$RT.cast(callback, Function, _FutureErrorTest, "CompositeCast", """line 117, column 12 of dart:async/future_impl.dart: """, ca llback is _FutureErrorTest, false);
66 } 68 }
67 _FutureAction get _whenCompleteAction { 69 _FutureAction get _whenCompleteAction {
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); 70 assert (handlesComplete); return DEVC$RT.cast(callback, Function, _FutureAction, "ImplicitCast", """line 121, column 12 of dart:async/future_impl.dart: """, cal lback is _FutureAction, true);
69 } 71 }
70 } 72 }
71 class _Future<T> implements Future<T> {static const int _INCOMPLETE = 0; 73 class _Future<T> implements Future<T> {static const int _INCOMPLETE = 0;
72 static const int _PENDING_COMPLETE = 1; 74 static const int _PENDING_COMPLETE = 1;
73 static const int _CHAINED = 2; 75 static const int _CHAINED = 2;
74 static const int _VALUE = 4; 76 static const int _VALUE = 4;
75 static const int _ERROR = 8; 77 static const int _ERROR = 8;
76 int _state = _INCOMPLETE; 78 int _state = _INCOMPLETE;
77 final Zone _zone = Zone.current; 79 final Zone _zone = Zone.current;
78 var _resultOrListeners; 80 var _resultOrListeners;
(...skipping 15 matching lines...) Expand all
94 } 96 }
95 else { 97 else {
96 assert (_isChained); _state = _INCOMPLETE; 98 assert (_isChained); _state = _INCOMPLETE;
97 } 99 }
98 } 100 }
99 Future then(f(T value), { 101 Future then(f(T value), {
100 Function onError} 102 Function onError}
101 ) { 103 ) {
102 _Future result = new _Future(); 104 _Future result = new _Future();
103 if (!identical(result._zone, _ROOT_ZONE)) { 105 if (!identical(result._zone, _ROOT_ZONE)) {
104 f = ((__x17) => DEVC$RT.cast(__x17, __t10, DEVC$RT.type((__t15<T> _) { 106 f = ((__x12) => DEVC$RT.cast(__x12, ZoneUnaryCallback, DEVC$RT.type((__t10<T> _) {
105 } 107 }
106 ), "CompositeCast", """line 208, column 11 of dart:async/future_impl.dart: """, __x17 is __t15<T>, false))(result._zone.registerUnaryCallback(f)); 108 ), "CompositeCast", """line 208, column 11 of dart:async/future_impl.dart: """, __x12 is __t10<T>, false))(result._zone.registerUnaryCallback(f));
107 if (onError != null) { 109 if (onError != null) {
108 onError = _registerErrorHandler(onError, result._zone); 110 onError = _registerErrorHandler(onError, result._zone);
109 } 111 }
110 } 112 }
111 _addListener(new _FutureListener.then(result, f, onError)); 113 _addListener(new _FutureListener.then(result, f, onError));
112 return result; 114 return result;
113 } 115 }
114 Future catchError(Function onError, { 116 Future catchError(Function onError, {
115 bool test(error)} 117 bool test(error)}
116 ) { 118 ) {
117 _Future result = new _Future(); 119 _Future result = new _Future();
118 if (!identical(result._zone, _ROOT_ZONE)) { 120 if (!identical(result._zone, _ROOT_ZONE)) {
119 onError = _registerErrorHandler(onError, result._zone); 121 onError = _registerErrorHandler(onError, result._zone);
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)); 122 if (test != null) test = ((__x15) => DEVC$RT.cast(__x15, ZoneUnaryCallback, __t 13, "CompositeCast", """line 221, column 32 of dart:async/future_impl.dart: """, __x15 is __t13, false))(result._zone.registerUnaryCallback(test));
121 } 123 }
122 _addListener(new _FutureListener.catchError(result, onError, test)); 124 _addListener(new _FutureListener.catchError(result, onError, test));
123 return result; 125 return result;
124 } 126 }
125 Future<T> whenComplete(action()) { 127 Future<T> whenComplete(action()) {
126 _Future result = new _Future<T>(); 128 _Future result = new _Future<T>();
127 if (!identical(result._zone, _ROOT_ZONE)) { 129 if (!identical(result._zone, _ROOT_ZONE)) {
128 action = result._zone.registerCallback(action); 130 action = result._zone.registerCallback(action);
129 } 131 }
130 _addListener(new _FutureListener.whenComplete(result, action)); 132 _addListener(new _FutureListener.whenComplete(result, action));
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 listenerValueOrError = new AsyncError(e, s); 314 listenerValueOrError = new AsyncError(e, s);
313 return false; 315 return false;
314 } 316 }
315 } 317 }
316 void handleError() { 318 void handleError() {
317 AsyncError asyncError = source._error; 319 AsyncError asyncError = source._error;
318 bool matchesTest = true; 320 bool matchesTest = true;
319 if (listener.hasErrorTest) { 321 if (listener.hasErrorTest) {
320 _FutureErrorTest test = listener._errorTest; 322 _FutureErrorTest test = listener._errorTest;
321 try { 323 try {
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)); 324 matchesTest = ((__x16) => DEVC$RT.cast(__x16, dynamic, bool, "DynamicCast", """line 499, column 29 of dart:async/future_impl.dart: """, __x16 is bool, true) )(zone.runUnary(test, asyncError.error));
323 } 325 }
324 catch (e, s) { 326 catch (e, s) {
325 listenerValueOrError = identical(asyncError.error, e) ? asyncError : new Asy ncError(e, s); 327 listenerValueOrError = identical(asyncError.error, e) ? asyncError : new Asy ncError(e, s);
326 listenerHasValue = false; 328 listenerHasValue = false;
327 return;} 329 return;}
328 } 330 }
329 Function errorCallback = listener._onError; 331 Function errorCallback = listener._onError;
330 if (matchesTest && errorCallback != null) { 332 if (matchesTest && errorCallback != null) {
331 try { 333 try {
332 if (errorCallback is ZoneBinaryCallback) { 334 if (errorCallback is ZoneBinaryCallback) {
333 listenerValueOrError = zone.runBinary(errorCallback, asyncError.error, asy ncError.stackTrace); 335 listenerValueOrError = zone.runBinary(errorCallback, asyncError.error, asy ncError.stackTrace);
334 } 336 }
335 else { 337 else {
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); 338 listenerValueOrError = zone.runUnary(DEVC$RT.cast(errorCallback, Function, __t17, "ImplicitCast", """line 515, column 54 of dart:async/future_impl.dart: " "", errorCallback is __t17, true), asyncError.error);
337 } 339 }
338 } 340 }
339 catch (e, s) { 341 catch (e, s) {
340 listenerValueOrError = identical(asyncError.error, e) ? asyncError : new Asy ncError(e, s); 342 listenerValueOrError = identical(asyncError.error, e) ? asyncError : new Asy ncError(e, s);
341 listenerHasValue = false; 343 listenerHasValue = false;
342 return;} 344 return;}
343 listenerHasValue = true; 345 listenerHasValue = true;
344 } 346 }
345 else { 347 else {
346 listenerValueOrError = asyncError; 348 listenerValueOrError = asyncError;
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 , onError: (e, s) { 461 , onError: (e, s) {
460 if (timer.isActive) { 462 if (timer.isActive) {
461 timer.cancel(); 463 timer.cancel();
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) ); 464 result._completeError(e, DEVC$RT.cast(s, dynamic, StackTrace, "DynamicCast", "" "line 646, column 34 of dart:async/future_impl.dart: """, s is StackTrace, true) );
463 } 465 }
464 } 466 }
465 ); 467 );
466 return result; 468 return result;
467 } 469 }
468 } 470 }
469 typedef dynamic __t10(dynamic __u11); 471 typedef dynamic __t10<T>(T __u11);
470 typedef bool __t12(dynamic __u13); 472 typedef bool __t13(dynamic __u14);
471 typedef dynamic __t14(); 473 typedef dynamic __t17(dynamic __u18);
472 typedef dynamic __t15<T>(T __u16);
OLDNEW
« no previous file with comments | « test/dart_codegen/expect/_internal/iterable.dart ('k') | test/dart_codegen/expect/async/schedule_microtask.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698