| OLD | NEW |
| 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:js_runtime/shared/async_await_error_codes.dart' | 10 import 'package:js_runtime/shared/async_await_error_codes.dart' |
| (...skipping 1263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1274 return withExpression( | 1274 return withExpression( |
| 1275 node.value, (js.Expression value) => new js.Property(node.name, value), | 1275 node.value, (js.Expression value) => new js.Property(node.name, value), |
| 1276 store: false); | 1276 store: false); |
| 1277 } | 1277 } |
| 1278 | 1278 |
| 1279 @override | 1279 @override |
| 1280 js.Expression visitRegExpLiteral(js.RegExpLiteral node) => node; | 1280 js.Expression visitRegExpLiteral(js.RegExpLiteral node) => node; |
| 1281 | 1281 |
| 1282 @override | 1282 @override |
| 1283 void visitReturn(js.Return node) { | 1283 void visitReturn(js.Return node) { |
| 1284 assert(node.value == null || (!isSyncStar && !isAsyncStar)); | |
| 1285 js.Node target = analysis.targets[node]; | 1284 js.Node target = analysis.targets[node]; |
| 1286 if (node.value != null) { | 1285 if (node.value != null) { |
| 1287 withExpression(node.value, (js.Expression value) { | 1286 if(isSyncStar || isAsyncStar) { |
| 1288 addStatement(js.js.statement("# = #;", [returnValue, value])); | 1287 // Even though `return expr;` is not allowed in the dart sync* and |
| 1289 }, store: false); | 1288 // async* code, the backend sometimes generates code like this, but |
| 1289 // only when it is known that the 'expr' throws, and the return is just |
| 1290 // to tell the JavaScript VM that the code won't continue here. |
| 1291 // It is therefore interpreted as `expr; return;` |
| 1292 visitExpressionIgnoreResult(node.value); |
| 1293 } else { |
| 1294 withExpression(node.value, (js.Expression value) { |
| 1295 addStatement(js.js.statement("# = #;", [returnValue, value])); |
| 1296 }, store: false); |
| 1297 } |
| 1290 } | 1298 } |
| 1291 translateJump(target, exitLabel); | 1299 translateJump(target, exitLabel); |
| 1292 } | 1300 } |
| 1293 | 1301 |
| 1294 @override | 1302 @override |
| 1295 void visitSwitch(js.Switch node) { | 1303 void visitSwitch(js.Switch node) { |
| 1296 if (!node.cases.any(shouldTransform)) { | 1304 if (!node.cases.any(shouldTransform)) { |
| 1297 // If only the key has an await, translation can be simplified. | 1305 // If only the key has an await, translation can be simplified. |
| 1298 bool oldInsideUntranslated = insideUntranslatedBreakable; | 1306 bool oldInsideUntranslated = insideUntranslatedBreakable; |
| 1299 insideUntranslatedBreakable = true; | 1307 insideUntranslatedBreakable = true; |
| (...skipping 1277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2577 return condition || body; | 2585 return condition || body; |
| 2578 } | 2586 } |
| 2579 | 2587 |
| 2580 @override | 2588 @override |
| 2581 bool visitDartYield(js.DartYield node) { | 2589 bool visitDartYield(js.DartYield node) { |
| 2582 hasYield = true; | 2590 hasYield = true; |
| 2583 visit(node.expression); | 2591 visit(node.expression); |
| 2584 return true; | 2592 return true; |
| 2585 } | 2593 } |
| 2586 } | 2594 } |
| OLD | NEW |