Chromium Code Reviews| 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/closure_conversion.dart' as closures; |
| 16 import 'package:kernel/transformations/treeshaker.dart' as treeshaker; | 16 import 'package:kernel/transformations/treeshaker.dart' as treeshaker; |
| 17 import 'package:kernel/transformations/method_call.dart' as method_call; | |
| 18 import 'package:kernel/transformations/empty.dart' as empty; | |
|
kustermann
2017/02/14 15:21:23
nit: sort?
jensj
2017/02/15 11:46:21
Done.
| |
| 17 | 19 |
| 18 import 'util.dart'; | 20 import 'util.dart'; |
| 19 import 'batch_util.dart'; | 21 import 'batch_util.dart'; |
| 20 | 22 |
| 21 ArgParser parser = new ArgParser() | 23 ArgParser parser = new ArgParser() |
| 22 ..addOption('format', | 24 ..addOption('format', |
| 23 abbr: 'f', | 25 abbr: 'f', |
| 24 allowed: ['text', 'bin'], | 26 allowed: ['text', 'bin'], |
| 25 defaultsTo: 'bin', | 27 defaultsTo: 'bin', |
| 26 help: 'Output format.') | 28 help: 'Output format.') |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 83 case 'resolve-mixins': | 85 case 'resolve-mixins': |
| 84 program = mix.transformProgram(program); | 86 program = mix.transformProgram(program); |
| 85 break; | 87 break; |
| 86 case 'closures': | 88 case 'closures': |
| 87 program = closures.transformProgram(program); | 89 program = closures.transformProgram(program); |
| 88 break; | 90 break; |
| 89 case 'treeshake': | 91 case 'treeshake': |
| 90 program = | 92 program = |
| 91 treeshaker.transformProgram(program, programRoots: programRoots); | 93 treeshaker.transformProgram(program, programRoots: programRoots); |
| 92 break; | 94 break; |
| 95 case 'methodcall': | |
| 96 program = method_call.transformProgram(program); | |
| 97 break; | |
| 98 case 'empty': | |
| 99 program = empty.transformProgram(program); | |
| 100 break; | |
| 93 default: | 101 default: |
| 94 throw 'Unknown transformation'; | 102 throw 'Unknown transformation'; |
| 95 } | 103 } |
| 96 | 104 |
| 97 verifyProgram(program); | 105 verifyProgram(program); |
| 98 | 106 |
| 99 if (format == 'text') { | 107 if (format == 'text') { |
| 100 writeProgramToText(program, path: output); | 108 writeProgramToText(program, path: output); |
| 101 } else { | 109 } else { |
| 102 assert(format == 'bin'); | 110 assert(format == 'bin'); |
| 103 await writeProgramToBinary(program, output); | 111 await writeProgramToBinary(program, output); |
| 104 } | 112 } |
| 105 | 113 |
| 106 if (verbose) { | 114 if (verbose) { |
| 107 writeLibraryToText(program.mainMethod.parent as Library); | 115 writeLibraryToText(program.mainMethod.parent as Library); |
| 108 } | 116 } |
| 109 | 117 |
| 110 return CompilerOutcome.Ok; | 118 return CompilerOutcome.Ok; |
| 111 } | 119 } |
| OLD | NEW |