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

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

Issue 996103002: Fix handling of lazy and and or in async functions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address Review 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 786 matching lines...) Expand 10 before | Expand all | Expand 10 after
797 797
798 @override 798 @override
799 js.Expression visitBinary(js.Binary node) { 799 js.Expression visitBinary(js.Binary node) {
800 if (shouldTransform(node.right) && (node.op == "||" || node.op == "&&")) { 800 if (shouldTransform(node.right) && (node.op == "||" || node.op == "&&")) {
801 int thenLabel = newLabel("then"); 801 int thenLabel = newLabel("then");
802 int joinLabel = newLabel("join"); 802 int joinLabel = newLabel("join");
803 withExpression(node.left, (js.Expression left) { 803 withExpression(node.left, (js.Expression left) {
804 js.Statement assignLeft = isResult(left) 804 js.Statement assignLeft = isResult(left)
805 ? new js.Block.empty() 805 ? new js.Block.empty()
806 : js.js.statement('# = #;', [result, left]); 806 : js.js.statement('# = #;', [result, left]);
807 if (node.op == "||") { 807 if (node.op == "&&") {
808 addStatement(js.js.statement('if (#) {#} else #', 808 addStatement(js.js.statement('if (#) {#} else #',
809 [left, gotoAndBreak(thenLabel), assignLeft])); 809 [left, gotoAndBreak(thenLabel), assignLeft]));
810 } else { 810 } else {
811 assert(node.op == "&&"); 811 assert(node.op == "||");
812 addStatement(js.js.statement('if (#) {#} else #', 812 addStatement(js.js.statement('if (#) {#} else #',
813 [left, assignLeft, gotoAndBreak(thenLabel)])); 813 [left, assignLeft, gotoAndBreak(thenLabel)]));
814 } 814 }
815 }, store: true); 815 }, store: true);
816 addGoto(joinLabel); 816 addGoto(joinLabel);
817 beginLabel(thenLabel); 817 beginLabel(thenLabel);
818 withExpression(node.right, (js.Expression value) { 818 withExpression(node.right, (js.Expression value) {
819 if (!isResult(value)) { 819 if (!isResult(value)) {
820 addStatement(js.js.statement('# = #;', [result, value])); 820 addStatement(js.js.statement('# = #;', [result, value]));
821 } 821 }
(...skipping 1702 matching lines...) Expand 10 before | Expand all | Expand 10 after
2524 return condition || body; 2524 return condition || body;
2525 } 2525 }
2526 2526
2527 @override 2527 @override
2528 bool visitDartYield(js.DartYield node) { 2528 bool visitDartYield(js.DartYield node) {
2529 hasYield = true; 2529 hasYield = true;
2530 visit(node.expression); 2530 visit(node.expression);
2531 return true; 2531 return true;
2532 } 2532 }
2533 } 2533 }
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