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

Side by Side Diff: runtime/lib/async_patch.dart

Issue 2684033006: Move _fatal from dart:core to dart:_internal (Closed)
Patch Set: Created 3 years, 10 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 | « no previous file | runtime/lib/core_patch.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import "dart:_internal"; 5 import "dart:_internal";
6 6
7 // We need to pass the value as first argument and leave the second and third 7 // We need to pass the value as first argument and leave the second and third
8 // arguments empty (used for error handling). 8 // arguments empty (used for error handling).
9 // See vm/ast_transformer.cc for usage. 9 // See vm/ast_transformer.cc for usage.
10 Function _asyncThenWrapperHelper(continuation) { 10 Function _asyncThenWrapperHelper(continuation) {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 // execution of the generator. 90 // execution of the generator.
91 // 91 //
92 // TODO(hausner): Per spec, the generator should be suspended before 92 // TODO(hausner): Per spec, the generator should be suspended before
93 // exiting when the stream is closed. We could add a getter like this: 93 // exiting when the stream is closed. We could add a getter like this:
94 // get isCancelled => controller.hasListener; 94 // get isCancelled => controller.hasListener;
95 // The generator would translate a 'yield e' statement to 95 // The generator would translate a 'yield e' statement to
96 // controller.add(e); 96 // controller.add(e);
97 // suspend; 97 // suspend;
98 // if (controller.isCancelled) return; 98 // if (controller.isCancelled) return;
99 bool add(event) { 99 bool add(event) {
100 if (!onListenReceived) _fatal("yield before stream is listened to!"); 100 if (!onListenReceived) fatal("yield before stream is listened to!");
101 if (isSuspendedAtYield) _fatal("unexpected yield"); 101 if (isSuspendedAtYield) fatal("unexpected yield");
102 // If stream is cancelled, tell caller to exit the async generator. 102 // If stream is cancelled, tell caller to exit the async generator.
103 if (!controller.hasListener) { 103 if (!controller.hasListener) {
104 return true; 104 return true;
105 } 105 }
106 controller.add(event); 106 controller.add(event);
107 scheduleGenerator(); 107 scheduleGenerator();
108 isSuspendedAtYield = true; 108 isSuspendedAtYield = true;
109 return false; 109 return false;
110 } 110 }
111 111
112 // Adds the elements of stream into this controller's stream. 112 // Adds the elements of stream into this controller's stream.
113 // The generator will be scheduled again when all of the 113 // The generator will be scheduled again when all of the
114 // elements of the added stream have been consumed. 114 // elements of the added stream have been consumed.
115 // Returns true if the caller should terminate 115 // Returns true if the caller should terminate
116 // execution of the generator. 116 // execution of the generator.
117 bool addStream(Stream stream) { 117 bool addStream(Stream stream) {
118 if (!onListenReceived) _fatal("yield before stream is listened to!"); 118 if (!onListenReceived) fatal("yield before stream is listened to!");
119 // If stream is cancelled, tell caller to exit the async generator. 119 // If stream is cancelled, tell caller to exit the async generator.
120 if (!controller.hasListener) return true; 120 if (!controller.hasListener) return true;
121 isAdding = true; 121 isAdding = true;
122 var whenDoneAdding = 122 var whenDoneAdding =
123 controller.addStream(stream as Stream, cancelOnError: false); 123 controller.addStream(stream as Stream, cancelOnError: false);
124 whenDoneAdding.then((_) { 124 whenDoneAdding.then((_) {
125 isAdding = false; 125 isAdding = false;
126 scheduleGenerator(); 126 scheduleGenerator();
127 if (!isScheduled) isSuspendedAtYield = true; 127 if (!isScheduled) isSuspendedAtYield = true;
128 }); 128 });
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 // suspended at an await. 183 // suspended at an await.
184 if (isSuspendedAtYield) { 184 if (isSuspendedAtYield) {
185 scheduleGenerator(); 185 scheduleGenerator();
186 } 186 }
187 } 187 }
188 return cancellationCompleter.future; 188 return cancellationCompleter.future;
189 } 189 }
190 } 190 }
191 191
192 @patch void _rethrow(Object error, StackTrace stackTrace) native "Async_rethrow" ; 192 @patch void _rethrow(Object error, StackTrace stackTrace) native "Async_rethrow" ;
OLDNEW
« no previous file with comments | « no previous file | runtime/lib/core_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698