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 show Future, EventSink; | 8 show Future, EventSink; |
9 import 'dart:convert' show UTF8, LineSplitter; | 9 import 'dart:convert' show UTF8, LineSplitter; |
10 import 'dart:io' | 10 import 'dart:io' |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 List<String> options = new List<String>(); | 109 List<String> options = new List<String>(); |
110 bool explicitOut = false; | 110 bool explicitOut = false; |
111 bool wantHelp = false; | 111 bool wantHelp = false; |
112 bool wantVersion = false; | 112 bool wantVersion = false; |
113 String outputLanguage = 'JavaScript'; | 113 String outputLanguage = 'JavaScript'; |
114 bool stripArgumentSet = false; | 114 bool stripArgumentSet = false; |
115 bool analyzeOnly = false; | 115 bool analyzeOnly = false; |
116 bool analyzeAll = false; | 116 bool analyzeAll = false; |
117 bool enableAsyncAwait = false; | 117 bool enableAsyncAwait = false; |
118 bool trustTypeAnnotations = false; | 118 bool trustTypeAnnotations = false; |
| 119 bool trustPrimitives = false; |
119 bool checkedMode = false; | 120 bool checkedMode = false; |
120 // List of provided options that imply that output is expected. | 121 // List of provided options that imply that output is expected. |
121 List<String> optionsImplyCompilation = <String>[]; | 122 List<String> optionsImplyCompilation = <String>[]; |
122 bool hasDisallowUnsafeEval = false; | 123 bool hasDisallowUnsafeEval = false; |
123 // TODO(johnniwinther): Measure time for reading files. | 124 // TODO(johnniwinther): Measure time for reading files. |
124 SourceFileProvider inputProvider = new CompilerSourceFileProvider(); | 125 SourceFileProvider inputProvider = new CompilerSourceFileProvider(); |
125 diagnosticHandler = new FormattingDiagnosticHandler(inputProvider); | 126 diagnosticHandler = new FormattingDiagnosticHandler(inputProvider); |
126 Map<String, dynamic> environment = new Map<String, dynamic>(); | 127 Map<String, dynamic> environment = new Map<String, dynamic>(); |
127 | 128 |
128 passThrough(String argument) => options.add(argument); | 129 passThrough(String argument) => options.add(argument); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 implyCompilation(String argument) { | 204 implyCompilation(String argument) { |
204 optionsImplyCompilation.add(argument); | 205 optionsImplyCompilation.add(argument); |
205 passThrough(argument); | 206 passThrough(argument); |
206 } | 207 } |
207 | 208 |
208 setTrustTypeAnnotations(String argument) { | 209 setTrustTypeAnnotations(String argument) { |
209 trustTypeAnnotations = true; | 210 trustTypeAnnotations = true; |
210 implyCompilation(argument); | 211 implyCompilation(argument); |
211 } | 212 } |
212 | 213 |
| 214 setTrustPrimitives(String argument) { |
| 215 trustPrimitives = true; |
| 216 implyCompilation(argument); |
| 217 } |
| 218 |
213 setCheckedMode(String argument) { | 219 setCheckedMode(String argument) { |
214 checkedMode = true; | 220 checkedMode = true; |
215 passThrough(argument); | 221 passThrough(argument); |
216 } | 222 } |
217 | 223 |
218 addInEnvironment(String argument) { | 224 addInEnvironment(String argument) { |
219 int eqIndex = argument.indexOf('='); | 225 int eqIndex = argument.indexOf('='); |
220 String name = argument.substring(2, eqIndex); | 226 String name = argument.substring(2, eqIndex); |
221 String value = argument.substring(eqIndex + 1); | 227 String value = argument.substring(eqIndex + 1); |
222 environment[name] = value; | 228 environment[name] = value; |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 new OptionHandler('--enable-diagnostic-colors', | 308 new OptionHandler('--enable-diagnostic-colors', |
303 (_) => diagnosticHandler.enableColors = true), | 309 (_) => diagnosticHandler.enableColors = true), |
304 new OptionHandler('--enable[_-]checked[_-]mode|--checked', | 310 new OptionHandler('--enable[_-]checked[_-]mode|--checked', |
305 (_) => setCheckedMode('--enable-checked-mode')), | 311 (_) => setCheckedMode('--enable-checked-mode')), |
306 new OptionHandler('--enable-concrete-type-inference', | 312 new OptionHandler('--enable-concrete-type-inference', |
307 (_) => implyCompilation( | 313 (_) => implyCompilation( |
308 '--enable-concrete-type-inference')), | 314 '--enable-concrete-type-inference')), |
309 new OptionHandler('--trust-type-annotations', | 315 new OptionHandler('--trust-type-annotations', |
310 (_) => setTrustTypeAnnotations( | 316 (_) => setTrustTypeAnnotations( |
311 '--trust-type-annotations')), | 317 '--trust-type-annotations')), |
| 318 new OptionHandler('--trust-primitives', |
| 319 (_) => setTrustPrimitives( |
| 320 '--trust-primitives')), |
312 new OptionHandler(r'--help|/\?|/h', (_) => wantHelp = true), | 321 new OptionHandler(r'--help|/\?|/h', (_) => wantHelp = true), |
313 new OptionHandler('--package-root=.+|-p.+', setPackageRoot), | 322 new OptionHandler('--package-root=.+|-p.+', setPackageRoot), |
314 new OptionHandler('--analyze-all', setAnalyzeAll), | 323 new OptionHandler('--analyze-all', setAnalyzeAll), |
315 new OptionHandler('--analyze-only', setAnalyzeOnly), | 324 new OptionHandler('--analyze-only', setAnalyzeOnly), |
316 new OptionHandler('--analyze-signatures-only', setAnalyzeOnly), | 325 new OptionHandler('--analyze-signatures-only', setAnalyzeOnly), |
317 new OptionHandler('--disable-native-live-type-analysis', passThrough), | 326 new OptionHandler('--disable-native-live-type-analysis', passThrough), |
318 new OptionHandler('--categories=.*', setCategories), | 327 new OptionHandler('--categories=.*', setCategories), |
319 new OptionHandler('--disable-type-inference', implyCompilation), | 328 new OptionHandler('--disable-type-inference', implyCompilation), |
320 new OptionHandler('--terse', passThrough), | 329 new OptionHandler('--terse', passThrough), |
321 new OptionHandler('--dump-info', implyCompilation), | 330 new OptionHandler('--dump-info', implyCompilation), |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
679 } else if (exitCode == 253) { | 688 } else if (exitCode == 253) { |
680 print(">>> TEST CRASH"); | 689 print(">>> TEST CRASH"); |
681 } else { | 690 } else { |
682 print(">>> TEST FAIL"); | 691 print(">>> TEST FAIL"); |
683 } | 692 } |
684 stderr.writeln(">>> EOF STDERR"); | 693 stderr.writeln(">>> EOF STDERR"); |
685 subscription.resume(); | 694 subscription.resume(); |
686 }); | 695 }); |
687 }); | 696 }); |
688 } | 697 } |
OLD | NEW |