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

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

Issue 1060293002: Fix bug in dart2js async rewrite (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
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 | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/language/async_regression_23058_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 862 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 } 873 }
874 874
875 @override 875 @override
876 void visitComment(js.Comment node) { 876 void visitComment(js.Comment node) {
877 addStatement(node); 877 addStatement(node);
878 } 878 }
879 879
880 @override 880 @override
881 js.Expression visitConditional(js.Conditional node) { 881 js.Expression visitConditional(js.Conditional node) {
882 if (!shouldTransform(node.then) && !shouldTransform(node.otherwise)) { 882 if (!shouldTransform(node.then) && !shouldTransform(node.otherwise)) {
883 return withExpression(node.condition, (js.Expression condition) { 883 return js.js('# ? # : #', [visitExpression(node.condition),
884 return js.js('# ? # : #', [condition, node.then, node.otherwise]); 884 visitExpression(node.then),
885 }, store: false); 885 visitExpression(node.otherwise)]);
886 } 886 }
887 int thenLabel = newLabel("then"); 887 int thenLabel = newLabel("then");
888 int joinLabel = newLabel("join"); 888 int joinLabel = newLabel("join");
889 int elseLabel = newLabel("else"); 889 int elseLabel = newLabel("else");
890 withExpression(node.condition, (js.Expression condition) { 890 withExpression(node.condition, (js.Expression condition) {
891 addStatement(js.js.statement('# = # ? # : #;', 891 addStatement(js.js.statement('# = # ? # : #;',
892 [goto, condition, js.number(thenLabel), js.number(elseLabel)])); 892 [goto, condition, js.number(thenLabel), js.number(elseLabel)]));
893 }, store: false); 893 }, store: false);
894 addBreak(); 894 addBreak();
895 beginLabel(thenLabel); 895 beginLabel(thenLabel);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
962 } 962 }
963 963
964 @override 964 @override
965 void visitDefault(js.Default node) => unreachable(node); 965 void visitDefault(js.Default node) => unreachable(node);
966 966
967 @override 967 @override
968 void visitDo(js.Do node) { 968 void visitDo(js.Do node) {
969 if (!shouldTransform(node)) { 969 if (!shouldTransform(node)) {
970 bool oldInsideUntranslatedBreakable = insideUntranslatedBreakable; 970 bool oldInsideUntranslatedBreakable = insideUntranslatedBreakable;
971 insideUntranslatedBreakable = true; 971 insideUntranslatedBreakable = true;
972 withExpression(node.condition, (js.Expression condition) { 972 addStatement(js.js.statement('do {#} while (#)',
973 addStatement(js.js.statement('do {#} while (#)', 973 [translateInBlock(node.body),
974 [node.body, condition])); 974 visitExpression(node.condition)]));
975 }, store: false);
976 insideUntranslatedBreakable = oldInsideUntranslatedBreakable; 975 insideUntranslatedBreakable = oldInsideUntranslatedBreakable;
977 return; 976 return;
978 } 977 }
979 int startLabel = newLabel("do body"); 978 int startLabel = newLabel("do body");
980 979
981 int continueLabel = newLabel("do condition"); 980 int continueLabel = newLabel("do condition");
982 continueLabels[node] = continueLabel; 981 continueLabels[node] = continueLabel;
983 982
984 int afterLabel = newLabel("after do"); 983 int afterLabel = newLabel("after do");
985 breakLabels[node] = afterLabel; 984 breakLabels[node] = afterLabel;
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
1341 } else { 1340 } else {
1342 addGoto(labels[defaultIndex]); 1341 addGoto(labels[defaultIndex]);
1343 } 1342 }
1344 } else { 1343 } else {
1345 bool hasDefault = false; 1344 bool hasDefault = false;
1346 int i = 0; 1345 int i = 0;
1347 List<js.SwitchClause> clauses = new List<js.SwitchClause>(); 1346 List<js.SwitchClause> clauses = new List<js.SwitchClause>();
1348 for (js.SwitchClause clause in node.cases) { 1347 for (js.SwitchClause clause in node.cases) {
1349 if (clause is js.Case) { 1348 if (clause is js.Case) {
1350 labels[i] = newLabel("case"); 1349 labels[i] = newLabel("case");
1351 clauses.add(new js.Case(clause.expression, gotoAndBreak(labels[i]))); 1350 clauses.add(new js.Case(visitExpression(clause.expression),
1351 gotoAndBreak(labels[i])));
1352 } else if (clause is js.Default) { 1352 } else if (clause is js.Default) {
1353 labels[i] = newLabel("default"); 1353 labels[i] = newLabel("default");
1354 clauses.add(new js.Default(gotoAndBreak(labels[i]))); 1354 clauses.add(new js.Default(gotoAndBreak(labels[i])));
1355 hasDefault = true; 1355 hasDefault = true;
1356 } else { 1356 } else {
1357 diagnosticListener.internalError( 1357 diagnosticListener.internalError(
1358 spannable, "Unknown clause type $clause"); 1358 spannable, "Unknown clause type $clause");
1359 } 1359 }
1360 i++; 1360 i++;
1361 } 1361 }
(...skipping 1180 matching lines...) Expand 10 before | Expand all | Expand 10 after
2542 return condition || body; 2542 return condition || body;
2543 } 2543 }
2544 2544
2545 @override 2545 @override
2546 bool visitDartYield(js.DartYield node) { 2546 bool visitDartYield(js.DartYield node) {
2547 hasYield = true; 2547 hasYield = true;
2548 visit(node.expression); 2548 visit(node.expression);
2549 return true; 2549 return true;
2550 } 2550 }
2551 } 2551 }
OLDNEW
« no previous file with comments | « no previous file | tests/language/async_regression_23058_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698