OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 leg_apiimpl; | 5 library leg_apiimpl; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import '../compiler.dart' as api; | 9 import '../compiler.dart' as api; |
10 import 'dart2jslib.dart' as leg; | 10 import 'dart2jslib.dart' as leg; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 analyzeOnly: hasOption(options, '--analyze-only'), | 50 analyzeOnly: hasOption(options, '--analyze-only'), |
51 analyzeSignaturesOnly: | 51 analyzeSignaturesOnly: |
52 hasOption(options, '--analyze-signatures-only'), | 52 hasOption(options, '--analyze-signatures-only'), |
53 strips: extractCsvOption(options, '--force-strip='), | 53 strips: extractCsvOption(options, '--force-strip='), |
54 enableConcreteTypeInference: | 54 enableConcreteTypeInference: |
55 hasOption(options, '--enable-concrete-type-inference'), | 55 hasOption(options, '--enable-concrete-type-inference'), |
56 disableTypeInferenceFlag: | 56 disableTypeInferenceFlag: |
57 hasOption(options, '--disable-type-inference'), | 57 hasOption(options, '--disable-type-inference'), |
58 preserveComments: hasOption(options, '--preserve-comments'), | 58 preserveComments: hasOption(options, '--preserve-comments'), |
59 verbose: hasOption(options, '--verbose'), | 59 verbose: hasOption(options, '--verbose'), |
60 sourceMapUri: extractSourceMapUri(options), | 60 sourceMapUri: extractUriOption(options, '--source-map='), |
| 61 outputUri: extractUriOption(options, '--out='), |
61 terseDiagnostics: hasOption(options, '--terse'), | 62 terseDiagnostics: hasOption(options, '--terse'), |
62 dumpInfo: hasOption(options, '--dump-info'), | 63 dumpInfo: hasOption(options, '--dump-info'), |
63 buildId: extractStringOption( | 64 buildId: extractStringOption( |
64 options, '--build-id=', | 65 options, '--build-id=', |
65 "build number could not be determined"), | 66 "build number could not be determined"), |
66 showPackageWarnings: | 67 showPackageWarnings: |
67 hasOption(options, '--show-package-warnings')) { | 68 hasOption(options, '--show-package-warnings')) { |
68 if (!libraryRoot.path.endsWith("/")) { | 69 if (!libraryRoot.path.endsWith("/")) { |
69 throw new ArgumentError("libraryRoot must end with a /"); | 70 throw new ArgumentError("libraryRoot must end with a /"); |
70 } | 71 } |
71 if (packageRoot != null && !packageRoot.path.endsWith("/")) { | 72 if (packageRoot != null && !packageRoot.path.endsWith("/")) { |
72 throw new ArgumentError("packageRoot must end with a /"); | 73 throw new ArgumentError("packageRoot must end with a /"); |
73 } | 74 } |
74 } | 75 } |
75 | 76 |
76 static String extractStringOption(List<String> options, | 77 static String extractStringOption(List<String> options, |
77 String prefix, | 78 String prefix, |
78 String defaultValue) { | 79 String defaultValue) { |
79 for (String option in options) { | 80 for (String option in options) { |
80 if (option.startsWith(prefix)) { | 81 if (option.startsWith(prefix)) { |
81 return option.substring(prefix.length); | 82 return option.substring(prefix.length); |
82 } | 83 } |
83 } | 84 } |
84 return defaultValue; | 85 return defaultValue; |
85 } | 86 } |
86 | 87 |
87 static Uri extractSourceMapUri(List<String> options) { | 88 static Uri extractUriOption(List<String> options, String prefix) { |
88 var option = extractStringOption(options, '--source-map=', null); | 89 var option = extractStringOption(options, prefix, null); |
89 return (option == null) ? null : Uri.parse(option); | 90 return (option == null) ? null : Uri.parse(option); |
90 } | 91 } |
91 | 92 |
92 // CSV: Comma separated values. | 93 // CSV: Comma separated values. |
93 static List<String> extractCsvOption(List<String> options, String prefix) { | 94 static List<String> extractCsvOption(List<String> options, String prefix) { |
94 for (String option in options) { | 95 for (String option in options) { |
95 if (option.startsWith(prefix)) { | 96 if (option.startsWith(prefix)) { |
96 return option.substring(prefix.length).split(','); | 97 return option.substring(prefix.length).split(','); |
97 } | 98 } |
98 } | 99 } |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 } | 332 } |
332 | 333 |
333 void diagnoseCrashInUserCode(String message, exception, stackTrace) { | 334 void diagnoseCrashInUserCode(String message, exception, stackTrace) { |
334 hasCrashed = true; | 335 hasCrashed = true; |
335 print('$message: ${tryToString(exception)}'); | 336 print('$message: ${tryToString(exception)}'); |
336 print(tryToString(stackTrace)); | 337 print(tryToString(stackTrace)); |
337 } | 338 } |
338 | 339 |
339 fromEnvironment(String name) => environment[name]; | 340 fromEnvironment(String name) => environment[name]; |
340 } | 341 } |
OLD | NEW |