OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library dart2js.cmdline; | 5 library dart2js.cmdline; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:collection' show Queue, LinkedHashMap; | 8 import 'dart:collection' show Queue, LinkedHashMap; |
9 import 'dart:io'; | 9 import 'dart:io'; |
10 import 'dart:utf'; | 10 import 'dart:utf'; |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 break; | 216 break; |
217 default: | 217 default: |
218 throw 'Internal error: "$shortOption" did not match'; | 218 throw 'Internal error: "$shortOption" did not match'; |
219 } | 219 } |
220 } | 220 } |
221 } | 221 } |
222 | 222 |
223 List<String> arguments = <String>[]; | 223 List<String> arguments = <String>[]; |
224 List<OptionHandler> handlers = <OptionHandler>[ | 224 List<OptionHandler> handlers = <OptionHandler>[ |
225 new OptionHandler('-[chv?]+', handleShortOptions), | 225 new OptionHandler('-[chv?]+', handleShortOptions), |
226 new OptionHandler('--throw-on-error', | 226 new OptionHandler('--throw-on-error', passThrough), |
227 (_) => diagnosticHandler.throwOnError = true), | |
228 new OptionHandler('--suppress-warnings', | 227 new OptionHandler('--suppress-warnings', |
229 (_) => diagnosticHandler.showWarnings = false), | 228 (_) => diagnosticHandler.showWarnings = false), |
230 new OptionHandler('--suppress-hints', | 229 new OptionHandler('--suppress-hints', |
231 (_) => diagnosticHandler.showHints = false), | 230 (_) => diagnosticHandler.showHints = false), |
232 new OptionHandler('--output-type=dart|--output-type=js', setOutputType), | 231 new OptionHandler('--output-type=dart|--output-type=js', setOutputType), |
233 new OptionHandler('--verbose', setVerbose), | 232 new OptionHandler('--verbose', setVerbose), |
234 new OptionHandler('--version', (_) => wantVersion = true), | 233 new OptionHandler('--version', (_) => wantVersion = true), |
235 new OptionHandler('--library-root=.+', setLibraryRoot), | 234 new OptionHandler('--library-root=.+', setLibraryRoot), |
236 new OptionHandler('--out=.+|-o.*', setOutput, multipleArguments: true), | 235 new OptionHandler('--out=.+|-o.*', setOutput, multipleArguments: true), |
237 new OptionHandler('--allow-mock-compilation', passThrough), | 236 new OptionHandler('--allow-mock-compilation', passThrough), |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 void add(String value) { | 382 void add(String value) { |
384 sink.add(value); | 383 sink.add(value); |
385 count += value.length; | 384 count += value.length; |
386 } | 385 } |
387 | 386 |
388 void addError(Object error) { sink.addError(error); } | 387 void addError(Object error) { sink.addError(error); } |
389 | 388 |
390 void close() { sink.close(); } | 389 void close() { sink.close(); } |
391 } | 390 } |
392 | 391 |
393 class AbortLeg { | |
394 final message; | |
395 AbortLeg(this.message); | |
396 toString() => 'Aborted due to --throw-on-error: $message'; | |
397 } | |
398 | |
399 void writeString(Uri uri, String text) { | 392 void writeString(Uri uri, String text) { |
400 if (uri.scheme != 'file') { | 393 if (uri.scheme != 'file') { |
401 fail('Error: Unhandled scheme ${uri.scheme}.'); | 394 fail('Error: Unhandled scheme ${uri.scheme}.'); |
402 } | 395 } |
403 var file = new File(uriPathToNative(uri.path)).openSync(mode: FileMode.WRITE); | 396 var file = new File(uriPathToNative(uri.path)).openSync(mode: FileMode.WRITE); |
404 file.writeStringSync(text); | 397 file.writeStringSync(text); |
405 file.closeSync(); | 398 file.closeSync(); |
406 } | 399 } |
407 | 400 |
408 void fail(String message) { | 401 void fail(String message) { |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 print(trace); | 566 print(trace); |
574 } finally { | 567 } finally { |
575 exit(253); // 253 is recognized as a crash by our test scripts. | 568 exit(253); // 253 is recognized as a crash by our test scripts. |
576 } | 569 } |
577 } | 570 } |
578 } | 571 } |
579 | 572 |
580 void main() { | 573 void main() { |
581 mainWithErrorHandler(new Options()); | 574 mainWithErrorHandler(new Options()); |
582 } | 575 } |
OLD | NEW |