| 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 'batch_util.dart'; | 9 import 'batch_util.dart'; |
| 10 | 10 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 ..addFlag('tolerant', | 68 ..addFlag('tolerant', |
| 69 help: 'Generate kernel even if there are compile-time errors.', | 69 help: 'Generate kernel even if there are compile-time errors.', |
| 70 defaultsTo: false) | 70 defaultsTo: false) |
| 71 ..addOption('D', | 71 ..addOption('D', |
| 72 abbr: 'D', | 72 abbr: 'D', |
| 73 allowMultiple: true, | 73 allowMultiple: true, |
| 74 help: 'Define an environment variable.', | 74 help: 'Define an environment variable.', |
| 75 hide: true) | 75 hide: true) |
| 76 ..addFlag('show-external', | 76 ..addFlag('show-external', |
| 77 help: 'When printing a library as text, also print its dependencies\n' | 77 help: 'When printing a library as text, also print its dependencies\n' |
| 78 'on external libraries.'); | 78 'on external libraries.') |
| 79 ..addFlag('show-offsets', |
| 80 help: 'When printing a library as text, also print node offsets'); |
| 79 | 81 |
| 80 String getUsage() => """ | 82 String getUsage() => """ |
| 81 Usage: dartk [options] FILE | 83 Usage: dartk [options] FILE |
| 82 | 84 |
| 83 Convert .dart or .dill files to kernel's IR and print out its textual | 85 Convert .dart or .dill files to kernel's IR and print out its textual |
| 84 or binary form. | 86 or binary form. |
| 85 | 87 |
| 86 Examples: | 88 Examples: |
| 87 dartk foo.dart # print text IR for foo.dart | 89 dartk foo.dart # print text IR for foo.dart |
| 88 dartk foo.dart -ofoo.dill # write binary IR for foo.dart to foo.dill | 90 dartk foo.dart -ofoo.dill # write binary IR for foo.dart to foo.dill |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 return CompilerOutcome.Ok; | 371 return CompilerOutcome.Ok; |
| 370 } | 372 } |
| 371 | 373 |
| 372 watch.reset(); | 374 watch.reset(); |
| 373 | 375 |
| 374 Future ioFuture; | 376 Future ioFuture; |
| 375 if (canContinueCompilation) { | 377 if (canContinueCompilation) { |
| 376 switch (format) { | 378 switch (format) { |
| 377 case 'text': | 379 case 'text': |
| 378 writeProgramToText(program, | 380 writeProgramToText(program, |
| 379 path: outputFile, showExternal: options['show-external']); | 381 path: outputFile, |
| 382 showExternal: options['show-external'], |
| 383 showOffsets: options['show-offsets']); |
| 380 break; | 384 break; |
| 381 case 'bin': | 385 case 'bin': |
| 382 ioFuture = writeProgramToBinary(program, outputFile); | 386 ioFuture = writeProgramToBinary(program, outputFile); |
| 383 break; | 387 break; |
| 384 } | 388 } |
| 385 } | 389 } |
| 386 | 390 |
| 387 int time = watch.elapsedMilliseconds; | 391 int time = watch.elapsedMilliseconds; |
| 388 if (shouldReportMetrics) { | 392 if (shouldReportMetrics) { |
| 389 print('writer.time = $time ms'); | 393 print('writer.time = $time ms'); |
| 390 } | 394 } |
| 391 | 395 |
| 392 await ioFuture; | 396 await ioFuture; |
| 393 | 397 |
| 394 if (shouldReportMetrics) { | 398 if (shouldReportMetrics) { |
| 395 int flushTime = watch.elapsedMilliseconds - time; | 399 int flushTime = watch.elapsedMilliseconds - time; |
| 396 print('writer.flush_time = $flushTime ms'); | 400 print('writer.flush_time = $flushTime ms'); |
| 397 } | 401 } |
| 398 | 402 |
| 399 return errors.length > 0 ? CompilerOutcome.Fail : CompilerOutcome.Ok; | 403 return errors.length > 0 ? CompilerOutcome.Fail : CompilerOutcome.Ok; |
| 400 } | 404 } |
| OLD | NEW |