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

Side by Side Diff: tests/compiler/dart2js/async_await_js_transform_test.dart

Issue 929053005: Merge request - fixes dart2js async problems. Base URL: http://dart.googlecode.com/svn/trunk/dart/
Patch Set: Created 5 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 | Annotate | Revision Log
« no previous file with comments | « sdk/lib/_internal/libraries.dart ('k') | tests/compiler/dart2js/mock_libraries.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 "package:expect/expect.dart"; 5 import "package:expect/expect.dart";
6 import "package:compiler/src/js/js.dart"; 6 import "package:compiler/src/js/js.dart";
7 import "package:compiler/src/js/rewrite_async.dart"; 7 import "package:compiler/src/js/rewrite_async.dart";
8 8
9 import "backend_dart/dart_printer_test.dart" show PrintDiagnosticListener; 9 import "backend_dart/dart_printer_test.dart" show PrintDiagnosticListener;
10 10
11 void testTransform(String source, String expected) { 11 void testTransform(String source, String expected) {
12 Fun fun = js(source); 12 Fun fun = js(source);
13 Fun rewritten = new AsyncRewriter( 13 Fun rewritten = new AsyncRewriter(
14 null, // The diagnostic helper should not be used in these tests. 14 null, // The diagnostic helper should not be used in these tests.
15 null, 15 null,
16 thenHelper: new VariableUse("thenHelper"), 16 asyncHelper: new VariableUse("thenHelper"),
17 newCompleter: new VariableUse("Completer"), 17 newCompleter: new VariableUse("Completer"),
18 endOfIteration: new VariableUse("endOfIteration"), 18 endOfIteration: new VariableUse("endOfIteration"),
19 newIterable: new VariableUse("Iterator"), 19 newIterable: new VariableUse("Iterator"),
20 safeVariableName: (String name) => "__$name").rewrite(fun); 20 safeVariableName: (String name) => "__$name").rewrite(fun);
21 21
22 JavaScriptPrintingOptions options = new JavaScriptPrintingOptions(); 22 JavaScriptPrintingOptions options = new JavaScriptPrintingOptions();
23 JavaScriptPrintingContext context = new SimpleJavaScriptPrintingContext(); 23 SimpleJavaScriptPrintingContext context =
24 new SimpleJavaScriptPrintingContext();
24 Printer printer = new Printer(options, context); 25 Printer printer = new Printer(options, context);
25 printer.visit(rewritten); 26 printer.visit(rewritten);
26 Expect.stringEquals(expected, context.getText()); 27 Expect.stringEquals(expected, context.getText());
27 } 28 }
28 29
29 main() { 30 main() {
30 testTransform(""" 31 testTransform("""
31 function() async { 32 function(a) async {
32 print(this.x); // Ensure `this` is translated in the helper function. 33 print(this.x); // Ensure `this` is translated in the helper function.
33 await foo(); 34 await foo();
34 }""", """ 35 }""", """
35 function() { 36 function(a) {
36 var __goto = 0, __completer = new Completer(), __self = this; 37 var __goto = 0, __completer = new Completer(), __handler = 1, __currentError, __self = this;
37 function __helper(__result) { 38 function __body(__errorCode, __result) {
39 if (__errorCode == 1) {
40 __currentError = __result;
41 __goto = __handler;
42 }
38 while (true) 43 while (true)
39 switch (__goto) { 44 try {
40 case 0: 45 switch (__goto) {
41 // Function start 46 case 0:
42 print(__self.x); 47 // Function start
43 __goto = 1; 48 print(__self.x);
44 return thenHelper(foo(), __helper, __completer, null); 49 __goto = 2;
45 case 1: 50 return thenHelper(foo(), __body, __completer);
46 // returning from await. 51 case 2:
47 // implicit return 52 // returning from await.
48 return thenHelper(null, null, __completer, null); 53 // implicit return
54 return thenHelper(null, 0, __completer, null);
55 case 1:
56 // rethrow
57 return thenHelper(__currentError, 1, __completer);
58 }
59 } catch (__error) {
60 __currentError = __error;
61 __goto = __handler;
49 } 62 }
63
50 } 64 }
51 return thenHelper(null, __helper, __completer, null); 65 return thenHelper(null, __body, __completer, null);
52 }"""); 66 }""");
53 67
54 testTransform(""" 68 testTransform("""
55 function() async { 69 function(b) async {
56 try { 70 try {
57 __outer: while (true) { // Overlapping label name. 71 __outer: while (true) { // Overlapping label name.
58 try { 72 try {
59 inner: while (true) { 73 inner: while (true) {
60 break __outer; // Break from untranslated loop to translated target. 74 break __outer; // Break from untranslated loop to translated target.
61 break; // break to untranslated target. 75 break; // break to untranslated target.
62 } 76 }
63 while (true) { 77 while (true) {
64 return; // Return via finallies. 78 return; // Return via finallies.
65 } 79 }
66 var __helper = await foo(); // Overlapping variable name. 80 var __helper = await foo(); // Overlapping variable name.
67 } finally { 81 } finally {
68 foo(); 82 foo();
69 continue; // Continue from finally with pending finally. 83 continue; // Continue from finally with pending finally.
70 return 2; // Return from finally with pending finally. 84 return 2; // Return from finally with pending finally.
71 } 85 }
72 } 86 }
73 } finally { 87 } finally {
74 return 3; // Return from finally with no pending finally. 88 return 3; // Return from finally with no pending finally.
75 } 89 }
76 return 4; 90 return 4;
77 }""", """ 91 }""", """
78 function() { 92 function(b) {
79 var __goto = 0, __completer = new Completer(), __handler = null, __next, __ret urnValue, __helper; 93 var __goto = 0, __completer = new Completer(), __handler = 2, __currentError, __next, __returnValue, __helper;
80 function __helper1(__result) { 94 function __body(__errorCode, __result) {
95 if (__errorCode == 1) {
96 __currentError = __result;
97 __goto = __handler;
98 }
81 while (true) 99 while (true)
82 try { 100 try {
83 __outer1: 101 __outer1:
84 switch (__goto) { 102 switch (__goto) {
85 case 0: 103 case 0:
86 // Function start 104 // Function start
87 __handler = 2; 105 __handler = 3;
88 case 6: 106 case 7:
89 // continue __outer 107 // continue __outer
90 case 7: 108 case 8:
91 // while condition 109 // while condition
92 __handler = 9; 110 __handler = 10;
93 inner: { 111 inner: {
94 while (true) { 112 while (true) {
95 __next = [5]; 113 __next = [6];
96 // goto finally 114 // goto finally
97 __goto = 10; 115 __goto = 11;
98 break __outer1; 116 break __outer1;
99 break; 117 break;
100 } 118 }
101 } 119 }
102 while (true) { 120 while (true) {
103 __next = [1, 3]; 121 __next = [1, 4];
104 // goto finally 122 // goto finally
105 __goto = 10; 123 __goto = 11;
106 break __outer1; 124 break __outer1;
107 } 125 }
108 __goto = 12; 126 __goto = 13;
109 return thenHelper(foo(), __helper1, __completer, function(__error) { 127 return thenHelper(foo(), __body, __completer);
110 __goto = 9; 128 case 13:
111 __helper1(__error);
112 });
113 case 12:
114 // returning from await. 129 // returning from await.
115 __helper = __result; 130 __helper = __result;
116 __next = [11]; 131 __next = [12];
117 // goto finally 132 // goto finally
118 __goto = 10; 133 __goto = 11;
119 break; 134 break;
120 case 9:
121 // catch
122 __handler = 2;
123 __next = [11];
124 case 10: 135 case 10:
136 // uncaught
137 __next = [3];
138 case 11:
125 // finally 139 // finally
126 __handler = 2; 140 __handler = 3;
127 foo(); 141 foo();
128 // goto while condition 142 // goto while condition
129 __goto = 7; 143 __goto = 8;
130 break; 144 break;
131 __returnValue = 2; 145 __returnValue = 2;
132 __next = [1]; 146 __next = [1];
133 // goto finally 147 // goto finally
134 __goto = 3; 148 __goto = 4;
135 break; 149 break;
136 // goto the next finally handler 150 // goto the next finally handler
137 __goto = __next.pop(); 151 __goto = __next.pop();
138 break; 152 break;
139 case 11: 153 case 12:
140 // after finally 154 // after finally
141 // goto while condition 155 // goto while condition
142 __goto = 7; 156 __goto = 8;
143 break; 157 break;
144 case 8: 158 case 9:
145 // after while 159 // after while
146 case 5: 160 case 6:
147 // break __outer 161 // break __outer
148 __next = [4]; 162 __next = [5];
149 // goto finally 163 // goto finally
150 __goto = 3; 164 __goto = 4;
151 break; 165 break;
152 case 2:
153 // catch
154 __handler = null;
155 __next = [4];
156 case 3: 166 case 3:
167 // uncaught
168 __next = [2];
169 case 4:
157 // finally 170 // finally
158 __handler = null; 171 __handler = 2;
159 __returnValue = 3; 172 __returnValue = 3;
160 // goto return 173 // goto return
161 __goto = 1; 174 __goto = 1;
162 break; 175 break;
163 // goto the next finally handler 176 // goto the next finally handler
164 __goto = __next.pop(); 177 __goto = __next.pop();
165 break; 178 break;
166 case 4: 179 case 5:
167 // after finally 180 // after finally
168 __returnValue = 4; 181 __returnValue = 4;
169 // goto return 182 // goto return
170 __goto = 1; 183 __goto = 1;
171 break; 184 break;
172 case 1: 185 case 1:
173 // return 186 // return
174 return thenHelper(__returnValue, null, __completer, null); 187 return thenHelper(__returnValue, 0, __completer, null);
188 case 2:
189 // rethrow
190 return thenHelper(__currentError, 1, __completer);
175 } 191 }
176 } catch (__error) { 192 } catch (__error) {
177 if (__handler === null) 193 __currentError = __error;
178 throw __error;
179 __result = __error;
180 __goto = __handler; 194 __goto = __handler;
181 } 195 }
182 196
183 } 197 }
184 return thenHelper(null, __helper1, __completer, null); 198 return thenHelper(null, __body, __completer, null);
185 }"""); 199 }""");
200
186 testTransform(""" 201 testTransform("""
187 function() async { 202 function(c) async {
188 var a, b, c, d, e, f; 203 var a, b, c, d, e, f;
189 a = b++; // post- and preincrements. 204 a = b++; // post- and preincrements.
190 b = --b; 205 b = --b;
191 c = (await foo()).a++; 206 c = (await foo()).a++;
192 d = ++(await foo()).a; 207 d = ++(await foo()).a;
193 e = foo1()[await foo2()]--; 208 e = foo1()[await foo2()]--;
194 f = --foo1()[await foo2()]; 209 f = --foo1()[await foo2()];
195 }""", """ 210 }""", """
196 function() { 211 function(c) {
197 var __goto = 0, __completer = new Completer(), a, b, c, d, e, f, __temp1; 212 var __goto = 0, __completer = new Completer(), __handler = 1, __currentError, a, b, c, d, e, f, __temp1;
198 function __helper(__result) { 213 function __body(__errorCode, __result) {
214 if (__errorCode == 1) {
215 __currentError = __result;
216 __goto = __handler;
217 }
199 while (true) 218 while (true)
200 switch (__goto) { 219 try {
201 case 0: 220 switch (__goto) {
202 // Function start 221 case 0:
203 a = b++; 222 // Function start
204 b = --b; 223 a = b++;
205 __goto = 1; 224 b = --b;
206 return thenHelper(foo(), __helper, __completer, null); 225 __goto = 2;
207 case 1: 226 return thenHelper(foo(), __body, __completer);
208 // returning from await. 227 case 2:
209 c = __result.a++; 228 // returning from await.
210 __goto = 2; 229 c = __result.a++;
211 return thenHelper(foo(), __helper, __completer, null); 230 __goto = 3;
212 case 2: 231 return thenHelper(foo(), __body, __completer);
213 // returning from await. 232 case 3:
214 d = ++__result.a; 233 // returning from await.
215 __temp1 = foo1(); 234 d = ++__result.a;
216 __goto = 3; 235 __temp1 = foo1();
217 return thenHelper(foo2(), __helper, __completer, null); 236 __goto = 4;
218 case 3: 237 return thenHelper(foo2(), __body, __completer);
219 // returning from await. 238 case 4:
220 e = __temp1[__result]--; 239 // returning from await.
221 __temp1 = foo1(); 240 e = __temp1[__result]--;
222 __goto = 4; 241 __temp1 = foo1();
223 return thenHelper(foo2(), __helper, __completer, null); 242 __goto = 5;
224 case 4: 243 return thenHelper(foo2(), __body, __completer);
225 // returning from await. 244 case 5:
226 f = --__temp1[__result]; 245 // returning from await.
227 // implicit return 246 f = --__temp1[__result];
228 return thenHelper(null, null, __completer, null); 247 // implicit return
248 return thenHelper(null, 0, __completer, null);
249 case 1:
250 // rethrow
251 return thenHelper(__currentError, 1, __completer);
252 }
253 } catch (__error) {
254 __currentError = __error;
255 __goto = __handler;
229 } 256 }
257
230 } 258 }
231 return thenHelper(null, __helper, __completer, null); 259 return thenHelper(null, __body, __completer, null);
232 }"""); 260 }""");
261
233 testTransform(""" 262 testTransform("""
234 function() async { 263 function(d2) async {
235 var a, b, c, d, e, f, g, h; // empty initializer 264 var a, b, c, d, e, f, g, h; // empty initializer
236 a = foo1() || await foo2(); // short circuiting operators 265 a = foo1() || await foo2(); // short circuiting operators
237 b = await foo1() || foo2(); 266 b = await foo1() || foo2();
238 c = await foo1() || foo3(await foo2()); 267 c = await foo1() || foo3(await foo2());
239 d = foo1() || foo2(); 268 d = foo1() || foo2();
240 e = foo1() && await foo2(); 269 e = foo1() && await foo2();
241 f = await foo1() && foo2(); 270 f = await foo1() && foo2();
242 g = await foo1() && await foo2(); 271 g = await foo1() && await foo2();
243 h = foo1() && foo2(); 272 h = foo1() && foo2();
244 }""", """ 273 }""", """
245 function() { 274 function(d2) {
246 var __goto = 0, __completer = new Completer(), a, b, c, d, e, f, g, h, __temp1 ; 275 var __goto = 0, __completer = new Completer(), __handler = 1, __currentError, a, b, c, d, e, f, g, h, __temp1;
247 function __helper(__result) { 276 function __body(__errorCode, __result) {
277 if (__errorCode == 1) {
278 __currentError = __result;
279 __goto = __handler;
280 }
248 while (true) 281 while (true)
249 switch (__goto) { 282 try {
250 case 0: 283 switch (__goto) {
251 // Function start 284 case 0:
252 __temp1 = foo1(); 285 // Function start
253 if (__temp1) { 286 __temp1 = foo1();
254 // goto then 287 if (__temp1) {
255 __goto = 1; 288 // goto then
289 __goto = 2;
290 break;
291 } else
292 __result = __temp1;
293 // goto join
294 __goto = 3;
256 break; 295 break;
257 } else 296 case 2:
258 __result = __temp1; 297 // then
259 // goto join 298 __goto = 4;
260 __goto = 2; 299 return thenHelper(foo2(), __body, __completer);
261 break; 300 case 4:
262 case 1: 301 // returning from await.
263 // then 302 case 3:
264 __goto = 3; 303 // join
265 return thenHelper(foo2(), __helper, __completer, null); 304 a = __result;
266 case 3:
267 // returning from await.
268 case 2:
269 // join
270 a = __result;
271 __goto = 4;
272 return thenHelper(foo1(), __helper, __completer, null);
273 case 4:
274 // returning from await.
275 b = __result || foo2();
276 __goto = 7;
277 return thenHelper(foo1(), __helper, __completer, null);
278 case 7:
279 // returning from await.
280 __temp1 = __result;
281 if (__temp1) {
282 // goto then
283 __goto = 5; 305 __goto = 5;
306 return thenHelper(foo1(), __body, __completer);
307 case 5:
308 // returning from await.
309 b = __result || foo2();
310 __goto = 8;
311 return thenHelper(foo1(), __body, __completer);
312 case 8:
313 // returning from await.
314 __temp1 = __result;
315 if (__temp1) {
316 // goto then
317 __goto = 6;
318 break;
319 } else
320 __result = __temp1;
321 // goto join
322 __goto = 7;
284 break; 323 break;
285 } else 324 case 6:
286 __result = __temp1; 325 // then
287 // goto join 326 __temp1 = foo3;
288 __goto = 6;
289 break;
290 case 5:
291 // then
292 __temp1 = foo3;
293 __goto = 8;
294 return thenHelper(foo2(), __helper, __completer, null);
295 case 8:
296 // returning from await.
297 __result = __temp1(__result);
298 case 6:
299 // join
300 c = __result;
301 d = foo1() || foo2();
302 __temp1 = foo1();
303 if (__temp1)
304 __result = __temp1;
305 else {
306 // goto then
307 __goto = 9; 327 __goto = 9;
328 return thenHelper(foo2(), __body, __completer);
329 case 9:
330 // returning from await.
331 __result = __temp1(__result);
332 case 7:
333 // join
334 c = __result;
335 d = foo1() || foo2();
336 __temp1 = foo1();
337 if (__temp1)
338 __result = __temp1;
339 else {
340 // goto then
341 __goto = 10;
342 break;
343 }
344 // goto join
345 __goto = 11;
308 break; 346 break;
309 } 347 case 10:
310 // goto join 348 // then
311 __goto = 10; 349 __goto = 12;
312 break; 350 return thenHelper(foo2(), __body, __completer);
313 case 9: 351 case 12:
314 // then 352 // returning from await.
315 __goto = 11; 353 case 11:
316 return thenHelper(foo2(), __helper, __completer, null); 354 // join
317 case 11: 355 e = __result;
318 // returning from await.
319 case 10:
320 // join
321 e = __result;
322 __goto = 12;
323 return thenHelper(foo1(), __helper, __completer, null);
324 case 12:
325 // returning from await.
326 f = __result && foo2();
327 __goto = 15;
328 return thenHelper(foo1(), __helper, __completer, null);
329 case 15:
330 // returning from await.
331 __temp1 = __result;
332 if (__temp1)
333 __result = __temp1;
334 else {
335 // goto then
336 __goto = 13; 356 __goto = 13;
357 return thenHelper(foo1(), __body, __completer);
358 case 13:
359 // returning from await.
360 f = __result && foo2();
361 __goto = 16;
362 return thenHelper(foo1(), __body, __completer);
363 case 16:
364 // returning from await.
365 __temp1 = __result;
366 if (__temp1)
367 __result = __temp1;
368 else {
369 // goto then
370 __goto = 14;
371 break;
372 }
373 // goto join
374 __goto = 15;
337 break; 375 break;
338 } 376 case 14:
339 // goto join 377 // then
340 __goto = 14; 378 __goto = 17;
341 break; 379 return thenHelper(foo2(), __body, __completer);
342 case 13: 380 case 17:
343 // then 381 // returning from await.
344 __goto = 16; 382 case 15:
345 return thenHelper(foo2(), __helper, __completer, null); 383 // join
346 case 16: 384 g = __result;
347 // returning from await. 385 h = foo1() && foo2();
348 case 14: 386 // implicit return
349 // join 387 return thenHelper(null, 0, __completer, null);
350 g = __result; 388 case 1:
351 h = foo1() && foo2(); 389 // rethrow
352 // implicit return 390 return thenHelper(__currentError, 1, __completer);
353 return thenHelper(null, null, __completer, null); 391 }
392 } catch (__error) {
393 __currentError = __error;
394 __goto = __handler;
354 } 395 }
396
355 } 397 }
356 return thenHelper(null, __helper, __completer, null); 398 return thenHelper(null, __body, __completer, null);
357 }"""); 399 }""");
400
358 testTransform(""" 401 testTransform("""
359 function(x, y) async { 402 function(x, y) async {
360 while (true) { 403 while (true) {
361 switch(y) { // Switch with no awaits in case key expressions 404 switch(y) { // Switch with no awaits in case key expressions
362 case 0: 405 case 0:
363 case 1: 406 case 1:
364 await foo(); 407 await foo();
365 continue; // Continue the loop, not the switch 408 continue; // Continue the loop, not the switch
366 case 1: // Duplicate case 409 case 1: // Duplicate case
367 await foo(); 410 await foo();
368 break; // Break the switch 411 break; // Break the switch
369 case 2: 412 case 2:
370 foo(); // No default 413 foo(); // No default
371 } 414 }
372 } 415 }
373 }""", """ 416 }""", """
374 function(x, y) { 417 function(x, y) {
375 var __goto = 0, __completer = new Completer(); 418 var __goto = 0, __completer = new Completer(), __handler = 1, __currentError;
376 function __helper(__result) { 419 function __body(__errorCode, __result) {
420 if (__errorCode == 1) {
421 __currentError = __result;
422 __goto = __handler;
423 }
377 while (true) 424 while (true)
378 switch (__goto) { 425 try {
379 case 0: 426 switch (__goto) {
380 // Function start 427 case 0:
381 case 1: 428 // Function start
382 // while condition 429 case 2:
383 case 3: 430 // while condition
384 // switch 431 case 4:
385 switch (y) { 432 // switch
386 case 0: 433 switch (y) {
387 // goto case 434 case 0:
388 __goto = 5; 435 // goto case
389 break; 436 __goto = 6;
390 case 1: 437 break;
391 // goto case 438 case 1:
392 __goto = 6; 439 // goto case
393 break; 440 __goto = 7;
394 case 1: 441 break;
395 // goto case 442 case 1:
396 __goto = 7; 443 // goto case
397 break; 444 __goto = 8;
398 case 2: 445 break;
399 // goto case 446 case 2:
400 __goto = 8; 447 // goto case
401 break; 448 __goto = 9;
402 } 449 break;
403 // goto after switch 450 }
404 __goto = 4; 451 // goto after switch
405 break; 452 __goto = 5;
406 case 5: 453 break;
407 // case 454 case 6:
408 case 6: 455 // case
409 // case 456 case 7:
410 __goto = 9; 457 // case
411 return thenHelper(foo(), __helper, __completer, null); 458 __goto = 10;
412 case 9: 459 return thenHelper(foo(), __body, __completer);
413 // returning from await. 460 case 10:
414 // goto while condition 461 // returning from await.
415 __goto = 1; 462 // goto while condition
416 break; 463 __goto = 2;
417 case 7: 464 break;
418 // case 465 case 8:
419 __goto = 10; 466 // case
420 return thenHelper(foo(), __helper, __completer, null); 467 __goto = 11;
421 case 10: 468 return thenHelper(foo(), __body, __completer);
422 // returning from await. 469 case 11:
423 // goto after switch 470 // returning from await.
424 __goto = 4; 471 // goto after switch
425 break; 472 __goto = 5;
426 case 8: 473 break;
427 // case 474 case 9:
428 foo(); 475 // case
429 case 4: 476 foo();
430 // after switch 477 case 5:
431 // goto while condition 478 // after switch
432 __goto = 1; 479 // goto while condition
433 break; 480 __goto = 2;
434 case 2: 481 break;
435 // after while 482 case 3:
436 // implicit return 483 // after while
437 return thenHelper(null, null, __completer, null); 484 // implicit return
485 return thenHelper(null, 0, __completer, null);
486 case 1:
487 // rethrow
488 return thenHelper(__currentError, 1, __completer);
489 }
490 } catch (__error) {
491 __currentError = __error;
492 __goto = __handler;
438 } 493 }
494
439 } 495 }
440 return thenHelper(null, __helper, __completer, null); 496 return thenHelper(null, __body, __completer, null);
441 }"""); 497 }""");
498
442 testTransform(""" 499 testTransform("""
443 function() async { 500 function(f) async {
444 do { 501 do {
445 var a = await foo(); 502 var a = await foo();
446 if (a) // If with no awaits in body 503 if (a) // If with no awaits in body
447 break; 504 break;
448 else 505 else
449 continue; 506 continue;
450 } while (await foo()); 507 } while (await foo());
451 } 508 }
452 """, """ 509 """, """
453 function() { 510 function(f) {
454 var __goto = 0, __completer = new Completer(), a; 511 var __goto = 0, __completer = new Completer(), __handler = 1, __currentError, a;
455 function __helper(__result) { 512 function __body(__errorCode, __result) {
513 if (__errorCode == 1) {
514 __currentError = __result;
515 __goto = __handler;
516 }
456 while (true) 517 while (true)
457 switch (__goto) { 518 try {
458 case 0: 519 switch (__goto) {
459 // Function start 520 case 0:
460 case 1: 521 // Function start
461 // do body 522 case 2:
462 __goto = 4; 523 // do body
463 return thenHelper(foo(), __helper, __completer, null); 524 __goto = 5;
464 case 4: 525 return thenHelper(foo(), __body, __completer);
465 // returning from await. 526 case 5:
466 a = __result; 527 // returning from await.
467 if (a) { 528 a = __result;
468 // goto after do 529 if (a) {
469 __goto = 3; 530 // goto after do
470 break; 531 __goto = 4;
471 } else { 532 break;
472 // goto do condition 533 } else {
473 __goto = 2; 534 // goto do condition
474 break; 535 __goto = 3;
475 } 536 break;
476 case 2: 537 }
477 // do condition 538 case 3:
478 __goto = 5; 539 // do condition
479 return thenHelper(foo(), __helper, __completer, null); 540 __goto = 6;
480 case 5: 541 return thenHelper(foo(), __body, __completer);
481 // returning from await. 542 case 6:
482 if (__result) { 543 // returning from await.
483 // goto do body 544 if (__result) {
484 __goto = 1; 545 // goto do body
485 break; 546 __goto = 2;
486 } 547 break;
487 case 3: 548 }
488 // after do 549 case 4:
489 // implicit return 550 // after do
490 return thenHelper(null, null, __completer, null); 551 // implicit return
552 return thenHelper(null, 0, __completer, null);
553 case 1:
554 // rethrow
555 return thenHelper(__currentError, 1, __completer);
556 }
557 } catch (__error) {
558 __currentError = __error;
559 __goto = __handler;
491 } 560 }
561
492 } 562 }
493 return thenHelper(null, __helper, __completer, null); 563 return thenHelper(null, __body, __completer, null);
494 }"""); 564 }""");
495 565
496 testTransform(""" 566 testTransform("""
497 function() async { 567 function(g) async {
498 for (var i = 0; i < await foo1(); i += await foo2()) { 568 for (var i = 0; i < await foo1(); i += await foo2()) {
499 if (foo(i)) 569 if (foo(i))
500 continue; 570 continue;
501 else 571 else
502 break; 572 break;
503 if (!foo(i)) { // If with no else and await in body. 573 if (!foo(i)) { // If with no else and await in body.
504 await foo(); 574 await foo();
505 return; 575 return;
506 } 576 }
507 print(await(foo(i))); 577 print(await(foo(i)));
508 } 578 }
509 } 579 }
510 """, """ 580 """, """
511 function() { 581 function(g) {
512 var __goto = 0, __completer = new Completer(), __returnValue, i, __temp1; 582 var __goto = 0, __completer = new Completer(), __handler = 2, __currentError, __returnValue, i, __temp1;
513 function __helper(__result) { 583 function __body(__errorCode, __result) {
584 if (__errorCode == 1) {
585 __currentError = __result;
586 __goto = __handler;
587 }
514 while (true) 588 while (true)
515 switch (__goto) { 589 try {
516 case 0: 590 switch (__goto) {
517 // Function start 591 case 0:
518 i = 0; 592 // Function start
519 case 2: 593 i = 0;
520 // for condition 594 case 3:
521 __temp1 = i; 595 // for condition
522 __goto = 5; 596 __temp1 = i;
523 return thenHelper(foo1(), __helper, __completer, null); 597 __goto = 6;
524 case 5: 598 return thenHelper(foo1(), __body, __completer);
525 // returning from await. 599 case 6:
526 if (!(__temp1 < __result)) { 600 // returning from await.
527 // goto after for 601 if (!(__temp1 < __result)) {
528 __goto = 4; 602 // goto after for
603 __goto = 5;
604 break;
605 }
606 if (foo(i)) {
607 // goto for update
608 __goto = 4;
609 break;
610 } else {
611 // goto after for
612 __goto = 5;
613 break;
614 }
615 __goto = !foo(i) ? 7 : 8;
529 break; 616 break;
530 } 617 case 7:
531 if (foo(i)) { 618 // then
532 // goto for update 619 __goto = 9;
620 return thenHelper(foo(), __body, __completer);
621 case 9:
622 // returning from await.
623 // goto return
624 __goto = 1;
625 break;
626 case 8:
627 // join
628 __temp1 = print;
629 __goto = 10;
630 return thenHelper(foo(i), __body, __completer);
631 case 10:
632 // returning from await.
633 __temp1(__result);
634 case 4:
635 // for update
636 __goto = 11;
637 return thenHelper(foo2(), __body, __completer);
638 case 11:
639 // returning from await.
640 i = __result;
641 // goto for condition
533 __goto = 3; 642 __goto = 3;
534 break; 643 break;
535 } else { 644 case 5:
536 // goto after for 645 // after for
537 __goto = 4; 646 case 1:
538 break; 647 // return
539 } 648 return thenHelper(__returnValue, 0, __completer, null);
540 __goto = !foo(i) ? 6 : 7; 649 case 2:
541 break; 650 // rethrow
542 case 6: 651 return thenHelper(__currentError, 1, __completer);
543 // then 652 }
544 __goto = 8; 653 } catch (__error) {
545 return thenHelper(foo(), __helper, __completer, null); 654 __currentError = __error;
546 case 8: 655 __goto = __handler;
547 // returning from await.
548 // goto return
549 __goto = 1;
550 break;
551 case 7:
552 // join
553 __temp1 = print;
554 __goto = 9;
555 return thenHelper(foo(i), __helper, __completer, null);
556 case 9:
557 // returning from await.
558 __temp1(__result);
559 case 3:
560 // for update
561 __goto = 10;
562 return thenHelper(foo2(), __helper, __completer, null);
563 case 10:
564 // returning from await.
565 i = __result;
566 // goto for condition
567 __goto = 2;
568 break;
569 case 4:
570 // after for
571 case 1:
572 // return
573 return thenHelper(__returnValue, null, __completer, null);
574 } 656 }
657
575 } 658 }
576 return thenHelper(null, __helper, __completer, null); 659 return thenHelper(null, __body, __completer, null);
577 }"""); 660 }""");
578 661
579 testTransform(""" 662 testTransform("""
580 function(a) async { 663 function(a, h) async {
581 var x = {"a": foo1(), "b": await foo2(), "c": foo3()}; 664 var x = {"a": foo1(), "b": await foo2(), "c": foo3()};
582 x["a"] = 2; // Different assignments 665 x["a"] = 2; // Different assignments
583 (await foo()).a = 3; 666 (await foo()).a = 3;
584 x[await foo()] = 4; 667 x[await foo()] = 4;
585 x[(await foo1()).a = await foo2()] = 5; 668 x[(await foo1()).a = await foo2()] = 5;
586 (await foo1())[await foo2()] = await foo3(6); 669 (await foo1())[await foo2()] = await foo3(6);
587 } 670 }
588 """, """ 671 """, """
589 function(a) { 672 function(a, h) {
590 var __goto = 0, __completer = new Completer(), x, __temp1, __temp2; 673 var __goto = 0, __completer = new Completer(), __handler = 1, __currentError, x, __temp1, __temp2;
591 function __helper(__result) { 674 function __body(__errorCode, __result) {
675 if (__errorCode == 1) {
676 __currentError = __result;
677 __goto = __handler;
678 }
592 while (true) 679 while (true)
593 switch (__goto) { 680 try {
594 case 0: 681 switch (__goto) {
595 // Function start 682 case 0:
596 __temp1 = foo1(); 683 // Function start
597 __goto = 1; 684 __temp1 = foo1();
598 return thenHelper(foo2(), __helper, __completer, null); 685 __goto = 2;
599 case 1: 686 return thenHelper(foo2(), __body, __completer);
600 // returning from await. 687 case 2:
601 x = {a: __temp1, b: __result, c: foo3()}; 688 // returning from await.
602 x.a = 2; 689 x = {a: __temp1, b: __result, c: foo3()};
603 __goto = 2; 690 x.a = 2;
604 return thenHelper(foo(), __helper, __completer, null); 691 __goto = 3;
605 case 2: 692 return thenHelper(foo(), __body, __completer);
606 // returning from await. 693 case 3:
607 __result.a = 3; 694 // returning from await.
608 __temp1 = x; 695 __result.a = 3;
609 __goto = 3; 696 __temp1 = x;
610 return thenHelper(foo(), __helper, __completer, null); 697 __goto = 4;
611 case 3: 698 return thenHelper(foo(), __body, __completer);
612 // returning from await. 699 case 4:
613 __temp1[__result] = 4; 700 // returning from await.
614 __temp1 = x; 701 __temp1[__result] = 4;
615 __goto = 4; 702 __temp1 = x;
616 return thenHelper(foo1(), __helper, __completer, null); 703 __goto = 5;
617 case 4: 704 return thenHelper(foo1(), __body, __completer);
618 // returning from await. 705 case 5:
619 __temp2 = __result; 706 // returning from await.
620 __goto = 5; 707 __temp2 = __result;
621 return thenHelper(foo2(), __helper, __completer, null); 708 __goto = 6;
622 case 5: 709 return thenHelper(foo2(), __body, __completer);
623 // returning from await. 710 case 6:
624 __temp1[__temp2.a = __result] = 5; 711 // returning from await.
625 __goto = 6; 712 __temp1[__temp2.a = __result] = 5;
626 return thenHelper(foo1(), __helper, __completer, null); 713 __goto = 7;
627 case 6: 714 return thenHelper(foo1(), __body, __completer);
628 // returning from await. 715 case 7:
629 __temp1 = __result; 716 // returning from await.
630 __goto = 7; 717 __temp1 = __result;
631 return thenHelper(foo2(), __helper, __completer, null); 718 __goto = 8;
632 case 7: 719 return thenHelper(foo2(), __body, __completer);
633 // returning from await. 720 case 8:
634 __temp2 = __result; 721 // returning from await.
635 __goto = 8; 722 __temp2 = __result;
636 return thenHelper(foo3(6), __helper, __completer, null); 723 __goto = 9;
637 case 8: 724 return thenHelper(foo3(6), __body, __completer);
638 // returning from await. 725 case 9:
639 __temp1[__temp2] = __result; 726 // returning from await.
640 // implicit return 727 __temp1[__temp2] = __result;
641 return thenHelper(null, null, __completer, null); 728 // implicit return
729 return thenHelper(null, 0, __completer, null);
730 case 1:
731 // rethrow
732 return thenHelper(__currentError, 1, __completer);
733 }
734 } catch (__error) {
735 __currentError = __error;
736 __goto = __handler;
642 } 737 }
738
643 } 739 }
644 return thenHelper(null, __helper, __completer, null); 740 return thenHelper(null, __body, __completer, null);
645 }"""); 741 }""");
742
646 testTransform(""" 743 testTransform("""
647 function(c) async { 744 function(c, i) async {
648 try { 745 try {
649 var x = c ? await foo() : foo(); // conditional 746 var x = c ? await foo() : foo(); // conditional
650 var y = {}; 747 var y = {};
651 } catch (error) { 748 } catch (error) {
652 try { 749 try {
653 x = c ? await fooError(error) : fooError(error); 750 x = c ? await fooError(error) : fooError(error);
654 } catch (error) { // nested error handler with overlapping name 751 } catch (error) { // nested error handler with overlapping name
655 y.x = foo(error); 752 y.x = foo(error);
656 } finally { 753 } finally {
657 foo(x); 754 foo(x);
658 } 755 }
659 } 756 }
660 } 757 }
661 """, """ 758 """, """
662 function(c) { 759 function(c, i) {
663 var __goto = 0, __completer = new Completer(), __handler = null, x, y, __error 1, __error2; 760 var __goto = 0, __completer = new Completer(), __handler = 1, __currentError, x, y, __error1, __error2;
664 function __helper(__result) { 761 function __body(__errorCode, __result) {
762 if (__errorCode == 1) {
763 __currentError = __result;
764 __goto = __handler;
765 }
665 while (true) 766 while (true)
666 try { 767 try {
667 switch (__goto) { 768 switch (__goto) {
668 case 0: 769 case 0:
669 // Function start 770 // Function start
670 __handler = 1; 771 __handler = 3;
671 __goto = c ? 4 : 6; 772 __goto = c ? 6 : 8;
672 break; 773 break;
673 case 4: 774 case 6:
674 // then 775 // then
675 __goto = 7; 776 __goto = 9;
676 return thenHelper(foo(), __helper, __completer, function(__error) { 777 return thenHelper(foo(), __body, __completer);
677 __goto = 1; 778 case 9:
678 __helper(__error);
679 });
680 case 7:
681 // returning from await. 779 // returning from await.
682 // goto join 780 // goto join
683 __goto = 5; 781 __goto = 7;
684 break; 782 break;
685 case 6: 783 case 8:
686 // else 784 // else
687 __result = foo(); 785 __result = foo();
688 case 5: 786 case 7:
689 // join 787 // join
690 x = __result; 788 x = __result;
691 y = {}; 789 y = {};
692 __next = [3]; 790 __handler = 1;
693 __handler = null;
694 // goto after finally 791 // goto after finally
695 __goto = 3; 792 __goto = 5;
696 break; 793 break;
697 case 1: 794 case 3:
698 // catch 795 // catch
699 __handler = null; 796 __handler = 2;
700 __error1 = __result; 797 __error1 = __currentError;
701 __handler = 8; 798 __handler = 11;
702 __goto = c ? 11 : 13; 799 __goto = c ? 14 : 16;
800 break;
801 case 14:
802 // then
803 __goto = 17;
804 return thenHelper(fooError(__error1), __body, __completer);
805 case 17:
806 // returning from await.
807 // goto join
808 __goto = 15;
809 break;
810 case 16:
811 // else
812 __result = fooError(__error1);
813 case 15:
814 // join
815 x = __result;
816 __next = [13];
817 // goto finally
818 __goto = 12;
703 break; 819 break;
704 case 11: 820 case 11:
705 // then 821 // catch
706 __goto = 14; 822 __handler = 10;
707 return thenHelper(fooError(__error1), __helper, __completer, functio n(__error) { 823 __error2 = __currentError;
708 __goto = 8; 824 y.x = foo(__error2);
709 __helper(__error); 825 __next = [13];
710 }); 826 // goto finally
711 case 14:
712 // returning from await.
713 // goto join
714 __goto = 12; 827 __goto = 12;
715 break; 828 break;
716 case 13: 829 case 10:
717 // else 830 // uncaught
718 __result = fooError(__error1); 831 __next = [2];
719 case 12: 832 case 12:
720 // join
721 x = __result;
722 __next = [10];
723 // goto finally
724 __goto = 9;
725 break;
726 case 8:
727 // catch
728 __handler = null;
729 __error2 = __result;
730 y.x = foo(__error2);
731 __handler = null;
732 __next = [10];
733 case 9:
734 // finally 833 // finally
735 __handler = null; 834 __handler = 2;
736 foo(x); 835 foo(x);
737 // goto the next finally handler 836 // goto the next finally handler
738 __goto = __next.pop(); 837 __goto = __next.pop();
739 break; 838 break;
740 case 10: 839 case 13:
741 // after finally 840 // after finally
742 case 3: 841 // goto after finally
842 __goto = 5;
843 break;
844 case 2:
845 // uncaught
846 // goto rethrow
847 __goto = 1;
848 break;
849 case 5:
743 // after finally 850 // after finally
744 // implicit return 851 // implicit return
745 return thenHelper(null, null, __completer, null); 852 return thenHelper(null, 0, __completer, null);
853 case 1:
854 // rethrow
855 return thenHelper(__currentError, 1, __completer);
746 } 856 }
747 } catch (__error) { 857 } catch (__error) {
748 if (__handler === null) 858 __currentError = __error;
749 throw __error;
750 __result = __error;
751 __goto = __handler; 859 __goto = __handler;
752 } 860 }
753 861
754 } 862 }
755 return thenHelper(null, __helper, __completer, null); 863 return thenHelper(null, __body, __completer, null);
756 }"""); 864 }""");
865
757 testTransform(""" 866 testTransform("""
758 function(x, y) async { 867 function(x, y, j) async {
759 print(await(foo(x))); // calls 868 print(await(foo(x))); // calls
760 (await print)(foo(x)); 869 (await print)(foo(x));
761 print(foo(await x)); 870 print(foo(await x));
762 await (print(foo(await x))); 871 await (print(foo(await x)));
763 print(foo(x, await y, z)); 872 print(foo(x, await y, z));
764 } 873 }
765 """, """ 874 """, """
766 function(x, y) { 875 function(x, y, j) {
767 var __goto = 0, __completer = new Completer(), __temp1, __temp2, __temp3; 876 var __goto = 0, __completer = new Completer(), __handler = 1, __currentError, __temp1, __temp2, __temp3;
768 function __helper(__result) { 877 function __body(__errorCode, __result) {
878 if (__errorCode == 1) {
879 __currentError = __result;
880 __goto = __handler;
881 }
769 while (true) 882 while (true)
770 switch (__goto) { 883 try {
771 case 0: 884 switch (__goto) {
772 // Function start 885 case 0:
773 __temp1 = print; 886 // Function start
774 __goto = 1; 887 __temp1 = print;
775 return thenHelper(foo(x), __helper, __completer, null); 888 __goto = 2;
776 case 1: 889 return thenHelper(foo(x), __body, __completer);
777 // returning from await. 890 case 2:
778 __temp1(__result); 891 // returning from await.
779 __goto = 2; 892 __temp1(__result);
780 return thenHelper(print, __helper, __completer, null); 893 __goto = 3;
781 case 2: 894 return thenHelper(print, __body, __completer);
782 // returning from await. 895 case 3:
783 __result(foo(x)); 896 // returning from await.
784 __temp1 = print; 897 __result(foo(x));
785 __temp2 = foo; 898 __temp1 = print;
786 __goto = 3; 899 __temp2 = foo;
787 return thenHelper(x, __helper, __completer, null); 900 __goto = 4;
788 case 3: 901 return thenHelper(x, __body, __completer);
789 // returning from await. 902 case 4:
790 __temp1(__temp2(__result)); 903 // returning from await.
791 __temp1 = print; 904 __temp1(__temp2(__result));
792 __temp2 = foo; 905 __temp1 = print;
793 __goto = 5; 906 __temp2 = foo;
794 return thenHelper(x, __helper, __completer, null); 907 __goto = 6;
795 case 5: 908 return thenHelper(x, __body, __completer);
796 // returning from await. 909 case 6:
797 __goto = 4; 910 // returning from await.
798 return thenHelper(__temp1(__temp2(__result)), __helper, __completer, n ull); 911 __goto = 5;
799 case 4: 912 return thenHelper(__temp1(__temp2(__result)), __body, __completer);
800 // returning from await. 913 case 5:
801 __temp1 = print; 914 // returning from await.
802 __temp2 = foo; 915 __temp1 = print;
803 __temp3 = x; 916 __temp2 = foo;
804 __goto = 6; 917 __temp3 = x;
805 return thenHelper(y, __helper, __completer, null); 918 __goto = 7;
806 case 6: 919 return thenHelper(y, __body, __completer);
807 // returning from await. 920 case 7:
808 __temp1(__temp2(__temp3, __result, z)); 921 // returning from await.
809 // implicit return 922 __temp1(__temp2(__temp3, __result, z));
810 return thenHelper(null, null, __completer, null); 923 // implicit return
924 return thenHelper(null, 0, __completer, null);
925 case 1:
926 // rethrow
927 return thenHelper(__currentError, 1, __completer);
928 }
929 } catch (__error) {
930 __currentError = __error;
931 __goto = __handler;
811 } 932 }
933
812 } 934 }
813 return thenHelper(null, __helper, __completer, null); 935 return thenHelper(null, __body, __completer, null);
814 }"""); 936 }""");
937
815 testTransform(""" 938 testTransform("""
816 function(x, y) async { 939 function(x, y, k) async {
817 while (await(foo())) { 940 while (await(foo())) {
818 lab: { // labelled statement 941 lab: { // labelled statement
819 switch(y) { 942 switch(y) {
820 case 0: 943 case 0:
821 foo(); 944 foo();
822 case 0: // Duplicate case 945 case 0: // Duplicate case
823 print(await foo1(x)); 946 print(await foo1(x));
824 return y; 947 return y;
825 case await bar(): // await in case 948 case await bar(): // await in case
826 print(await foobar(x)); 949 print(await foobar(x));
827 return y; 950 return y;
828 case x: 951 case x:
829 if (a) { 952 if (a) {
830 throw new Error(); 953 throw new Error();
831 } else { 954 } else {
832 continue; 955 continue;
833 } 956 }
834 default: // defaul case 957 default: // defaul case
835 break lab; // break to label 958 break lab; // break to label
836 } 959 }
837 foo(); 960 foo();
838 } 961 }
839 } 962 }
840 }""", """ 963 }""", """
841 function(x, y) { 964 function(x, y, k) {
842 var __goto = 0, __completer = new Completer(), __returnValue, __temp1; 965 var __goto = 0, __completer = new Completer(), __handler = 2, __currentError, __returnValue, __temp1;
843 function __helper(__result) { 966 function __body(__errorCode, __result) {
967 if (__errorCode == 1) {
968 __currentError = __result;
969 __goto = __handler;
970 }
844 while (true) 971 while (true)
845 switch (__goto) { 972 try {
846 case 0: 973 switch (__goto) {
847 // Function start 974 case 0:
848 case 2: 975 // Function start
849 // while condition 976 case 3:
850 __goto = 4; 977 // while condition
851 return thenHelper(foo(), __helper, __completer, null); 978 __goto = 5;
852 case 4: 979 return thenHelper(foo(), __body, __completer);
853 // returning from await. 980 case 5:
854 if (!__result) { 981 // returning from await.
855 // goto after while 982 if (!__result) {
983 // goto after while
984 __goto = 4;
985 break;
986 }
987 case 7:
988 // continue lab
989 case 8:
990 // switch
991 __temp1 = y;
992 if (__temp1 === 0) {
993 // goto case
994 __goto = 10;
995 break;
996 }
997 if (__temp1 === 0) {
998 // goto case
999 __goto = 11;
1000 break;
1001 }
1002 __goto = 13;
1003 return thenHelper(bar(), __body, __completer);
1004 case 13:
1005 // returning from await.
1006 if (__temp1 === __result) {
1007 // goto case
1008 __goto = 12;
1009 break;
1010 }
1011 if (__temp1 === x) {
1012 // goto case
1013 __goto = 14;
1014 break;
1015 }
1016 // goto default
1017 __goto = 15;
1018 break;
1019 case 10:
1020 // case
1021 foo();
1022 case 11:
1023 // case
1024 __temp1 = print;
1025 __goto = 16;
1026 return thenHelper(foo1(x), __body, __completer);
1027 case 16:
1028 // returning from await.
1029 __temp1(__result);
1030 __returnValue = y;
1031 // goto return
1032 __goto = 1;
1033 break;
1034 case 12:
1035 // case
1036 __temp1 = print;
1037 __goto = 17;
1038 return thenHelper(foobar(x), __body, __completer);
1039 case 17:
1040 // returning from await.
1041 __temp1(__result);
1042 __returnValue = y;
1043 // goto return
1044 __goto = 1;
1045 break;
1046 case 14:
1047 // case
1048 if (a) {
1049 throw new Error();
1050 } else {
1051 // goto while condition
1052 __goto = 3;
1053 break;
1054 }
1055 case 15:
1056 // default
1057 // goto break lab
1058 __goto = 6;
1059 break;
1060 case 9:
1061 // after switch
1062 foo();
1063 case 6:
1064 // break lab
1065 // goto while condition
856 __goto = 3; 1066 __goto = 3;
857 break; 1067 break;
858 } 1068 case 4:
859 case 6: 1069 // after while
860 // continue lab 1070 case 1:
861 case 7: 1071 // return
862 // switch 1072 return thenHelper(__returnValue, 0, __completer, null);
863 __temp1 = y; 1073 case 2:
864 if (__temp1 === 0) { 1074 // rethrow
865 // goto case 1075 return thenHelper(__currentError, 1, __completer);
866 __goto = 9; 1076 }
867 break; 1077 } catch (__error) {
868 } 1078 __currentError = __error;
869 if (__temp1 === 0) { 1079 __goto = __handler;
870 // goto case
871 __goto = 10;
872 break;
873 }
874 __goto = 12;
875 return thenHelper(bar(), __helper, __completer, null);
876 case 12:
877 // returning from await.
878 if (__temp1 === __result) {
879 // goto case
880 __goto = 11;
881 break;
882 }
883 if (__temp1 === x) {
884 // goto case
885 __goto = 13;
886 break;
887 }
888 // goto default
889 __goto = 14;
890 break;
891 case 9:
892 // case
893 foo();
894 case 10:
895 // case
896 __temp1 = print;
897 __goto = 15;
898 return thenHelper(foo1(x), __helper, __completer, null);
899 case 15:
900 // returning from await.
901 __temp1(__result);
902 __returnValue = y;
903 // goto return
904 __goto = 1;
905 break;
906 case 11:
907 // case
908 __temp1 = print;
909 __goto = 16;
910 return thenHelper(foobar(x), __helper, __completer, null);
911 case 16:
912 // returning from await.
913 __temp1(__result);
914 __returnValue = y;
915 // goto return
916 __goto = 1;
917 break;
918 case 13:
919 // case
920 if (a) {
921 throw new Error();
922 } else {
923 // goto while condition
924 __goto = 2;
925 break;
926 }
927 case 14:
928 // default
929 // goto break lab
930 __goto = 5;
931 break;
932 case 8:
933 // after switch
934 foo();
935 case 5:
936 // break lab
937 // goto while condition
938 __goto = 2;
939 break;
940 case 3:
941 // after while
942 case 1:
943 // return
944 return thenHelper(__returnValue, null, __completer, null);
945 } 1080 }
1081
946 } 1082 }
947 return thenHelper(null, __helper, __completer, null); 1083 return thenHelper(null, __body, __completer, null);
948 }"""); 1084 }""");
949 } 1085 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/libraries.dart ('k') | tests/compiler/dart2js/mock_libraries.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698