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

Side by Side Diff: pkg/compiler/lib/src/js/rewrite_async.dart

Issue 976603002: Fix problems with default-cases in async code. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 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 | « no previous file | tests/compiler/dart2js/async_await_js_transform_test.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 library rewrite_async; 5 library rewrite_async;
6 6
7 import "dart:math" show max; 7 import "dart:math" show max;
8 import 'dart:collection'; 8 import 'dart:collection';
9 9
10 import 'package:_internal/compiler/js_lib/shared/async_await_error_codes.dart' 10 import 'package:_internal/compiler/js_lib/shared/async_await_error_codes.dart'
(...skipping 1287 matching lines...) Expand 10 before | Expand all | Expand 10 after
1298 addGoto(labels[defaultIndex]); 1298 addGoto(labels[defaultIndex]);
1299 } 1299 }
1300 } else { 1300 } else {
1301 bool hasDefault = false; 1301 bool hasDefault = false;
1302 int i = 0; 1302 int i = 0;
1303 List<js.SwitchClause> clauses = new List<js.SwitchClause>(); 1303 List<js.SwitchClause> clauses = new List<js.SwitchClause>();
1304 for (js.SwitchClause clause in node.cases) { 1304 for (js.SwitchClause clause in node.cases) {
1305 if (clause is js.Case) { 1305 if (clause is js.Case) {
1306 labels[i] = newLabel("case"); 1306 labels[i] = newLabel("case");
1307 clauses.add(new js.Case(clause.expression, gotoAndBreak(labels[i]))); 1307 clauses.add(new js.Case(clause.expression, gotoAndBreak(labels[i])));
1308 } else if (i is js.Default) { 1308 } else if (clause is js.Default) {
1309 labels[i] = newLabel("default"); 1309 labels[i] = newLabel("default");
1310 clauses.add(new js.Default(gotoAndBreak(labels[i]))); 1310 clauses.add(new js.Default(gotoAndBreak(labels[i])));
1311 hasDefault = true; 1311 hasDefault = true;
1312 } else { 1312 } else {
1313 diagnosticListener.internalError( 1313 diagnosticListener.internalError(
1314 spannable, "Unknown clause type $clause"); 1314 spannable, "Unknown clause type $clause");
1315 } 1315 }
1316 i++; 1316 i++;
1317 } 1317 }
1318 if (!hasDefault) {
1319 clauses.add(new js.Default(gotoAndBreak(after)));
1320 }
1318 withExpression(node.key, (js.Expression key) { 1321 withExpression(node.key, (js.Expression key) {
1319 addStatement(new js.Switch(key, clauses)); 1322 addStatement(new js.Switch(key, clauses));
1320 }, store: false); 1323 }, store: false);
1321 if (!hasDefault) { 1324
1322 addGoto(after); 1325 addBreak();
1323 }
1324 } 1326 }
1325 1327
1326 jumpTargets.add(node); 1328 jumpTargets.add(node);
1327 for (int i = 0; i < labels.length; i++) { 1329 for (int i = 0; i < labels.length; i++) {
1328 beginLabel(labels[i]); 1330 beginLabel(labels[i]);
1329 visitStatement(node.cases[i].body); 1331 visitStatement(node.cases[i].body);
1330 } 1332 }
1331 beginLabel(after); 1333 beginLabel(after);
1332 jumpTargets.removeLast(); 1334 jumpTargets.removeLast();
1333 } 1335 }
(...skipping 1117 matching lines...) Expand 10 before | Expand all | Expand 10 after
2451 return condition || body; 2453 return condition || body;
2452 } 2454 }
2453 2455
2454 @override 2456 @override
2455 bool visitDartYield(js.DartYield node) { 2457 bool visitDartYield(js.DartYield node) {
2456 hasYield = true; 2458 hasYield = true;
2457 visit(node.expression); 2459 visit(node.expression);
2458 return true; 2460 return true;
2459 } 2461 }
2460 } 2462 }
OLDNEW
« no previous file with comments | « no previous file | tests/compiler/dart2js/async_await_js_transform_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698