| 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'); | |
| 81 | 79 |
| 82 String getUsage() => """ | 80 String getUsage() => """ |
| 83 Usage: dartk [options] FILE | 81 Usage: dartk [options] FILE |
| 84 | 82 |
| 85 Convert .dart or .dill files to kernel's IR and print out its textual | 83 Convert .dart or .dill files to kernel's IR and print out its textual |
| 86 or binary form. | 84 or binary form. |
| 87 | 85 |
| 88 Examples: | 86 Examples: |
| 89 dartk foo.dart # print text IR for foo.dart | 87 dartk foo.dart # print text IR for foo.dart |
| 90 dartk foo.dart -ofoo.dill # write binary IR for foo.dart to foo.dill | 88 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... |
| 371 return CompilerOutcome.Ok; | 369 return CompilerOutcome.Ok; |
| 372 } | 370 } |
| 373 | 371 |
| 374 watch.reset(); | 372 watch.reset(); |
| 375 | 373 |
| 376 Future ioFuture; | 374 Future ioFuture; |
| 377 if (canContinueCompilation) { | 375 if (canContinueCompilation) { |
| 378 switch (format) { | 376 switch (format) { |
| 379 case 'text': | 377 case 'text': |
| 380 writeProgramToText(program, | 378 writeProgramToText(program, |
| 381 path: outputFile, | 379 path: outputFile, showExternal: options['show-external']); |
| 382 showExternal: options['show-external'], | |
| 383 showOffsets: options['show-offsets']); | |
| 384 break; | 380 break; |
| 385 case 'bin': | 381 case 'bin': |
| 386 ioFuture = writeProgramToBinary(program, outputFile); | 382 ioFuture = writeProgramToBinary(program, outputFile); |
| 387 break; | 383 break; |
| 388 } | 384 } |
| 389 } | 385 } |
| 390 | 386 |
| 391 int time = watch.elapsedMilliseconds; | 387 int time = watch.elapsedMilliseconds; |
| 392 if (shouldReportMetrics) { | 388 if (shouldReportMetrics) { |
| 393 print('writer.time = $time ms'); | 389 print('writer.time = $time ms'); |
| 394 } | 390 } |
| 395 | 391 |
| 396 await ioFuture; | 392 await ioFuture; |
| 397 | 393 |
| 398 if (shouldReportMetrics) { | 394 if (shouldReportMetrics) { |
| 399 int flushTime = watch.elapsedMilliseconds - time; | 395 int flushTime = watch.elapsedMilliseconds - time; |
| 400 print('writer.flush_time = $flushTime ms'); | 396 print('writer.flush_time = $flushTime ms'); |
| 401 } | 397 } |
| 402 | 398 |
| 403 return errors.length > 0 ? CompilerOutcome.Fail : CompilerOutcome.Ok; | 399 return errors.length > 0 ? CompilerOutcome.Fail : CompilerOutcome.Ok; |
| 404 } | 400 } |
| OLD | NEW |