| 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 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 ++nameIndex; | 402 ++nameIndex; |
| 403 seenAwait = seenAwait || thenAwait || otherwiseAwait; | 403 seenAwait = seenAwait || thenAwait || otherwiseAwait; |
| 404 return new VariableGet(result); | 404 return new VariableGet(result); |
| 405 } | 405 } |
| 406 | 406 |
| 407 // Others. | 407 // Others. |
| 408 TreeNode visitAwaitExpression(AwaitExpression expr) { | 408 TreeNode visitAwaitExpression(AwaitExpression expr) { |
| 409 final R = continuationRewriter; | 409 final R = continuationRewriter; |
| 410 var shouldName = seenAwait; | 410 var shouldName = seenAwait; |
| 411 var result = new VariableGet(asyncResult); | 411 var result = new VariableGet(asyncResult); |
| 412 |
| 412 // The statements are in reverse order, so name the result first if | 413 // The statements are in reverse order, so name the result first if |
| 413 // necessary and then add the two other statements in reverse. | 414 // necessary and then add the two other statements in reverse. |
| 414 if (shouldName) result = name(result); | 415 if (shouldName) result = name(result); |
| 415 statements.add(R.createContinuationPoint()); | 416 statements.add(R.createContinuationPoint()..fileOffset = expr.fileOffset); |
| 416 Arguments arguments = new Arguments(<Expression>[ | 417 Arguments arguments = new Arguments(<Expression>[ |
| 417 expr.operand, | 418 expr.operand, |
| 418 new VariableGet(R.thenContinuationVariable), | 419 new VariableGet(R.thenContinuationVariable), |
| 419 new VariableGet(R.catchErrorContinuationVariable) | 420 new VariableGet(R.catchErrorContinuationVariable) |
| 420 ]); | 421 ]); |
| 421 statements.add(new ExpressionStatement( | 422 statements.add(new ExpressionStatement( |
| 422 new StaticInvocation(R.helper.awaitHelper, arguments))); | 423 new StaticInvocation(R.helper.awaitHelper, arguments) |
| 424 ..fileOffset = expr.fileOffset)); |
| 423 | 425 |
| 424 seenAwait = false; | 426 seenAwait = false; |
| 425 var index = nameIndex; | 427 var index = nameIndex; |
| 426 arguments.positional[0] = expr.operand.accept(this)..parent = arguments; | 428 arguments.positional[0] = expr.operand.accept(this)..parent = arguments; |
| 427 | 429 |
| 428 if (shouldName) nameIndex = index + 1; | 430 if (shouldName) nameIndex = index + 1; |
| 429 seenAwait = true; | 431 seenAwait = true; |
| 430 return result; | 432 return result; |
| 431 } | 433 } |
| 432 | 434 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 }); | 481 }); |
| 480 } | 482 } |
| 481 } | 483 } |
| 482 | 484 |
| 483 visitFunctionNode(FunctionNode node) { | 485 visitFunctionNode(FunctionNode node) { |
| 484 var nestedRewriter = | 486 var nestedRewriter = |
| 485 new RecursiveContinuationRewriter(continuationRewriter.helper); | 487 new RecursiveContinuationRewriter(continuationRewriter.helper); |
| 486 return node.accept(nestedRewriter); | 488 return node.accept(nestedRewriter); |
| 487 } | 489 } |
| 488 } | 490 } |
| OLD | NEW |