Chromium Code Reviews| 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.continuation; | 5 library kernel.transformations.continuation; |
| 6 | 6 |
| 7 import 'dart:math' as math; | 7 import 'dart:math' as math; |
| 8 | 8 |
| 9 import '../ast.dart'; | 9 import '../ast.dart'; |
| 10 import '../core_types.dart'; | 10 import '../core_types.dart'; |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 139 | 139 |
| 140 // return new _SyncIterable(:sync_body); | 140 // return new _SyncIterable(:sync_body); |
| 141 final arguments = new Arguments([new VariableGet(nestedClosureVariable)]); | 141 final arguments = new Arguments([new VariableGet(nestedClosureVariable)]); |
| 142 final returnStatement = new ReturnStatement( | 142 final returnStatement = new ReturnStatement( |
| 143 new ConstructorInvocation(helper.syncIterableConstructor, arguments)); | 143 new ConstructorInvocation(helper.syncIterableConstructor, arguments)); |
| 144 | 144 |
| 145 enclosingFunction.body = new Block([] | 145 enclosingFunction.body = new Block([] |
| 146 ..addAll(variableDeclarations()) | 146 ..addAll(variableDeclarations()) |
| 147 ..addAll([closureFunction, returnStatement])); | 147 ..addAll([closureFunction, returnStatement])); |
| 148 enclosingFunction.body.parent = enclosingFunction; | 148 enclosingFunction.body.parent = enclosingFunction; |
| 149 enclosingFunction.originalAsyncMarker = enclosingFunction.asyncMarker; | |
|
Kevin Millikin (Google)
2017/02/22 07:59:59
It doesn't make sense to ever change the original
jensj
2017/02/22 10:36:45
Done.
| |
| 149 enclosingFunction.asyncMarker = AsyncMarker.Sync; | 150 enclosingFunction.asyncMarker = AsyncMarker.Sync; |
| 150 return enclosingFunction; | 151 return enclosingFunction; |
| 151 } | 152 } |
| 152 | 153 |
| 153 Statement buildClosureBody() { | 154 Statement buildClosureBody() { |
| 154 // The body will insert calls to | 155 // The body will insert calls to |
| 155 // :iterator.current_= | 156 // :iterator.current_= |
| 156 // :iterator.isYieldEach= | 157 // :iterator.isYieldEach= |
| 157 // and return `true` as long as it did something and `false` when it's done. | 158 // and return `true` as long as it did something and `false` when it's done. |
| 158 return new Block(<Statement>[ | 159 return new Block(<Statement>[ |
| (...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 691 statements.add(setController); | 692 statements.add(setController); |
| 692 | 693 |
| 693 // return :controller.stream; | 694 // return :controller.stream; |
| 694 var completerGet = new VariableGet(controllerVariable); | 695 var completerGet = new VariableGet(controllerVariable); |
| 695 var returnStatement = new ReturnStatement( | 696 var returnStatement = new ReturnStatement( |
| 696 new PropertyGet(completerGet, new Name('stream', helper.asyncLibrary))); | 697 new PropertyGet(completerGet, new Name('stream', helper.asyncLibrary))); |
| 697 statements.add(returnStatement); | 698 statements.add(returnStatement); |
| 698 | 699 |
| 699 enclosingFunction.body = new Block(statements); | 700 enclosingFunction.body = new Block(statements); |
| 700 enclosingFunction.body.parent = enclosingFunction; | 701 enclosingFunction.body.parent = enclosingFunction; |
| 702 enclosingFunction.originalAsyncMarker = enclosingFunction.asyncMarker; | |
|
Kevin Millikin (Google)
2017/02/22 07:59:59
Same comment.
jensj
2017/02/22 10:36:45
Done.
| |
| 701 enclosingFunction.asyncMarker = AsyncMarker.Sync; | 703 enclosingFunction.asyncMarker = AsyncMarker.Sync; |
| 702 return enclosingFunction; | 704 return enclosingFunction; |
| 703 } | 705 } |
| 704 | 706 |
| 705 Statement buildWrappedBody() { | 707 Statement buildWrappedBody() { |
| 706 ++currentTryDepth; | 708 ++currentTryDepth; |
| 707 Statement body = super.buildWrappedBody(); | 709 Statement body = super.buildWrappedBody(); |
| 708 --currentTryDepth; | 710 --currentTryDepth; |
| 709 | 711 |
| 710 var finallyBody = new ExpressionStatement(new MethodInvocation( | 712 var finallyBody = new ExpressionStatement(new MethodInvocation( |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 813 statements.add(newMicrotaskStatement); | 815 statements.add(newMicrotaskStatement); |
| 814 | 816 |
| 815 // return :completer.future; | 817 // return :completer.future; |
| 816 var completerGet = new VariableGet(completerVariable); | 818 var completerGet = new VariableGet(completerVariable); |
| 817 var returnStatement = new ReturnStatement( | 819 var returnStatement = new ReturnStatement( |
| 818 new PropertyGet(completerGet, new Name('future', helper.asyncLibrary))); | 820 new PropertyGet(completerGet, new Name('future', helper.asyncLibrary))); |
| 819 statements.add(returnStatement); | 821 statements.add(returnStatement); |
| 820 | 822 |
| 821 enclosingFunction.body = new Block(statements); | 823 enclosingFunction.body = new Block(statements); |
| 822 enclosingFunction.body.parent = enclosingFunction; | 824 enclosingFunction.body.parent = enclosingFunction; |
| 825 enclosingFunction.originalAsyncMarker = enclosingFunction.asyncMarker; | |
|
Kevin Millikin (Google)
2017/02/22 07:59:59
Same comment.
jensj
2017/02/22 10:36:45
Done.
| |
| 823 enclosingFunction.asyncMarker = AsyncMarker.Sync; | 826 enclosingFunction.asyncMarker = AsyncMarker.Sync; |
| 824 enclosingFunction.debuggable = false; | |
| 825 return enclosingFunction; | 827 return enclosingFunction; |
| 826 } | 828 } |
| 827 | 829 |
| 828 Statement buildCatchBody(exceptionVariable, stackTraceVariable) { | 830 Statement buildCatchBody(exceptionVariable, stackTraceVariable) { |
| 829 return new ExpressionStatement(new MethodInvocation( | 831 return new ExpressionStatement(new MethodInvocation( |
| 830 new VariableGet(completerVariable), | 832 new VariableGet(completerVariable), |
| 831 new Name("completeError", helper.asyncLibrary), | 833 new Name("completeError", helper.asyncLibrary), |
| 832 new Arguments([ | 834 new Arguments([ |
| 833 new VariableGet(exceptionVariable), | 835 new VariableGet(exceptionVariable), |
| 834 new VariableGet(stackTraceVariable) | 836 new VariableGet(stackTraceVariable) |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 970 findConstructor(syncIterableClass, ''), | 972 findConstructor(syncIterableClass, ''), |
| 971 findConstructor(streamIteratorClass, ''), | 973 findConstructor(streamIteratorClass, ''), |
| 972 findFactoryConstructor(futureClass, 'microtask'), | 974 findFactoryConstructor(futureClass, 'microtask'), |
| 973 findConstructor(streamControllerClass, ''), | 975 findConstructor(streamControllerClass, ''), |
| 974 findProcedure(asyncLibrary, '_asyncThenWrapperHelper'), | 976 findProcedure(asyncLibrary, '_asyncThenWrapperHelper'), |
| 975 findProcedure(asyncLibrary, '_asyncErrorWrapperHelper'), | 977 findProcedure(asyncLibrary, '_asyncErrorWrapperHelper'), |
| 976 findProcedure(asyncLibrary, '_awaitHelper'), | 978 findProcedure(asyncLibrary, '_awaitHelper'), |
| 977 new CoreTypes(program)); | 979 new CoreTypes(program)); |
| 978 } | 980 } |
| 979 } | 981 } |
| OLD | NEW |