OLD | NEW |
1 #!/usr/bin/env dart | 1 #!/usr/bin/env dart |
2 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 2 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
3 // for details. All rights reserved. Use of this source code is governed by a | 3 // for details. All rights reserved. Use of this source code is governed by a |
4 // BSD-style license that can be found in the LICENSE file. | 4 // BSD-style license that can be found in the LICENSE file. |
5 | 5 |
6 import 'dart:async'; | 6 import 'dart:async'; |
7 import 'dart:io'; | 7 import 'dart:io'; |
8 | 8 |
9 import 'package:args/args.dart'; | 9 import 'package:args/args.dart'; |
10 import 'package:kernel/verifier.dart'; | 10 import 'package:kernel/verifier.dart'; |
11 import 'package:kernel/kernel.dart'; | 11 import 'package:kernel/kernel.dart'; |
12 import 'package:kernel/transformations/continuation.dart' as cont; | 12 import 'package:kernel/transformations/continuation.dart' as cont; |
13 import 'package:kernel/transformations/infer_values.dart' as infer_values; | 13 import 'package:kernel/transformations/infer_values.dart' as infer_values; |
14 import 'package:kernel/transformations/mixin_full_resolution.dart' as mix; | 14 import 'package:kernel/transformations/mixin_full_resolution.dart' as mix; |
| 15 import 'package:kernel/transformations/closure_conversion.dart' as closures; |
15 import 'package:kernel/transformations/treeshaker.dart' as treeshaker; | 16 import 'package:kernel/transformations/treeshaker.dart' as treeshaker; |
16 | 17 |
17 import 'batch_util.dart'; | 18 import 'batch_util.dart'; |
18 | 19 |
19 ArgParser parser = new ArgParser() | 20 ArgParser parser = new ArgParser() |
20 ..addOption('format', | 21 ..addOption('format', |
21 abbr: 'f', | 22 abbr: 'f', |
22 allowed: ['text', 'bin'], | 23 allowed: ['text', 'bin'], |
23 defaultsTo: 'bin', | 24 defaultsTo: 'bin', |
24 help: 'Output format.') | 25 help: 'Output format.') |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 switch (options['transformation']) { | 66 switch (options['transformation']) { |
66 case 'continuation': | 67 case 'continuation': |
67 program = cont.transformProgram(program); | 68 program = cont.transformProgram(program); |
68 break; | 69 break; |
69 case 'infervalues': | 70 case 'infervalues': |
70 program = infer_values.transformProgram(program); | 71 program = infer_values.transformProgram(program); |
71 break; | 72 break; |
72 case 'resolve-mixins': | 73 case 'resolve-mixins': |
73 program = mix.transformProgram(program); | 74 program = mix.transformProgram(program); |
74 break; | 75 break; |
| 76 case 'closures': |
| 77 program = closures.transformProgram(program); |
| 78 break; |
75 case 'treeshake': | 79 case 'treeshake': |
76 program = treeshaker.transformProgram(program); | 80 program = treeshaker.transformProgram(program); |
77 break; | 81 break; |
78 default: | 82 default: |
79 throw 'Unknown transformation'; | 83 throw 'Unknown transformation'; |
80 } | 84 } |
81 | 85 |
82 verifyProgram(program); | 86 verifyProgram(program); |
83 | 87 |
84 if (format == 'text') { | 88 if (format == 'text') { |
85 writeProgramToText(program, path: output); | 89 writeProgramToText(program, path: output); |
86 } else { | 90 } else { |
87 assert(format == 'bin'); | 91 assert(format == 'bin'); |
88 await writeProgramToBinary(program, output); | 92 await writeProgramToBinary(program, output); |
89 } | 93 } |
90 | 94 |
91 if (verbose) { | 95 if (verbose) { |
92 writeLibraryToText(program.mainMethod.parent as Library); | 96 writeLibraryToText(program.mainMethod.parent as Library); |
93 } | 97 } |
94 | 98 |
95 return CompilerOutcome.Ok; | 99 return CompilerOutcome.Ok; |
96 } | 100 } |
OLD | NEW |