| 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/kernel.dart'; | 10 import 'package:kernel/kernel.dart'; |
| 11 import 'package:kernel/checks.dart' as checks; | 11 import 'package:kernel/checks.dart' as checks; |
| 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; | |
| 16 import 'package:kernel/transformations/treeshaker.dart' as treeshaker; | 15 import 'package:kernel/transformations/treeshaker.dart' as treeshaker; |
| 17 | 16 |
| 18 import 'batch_util.dart'; | 17 import 'batch_util.dart'; |
| 19 | 18 |
| 20 ArgParser parser = new ArgParser() | 19 ArgParser parser = new ArgParser() |
| 21 ..addOption('format', | 20 ..addOption('format', |
| 22 abbr: 'f', | 21 abbr: 'f', |
| 23 allowed: ['text', 'bin'], | 22 allowed: ['text', 'bin'], |
| 24 defaultsTo: 'bin', | 23 defaultsTo: 'bin', |
| 25 help: 'Output format.') | 24 help: 'Output format.') |
| 26 ..addOption('out', | 25 ..addOption('out', abbr: 'o', help: 'Output file.', defaultsTo: null) |
| 27 abbr: 'o', | |
| 28 help: 'Output file.', | |
| 29 defaultsTo: null) | |
| 30 ..addFlag('verbose', | 26 ..addFlag('verbose', |
| 31 abbr: 'v', | 27 abbr: 'v', |
| 32 negatable: false, | 28 negatable: false, |
| 33 help: 'Be verbose (e.g. prints transformed main library).', | 29 help: 'Be verbose (e.g. prints transformed main library).', |
| 34 defaultsTo: false) | 30 defaultsTo: false) |
| 35 ..addOption('transformation', | 31 ..addOption('transformation', |
| 36 abbr: 't', | 32 abbr: 't', |
| 37 help: 'The transformation to apply.', | 33 help: 'The transformation to apply.', |
| 38 defaultsTo: 'continuation'); | 34 defaultsTo: 'continuation'); |
| 39 | 35 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 69 switch (options['transformation']) { | 65 switch (options['transformation']) { |
| 70 case 'continuation': | 66 case 'continuation': |
| 71 program = cont.transformProgram(program); | 67 program = cont.transformProgram(program); |
| 72 break; | 68 break; |
| 73 case 'infervalues': | 69 case 'infervalues': |
| 74 program = infer_values.transformProgram(program); | 70 program = infer_values.transformProgram(program); |
| 75 break; | 71 break; |
| 76 case 'resolve-mixins': | 72 case 'resolve-mixins': |
| 77 program = mix.transformProgram(program); | 73 program = mix.transformProgram(program); |
| 78 break; | 74 break; |
| 79 case 'closures': | |
| 80 program = closures.transformProgram(program); | |
| 81 break; | |
| 82 case 'treeshake': | 75 case 'treeshake': |
| 83 program = treeshaker.transformProgram(program); | 76 program = treeshaker.transformProgram(program); |
| 84 break; | 77 break; |
| 85 default: throw 'Unknown transformation'; | 78 default: |
| 79 throw 'Unknown transformation'; |
| 86 } | 80 } |
| 87 | 81 |
| 88 program.accept(new checks.CheckParentPointers()); | 82 program.accept(new checks.CheckParentPointers()); |
| 89 | 83 |
| 90 if (format == 'text') { | 84 if (format == 'text') { |
| 91 writeProgramToText(program, path: output); | 85 writeProgramToText(program, path: output); |
| 92 } else { | 86 } else { |
| 93 assert(format == 'bin'); | 87 assert(format == 'bin'); |
| 94 await writeProgramToBinary(program, output); | 88 await writeProgramToBinary(program, output); |
| 95 } | 89 } |
| 96 | 90 |
| 97 if (verbose) { | 91 if (verbose) { |
| 98 writeLibraryToText(program.mainMethod.parent as Library); | 92 writeLibraryToText(program.mainMethod.parent as Library); |
| 99 } | 93 } |
| 100 | 94 |
| 101 return CompilerOutcome.Ok; | 95 return CompilerOutcome.Ok; |
| 102 } | 96 } |
| OLD | NEW |