| 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:collection'; | 7 import 'dart:collection'; |
| 8 import "dart:math" show max; | 8 import "dart:math" show max; |
| 9 | 9 |
| 10 import 'package:js_runtime/shared/async_await_error_codes.dart' as error_codes; | 10 import 'package:js_runtime/shared/async_await_error_codes.dart' as error_codes; |
| (...skipping 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1067 List<js.Statement> oldBuffer = currentStatementBuffer; | 1067 List<js.Statement> oldBuffer = currentStatementBuffer; |
| 1068 currentStatementBuffer = <js.Statement>[]; | 1068 currentStatementBuffer = <js.Statement>[]; |
| 1069 List<js.Statement> resultBuffer = currentStatementBuffer; | 1069 List<js.Statement> resultBuffer = currentStatementBuffer; |
| 1070 visitStatement(node); | 1070 visitStatement(node); |
| 1071 currentStatementBuffer = oldBuffer; | 1071 currentStatementBuffer = oldBuffer; |
| 1072 return resultBuffer; | 1072 return resultBuffer; |
| 1073 } | 1073 } |
| 1074 | 1074 |
| 1075 js.Statement translateToStatement(js.Statement node) { | 1075 js.Statement translateToStatement(js.Statement node) { |
| 1076 List<js.Statement> statements = translateToStatementSequence(node); | 1076 List<js.Statement> statements = translateToStatementSequence(node); |
| 1077 if (statements.length == 1) | 1077 if (statements.length == 1) return statements.single; |
| 1078 return statements.single; | |
| 1079 return new js.Block(statements); | 1078 return new js.Block(statements); |
| 1080 } | 1079 } |
| 1081 | 1080 |
| 1082 js.Block translateToBlock(js.Statement node) { | 1081 js.Block translateToBlock(js.Statement node) { |
| 1083 return new js.Block(translateToStatementSequence(node)); | 1082 return new js.Block(translateToStatementSequence(node)); |
| 1084 } | 1083 } |
| 1085 | 1084 |
| 1086 @override | 1085 @override |
| 1087 void visitIf(js.If node) { | 1086 void visitIf(js.If node) { |
| 1088 if (!shouldTransform(node.then) && !shouldTransform(node.otherwise)) { | 1087 if (!shouldTransform(node.then) && !shouldTransform(node.otherwise)) { |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1433 return result.reversed.toList(); | 1432 return result.reversed.toList(); |
| 1434 } | 1433 } |
| 1435 | 1434 |
| 1436 /// See the comments of [rewriteFunction] for more explanation. | 1435 /// See the comments of [rewriteFunction] for more explanation. |
| 1437 void visitTry(js.Try node) { | 1436 void visitTry(js.Try node) { |
| 1438 if (!shouldTransform(node)) { | 1437 if (!shouldTransform(node)) { |
| 1439 js.Block body = translateToBlock(node.body); | 1438 js.Block body = translateToBlock(node.body); |
| 1440 js.Catch catchPart = (node.catchPart == null) | 1439 js.Catch catchPart = (node.catchPart == null) |
| 1441 ? null | 1440 ? null |
| 1442 : new js.Catch(node.catchPart.declaration, | 1441 : new js.Catch(node.catchPart.declaration, |
| 1443 translateToBlock(node.catchPart.body)); | 1442 translateToBlock(node.catchPart.body)); |
| 1444 js.Block finallyPart = (node.finallyPart == null) | 1443 js.Block finallyPart = (node.finallyPart == null) |
| 1445 ? null | 1444 ? null |
| 1446 : translateToBlock(node.finallyPart); | 1445 : translateToBlock(node.finallyPart); |
| 1447 addStatement(new js.Try(body, catchPart, finallyPart)); | 1446 addStatement(new js.Try(body, catchPart, finallyPart)); |
| 1448 return; | 1447 return; |
| 1449 } | 1448 } |
| 1450 | 1449 |
| 1451 hasTryBlocks = true; | 1450 hasTryBlocks = true; |
| 1452 int uncaughtLabel = newLabel("uncaught"); | 1451 int uncaughtLabel = newLabel("uncaught"); |
| 1453 int handlerLabel = | 1452 int handlerLabel = |
| (...skipping 1133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2587 return condition || body; | 2586 return condition || body; |
| 2588 } | 2587 } |
| 2589 | 2588 |
| 2590 @override | 2589 @override |
| 2591 bool visitDartYield(js.DartYield node) { | 2590 bool visitDartYield(js.DartYield node) { |
| 2592 hasYield = true; | 2591 hasYield = true; |
| 2593 visit(node.expression); | 2592 visit(node.expression); |
| 2594 return true; | 2593 return true; |
| 2595 } | 2594 } |
| 2596 } | 2595 } |
| OLD | NEW |