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'; |
11 import '../visitor.dart'; | 11 import '../visitor.dart'; |
12 | 12 |
13 import 'async.dart'; | 13 import 'async.dart'; |
14 | 14 |
15 void transformLibraries(CoreTypes coreTypes, List<Library> libraries) { | 15 void transformLibraries(CoreTypes coreTypes, List<Library> libraries) { |
16 var helper = new HelperNodes.fromCoreTypes(coreTypes); | 16 var helper = new HelperNodes.fromCoreTypes(coreTypes); |
17 var rewriter = new RecursiveContinuationRewriter(helper); | 17 var rewriter = new RecursiveContinuationRewriter(helper); |
18 for (var library in libraries) { | 18 for (var library in libraries) { |
19 rewriter.rewriteLibrary(library); | 19 rewriter.rewriteLibrary(library); |
20 } | 20 } |
21 } | 21 } |
22 | 22 |
23 Program transformProgram(Program program) { | 23 Program transformProgram(CoreTypes coreTypes, Program program) { |
24 var helper = new HelperNodes.fromProgram(program); | 24 var helper = new HelperNodes.fromCoreTypes(coreTypes); |
25 var rewriter = new RecursiveContinuationRewriter(helper); | 25 var rewriter = new RecursiveContinuationRewriter(helper); |
26 return rewriter.rewriteProgram(program); | 26 return rewriter.rewriteProgram(program); |
27 } | 27 } |
28 | 28 |
29 class RecursiveContinuationRewriter extends Transformer { | 29 class RecursiveContinuationRewriter extends Transformer { |
30 final HelperNodes helper; | 30 final HelperNodes helper; |
31 final VariableDeclaration asyncJumpVariable = new VariableDeclaration( | 31 final VariableDeclaration asyncJumpVariable = new VariableDeclaration( |
32 ":await_jump_var", | 32 ":await_jump_var", |
33 initializer: new IntLiteral(0)); | 33 initializer: new IntLiteral(0)); |
34 final VariableDeclaration asyncContextVariable = | 34 final VariableDeclaration asyncContextVariable = |
(...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
936 coreTypes.completerSyncConstructor, | 936 coreTypes.completerSyncConstructor, |
937 coreTypes.syncIterableDefaultConstructor, | 937 coreTypes.syncIterableDefaultConstructor, |
938 coreTypes.streamIteratorDefaultConstructor, | 938 coreTypes.streamIteratorDefaultConstructor, |
939 coreTypes.futureMicrotaskConstructor, | 939 coreTypes.futureMicrotaskConstructor, |
940 coreTypes.asyncStarStreamControllerDefaultConstructor, | 940 coreTypes.asyncStarStreamControllerDefaultConstructor, |
941 coreTypes.asyncThenWrapperHelperProcedure, | 941 coreTypes.asyncThenWrapperHelperProcedure, |
942 coreTypes.asyncErrorWrapperHelperProcedure, | 942 coreTypes.asyncErrorWrapperHelperProcedure, |
943 coreTypes.awaitHelperProcedure, | 943 coreTypes.awaitHelperProcedure, |
944 coreTypes); | 944 coreTypes); |
945 } | 945 } |
946 | |
947 factory HelperNodes.fromProgram(Program program) { | |
948 var coreTypes = new CoreTypes(program); | |
949 return new HelperNodes.fromCoreTypes(coreTypes); | |
950 } | |
951 } | 946 } |
OLD | NEW |