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 1658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1669 /// - [error_codes.SUCCESS] | 1669 /// - [error_codes.SUCCESS] |
1670 /// - The completer object [completer] | 1670 /// - The completer object [completer] |
1671 /// | 1671 /// |
1672 /// For a throw it is called with: | 1672 /// For a throw it is called with: |
1673 /// | 1673 /// |
1674 /// - The error to complete the completer with. | 1674 /// - The error to complete the completer with. |
1675 /// - [error_codes.ERROR] | 1675 /// - [error_codes.ERROR] |
1676 /// - The completer object [completer] | 1676 /// - The completer object [completer] |
1677 final js.Expression asyncHelper; | 1677 final js.Expression asyncHelper; |
1678 | 1678 |
1679 /// Contructor used to initialize the [completer] variable. | 1679 /// Constructor used to initialize the [completer] variable. |
1680 /// | 1680 /// |
1681 /// Specific to async methods. | 1681 /// Specific to async methods. |
1682 final js.Expression newCompleter; | 1682 final js.Expression newCompleter; |
1683 | 1683 |
1684 final js.Expression wrapBody; | 1684 final js.Expression wrapBody; |
1685 | 1685 |
1686 AsyncRewriter(DiagnosticReporter reporter, Spannable spannable, | 1686 AsyncRewriter(DiagnosticReporter reporter, Spannable spannable, |
1687 {this.asyncHelper, | 1687 {this.asyncHelper, |
1688 this.newCompleter, | 1688 this.newCompleter, |
1689 this.wrapBody, | 1689 this.wrapBody, |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1792 "asyncHelper": asyncHelper, | 1792 "asyncHelper": asyncHelper, |
1793 "completer": completer, | 1793 "completer": completer, |
1794 "wrapBody": wrapBody, | 1794 "wrapBody": wrapBody, |
1795 }).withSourceInformation(sourceInformation); | 1795 }).withSourceInformation(sourceInformation); |
1796 } | 1796 } |
1797 } | 1797 } |
1798 | 1798 |
1799 class SyncStarRewriter extends AsyncRewriterBase { | 1799 class SyncStarRewriter extends AsyncRewriterBase { |
1800 bool get isSyncStar => true; | 1800 bool get isSyncStar => true; |
1801 | 1801 |
1802 /// Contructor creating the Iterable for a sync* method. Called with | 1802 /// Constructor creating the Iterable for a sync* method. Called with |
1803 /// [bodyName]. | 1803 /// [bodyName]. |
1804 final js.Expression newIterable; | 1804 final js.Expression newIterable; |
1805 | 1805 |
1806 /// A JS Expression that creates a marker showing that iteration is over. | 1806 /// A JS Expression that creates a marker showing that iteration is over. |
1807 /// | 1807 /// |
1808 /// Called without arguments. | 1808 /// Called without arguments. |
1809 final js.Expression endOfIteration; | 1809 final js.Expression endOfIteration; |
1810 | 1810 |
1811 /// A JS Expression that creates a marker indication a 'yield*' statement. | 1811 /// A JS Expression that creates a marker indication a 'yield*' statement. |
1812 /// | 1812 /// |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1959 /// - The controller object [controllerName] | 1959 /// - The controller object [controllerName] |
1960 /// | 1960 /// |
1961 /// For a return it is called with: | 1961 /// For a return it is called with: |
1962 /// | 1962 /// |
1963 /// - null | 1963 /// - null |
1964 /// - null | 1964 /// - null |
1965 /// - The [controllerName] | 1965 /// - The [controllerName] |
1966 /// - null. | 1966 /// - null. |
1967 final js.Expression asyncStarHelper; | 1967 final js.Expression asyncStarHelper; |
1968 | 1968 |
1969 /// Contructor used to initialize the [controllerName] variable. | 1969 /// Constructor used to initialize the [controllerName] variable. |
1970 /// | 1970 /// |
1971 /// Specific to async* methods. | 1971 /// Specific to async* methods. |
1972 final js.Expression newController; | 1972 final js.Expression newController; |
1973 | 1973 |
1974 /// Used to get the `Stream` out of the [controllerName] variable. | 1974 /// Used to get the `Stream` out of the [controllerName] variable. |
1975 final js.Expression streamOfController; | 1975 final js.Expression streamOfController; |
1976 | 1976 |
1977 /// A JS Expression that creates a marker indicating a 'yield' statement. | 1977 /// A JS Expression that creates a marker indicating a 'yield' statement. |
1978 /// | 1978 /// |
1979 /// Called with the value to yield. | 1979 /// Called with the value to yield. |
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2592 return condition || body; | 2592 return condition || body; |
2593 } | 2593 } |
2594 | 2594 |
2595 @override | 2595 @override |
2596 bool visitDartYield(js.DartYield node) { | 2596 bool visitDartYield(js.DartYield node) { |
2597 hasYield = true; | 2597 hasYield = true; |
2598 visit(node.expression); | 2598 visit(node.expression); |
2599 return true; | 2599 return true; |
2600 } | 2600 } |
2601 } | 2601 } |
OLD | NEW |