| 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; | 5 library dart2js; |
| 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:uri'; | 10 import 'dart:uri'; |
| 11 import 'dart:utf'; | 11 import 'dart:utf'; |
| 12 | 12 |
| 13 import '../compiler.dart' as api; | 13 import '../compiler.dart' as api; |
| 14 import 'source_file.dart'; | 14 import 'source_file.dart'; |
| 15 import 'source_file_provider.dart'; | 15 import 'source_file_provider.dart'; |
| 16 import 'filenames.dart'; | 16 import 'filenames.dart'; |
| 17 import 'util/uri_extras.dart'; | 17 import 'util/uri_extras.dart'; |
| 18 import '../../libraries.dart'; | 18 import '../../libraries.dart'; |
| 19 | 19 |
| 20 const String LIBRARY_ROOT = '../../../../..'; | 20 const String LIBRARY_ROOT = '../../../../..'; |
| 21 const String OUTPUT_LANGUAGE_DART = 'Dart'; | 21 const String OUTPUT_LANGUAGE_DART = 'Dart'; |
| 22 | 22 |
| 23 /** |
| 24 * A string to identify the revision or build. |
| 25 * |
| 26 * This ID is displayed if the compiler crashes and in verbose mode, and is |
| 27 * an aid in reproducing bug reports. |
| 28 * |
| 29 * The actual string is rewritten by a wrapper script when included in the sdk. |
| 30 */ |
| 31 String BUILD_ID = null; |
| 32 |
| 23 typedef void HandleOption(String option); | 33 typedef void HandleOption(String option); |
| 24 | 34 |
| 25 class OptionHandler { | 35 class OptionHandler { |
| 26 String pattern; | 36 String pattern; |
| 27 HandleOption handle; | 37 HandleOption handle; |
| 28 | 38 |
| 29 OptionHandler(this.pattern, this.handle); | 39 OptionHandler(this.pattern, this.handle); |
| 30 } | 40 } |
| 31 | 41 |
| 32 /** | 42 /** |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 bool wantHelp = false; | 90 bool wantHelp = false; |
| 81 String outputLanguage = 'JavaScript'; | 91 String outputLanguage = 'JavaScript'; |
| 82 bool stripArgumentSet = false; | 92 bool stripArgumentSet = false; |
| 83 bool analyzeOnly = false; | 93 bool analyzeOnly = false; |
| 84 SourceFileProvider inputProvider = new SourceFileProvider(); | 94 SourceFileProvider inputProvider = new SourceFileProvider(); |
| 85 FormattingDiagnosticHandler diagnosticHandler = | 95 FormattingDiagnosticHandler diagnosticHandler = |
| 86 new FormattingDiagnosticHandler(inputProvider); | 96 new FormattingDiagnosticHandler(inputProvider); |
| 87 | 97 |
| 88 passThrough(String argument) => options.add(argument); | 98 passThrough(String argument) => options.add(argument); |
| 89 | 99 |
| 100 if (BUILD_ID != null) { |
| 101 passThrough("--build-id=$BUILD_ID"); |
| 102 } |
| 103 |
| 90 setLibraryRoot(String argument) { | 104 setLibraryRoot(String argument) { |
| 91 libraryRoot = cwd.resolve(extractPath(argument)); | 105 libraryRoot = cwd.resolve(extractPath(argument)); |
| 92 } | 106 } |
| 93 | 107 |
| 94 setPackageRoot(String argument) { | 108 setPackageRoot(String argument) { |
| 95 packageRoot = cwd.resolve(extractPath(argument)); | 109 packageRoot = cwd.resolve(extractPath(argument)); |
| 96 } | 110 } |
| 97 | 111 |
| 98 setOutput(String argument) { | 112 setOutput(String argument) { |
| 99 explicitOut = true; | 113 explicitOut = true; |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 } | 493 } |
| 480 exit(0); | 494 exit(0); |
| 481 } | 495 } |
| 482 | 496 |
| 483 void helpAndFail(String message) { | 497 void helpAndFail(String message) { |
| 484 help(); | 498 help(); |
| 485 print(''); | 499 print(''); |
| 486 fail(message); | 500 fail(message); |
| 487 } | 501 } |
| 488 | 502 |
| 489 void main() { | 503 void mainWithErrorHandler(Options options) { |
| 490 try { | 504 try { |
| 491 compilerMain(new Options()); | 505 compilerMain(options); |
| 492 } catch (exception, trace) { | 506 } catch (exception, trace) { |
| 493 try { | 507 try { |
| 494 print('Internal error: $exception'); | 508 print('Internal error: $exception'); |
| 495 } catch (ignored) { | 509 } catch (ignored) { |
| 496 print('Internal error: error while printing exception'); | 510 print('Internal error: error while printing exception'); |
| 497 } | 511 } |
| 498 try { | 512 try { |
| 499 print(trace); | 513 print(trace); |
| 500 } finally { | 514 } finally { |
| 501 exit(253); // 253 is recognized as a crash by our test scripts. | 515 exit(253); // 253 is recognized as a crash by our test scripts. |
| 502 } | 516 } |
| 503 } | 517 } |
| 504 } | 518 } |
| 519 |
| 520 void main() { |
| 521 mainWithErrorHandler(new Options()); |
| 522 } |
| OLD | NEW |