| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 kernel.transformations.async; | 5 library kernel.transformations.async; |
| 6 | 6 |
| 7 import '../kernel.dart'; | 7 import '../kernel.dart'; |
| 8 import 'continuation.dart'; | 8 import 'continuation.dart'; |
| 9 | 9 |
| 10 /// A transformer that introduces temporary variables for all subexpressions | 10 /// A transformer that introduces temporary variables for all subexpressions |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 // will produce the sequence of statements: | 450 // will produce the sequence of statements: |
| 451 // | 451 // |
| 452 // <initializer's statements> | 452 // <initializer's statements> |
| 453 // var x = <initializer's value> | 453 // var x = <initializer's value> |
| 454 // <body's statements> | 454 // <body's statements> |
| 455 // | 455 // |
| 456 // and return the body's value. | 456 // and return the body's value. |
| 457 // | 457 // |
| 458 // So x is in scope for all the body's statements and the body's value. | 458 // So x is in scope for all the body's statements and the body's value. |
| 459 // This has the unpleasant consequence that all let-bound variables with | 459 // This has the unpleasant consequence that all let-bound variables with |
| 460 // await in the let's body will end up hoisted out the the expression and | 460 // await in the let's body will end up hoisted out of the expression and |
| 461 // allocated to the context in the VM, even if they have no uses | 461 // allocated to the context in the VM, even if they have no uses |
| 462 // (`let _ = e0 in e1` can be used for sequencing of `e0` and `e1`). | 462 // (`let _ = e0 in e1` can be used for sequencing of `e0` and `e1`). |
| 463 statements.add(variable); | 463 statements.add(variable); |
| 464 var index = nameIndex; | 464 var index = nameIndex; |
| 465 seenAwait = false; | 465 seenAwait = false; |
| 466 variable.initializer = variable.initializer.accept(this) | 466 variable.initializer = variable.initializer.accept(this) |
| 467 ..parent = variable; | 467 ..parent = variable; |
| 468 // Temporaries used in the initializer or the body are not live but the | 468 // Temporaries used in the initializer or the body are not live but the |
| 469 // temporary used for the body is. | 469 // temporary used for the body is. |
| 470 nameIndex = index + 1; | 470 nameIndex = index + 1; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 482 }); | 482 }); |
| 483 } | 483 } |
| 484 } | 484 } |
| 485 | 485 |
| 486 visitFunctionNode(FunctionNode node) { | 486 visitFunctionNode(FunctionNode node) { |
| 487 var nestedRewriter = | 487 var nestedRewriter = |
| 488 new RecursiveContinuationRewriter(continuationRewriter.helper); | 488 new RecursiveContinuationRewriter(continuationRewriter.helper); |
| 489 return node.accept(nestedRewriter); | 489 return node.accept(nestedRewriter); |
| 490 } | 490 } |
| 491 } | 491 } |
| OLD | NEW |