Chromium Code Reviews| 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 generated code like this. |
| 1289 // It is interpreted as `expr; return;` | |
|
floitsch
2015/07/15 14:03:16
Add more comment of why this could ever be legal.
| |
| 1290 visitExpressionIgnoreResult(node.value); | |
| 1291 } else { | |
| 1292 withExpression(node.value, (js.Expression value) { | |
| 1293 addStatement(js.js.statement("# = #;", [returnValue, value])); | |
| 1294 }, store: false); | |
| 1295 } | |
| 1290 } | 1296 } |
| 1291 translateJump(target, exitLabel); | 1297 translateJump(target, exitLabel); |
| 1292 } | 1298 } |
| 1293 | 1299 |
| 1294 @override | 1300 @override |
| 1295 void visitSwitch(js.Switch node) { | 1301 void visitSwitch(js.Switch node) { |
| 1296 if (!node.cases.any(shouldTransform)) { | 1302 if (!node.cases.any(shouldTransform)) { |
| 1297 // If only the key has an await, translation can be simplified. | 1303 // If only the key has an await, translation can be simplified. |
| 1298 bool oldInsideUntranslated = insideUntranslatedBreakable; | 1304 bool oldInsideUntranslated = insideUntranslatedBreakable; |
| 1299 insideUntranslatedBreakable = true; | 1305 insideUntranslatedBreakable = true; |
| (...skipping 1277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2577 return condition || body; | 2583 return condition || body; |
| 2578 } | 2584 } |
| 2579 | 2585 |
| 2580 @override | 2586 @override |
| 2581 bool visitDartYield(js.DartYield node) { | 2587 bool visitDartYield(js.DartYield node) { |
| 2582 hasYield = true; | 2588 hasYield = true; |
| 2583 visit(node.expression); | 2589 visit(node.expression); |
| 2584 return true; | 2590 return true; |
| 2585 } | 2591 } |
| 2586 } | 2592 } |
| OLD | NEW |