OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 /// Command line tool to run the checker on a Dart program. | 5 /// Command line tool to run the checker on a Dart program. |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:collection'; | 8 import 'dart:collection'; |
9 import 'dart:convert' show JSON; | 9 import 'dart:convert' show JSON; |
10 import 'dart:math' as math; | 10 import 'dart:math' as math; |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 return options.htmlReport | 482 return options.htmlReport |
483 ? new HtmlReporter(context) | 483 ? new HtmlReporter(context) |
484 : options.dumpInfo | 484 : options.dumpInfo |
485 ? new SummaryReporter(context, options.logLevel) | 485 ? new SummaryReporter(context, options.logLevel) |
486 : new LogReporter(context, useColors: options.useColors); | 486 : new LogReporter(context, useColors: options.useColors); |
487 } | 487 } |
488 | 488 |
489 // TODO(jmesserly): find a better home for these. | 489 // TODO(jmesserly): find a better home for these. |
490 /// Curated order to minimize lazy classes needed by dart:core and its | 490 /// Curated order to minimize lazy classes needed by dart:core and its |
491 /// transitive SDK imports. | 491 /// transitive SDK imports. |
492 const corelibOrder = const [ | 492 final corelibOrder = [ |
493 'dart.core', | 493 'dart:core', |
494 'dart.collection', | 494 'dart:collection', |
495 'dart._internal', | 495 'dart:_internal', |
496 'dart.math', | 496 'dart:math', |
497 'dart._interceptors', | 497 'dart:_interceptors', |
498 'dart.async', | 498 'dart:async', |
499 'dart._foreign_helper', | 499 'dart:_foreign_helper', |
500 'dart._js_embedded_names', | 500 'dart:_js_embedded_names', |
501 'dart._js_helper', | 501 'dart:_js_helper', |
502 'dart.isolate', | 502 'dart:isolate', |
503 'dart.typed_data', | 503 'dart:typed_data', |
504 'dart._native_typed_data', | 504 'dart:_native_typed_data', |
505 'dart._isolate_helper', | 505 'dart:_isolate_helper', |
506 'dart._js_primitives', | 506 'dart:_js_primitives', |
507 'dart.convert', | 507 'dart:convert', |
508 // TODO(jmesserly): these are not part of corelib library cycle, and shouldn't | 508 // TODO(jmesserly): these are not part of corelib library cycle, and shouldn't |
509 // be listed here. Instead, their source should be copied on demand if they | 509 // be listed here. Instead, their source should be copied on demand if they |
510 // are actually used by the application. | 510 // are actually used by the application. |
511 'dart.mirrors', | 511 'dart:mirrors', |
512 'dart._js_mirrors', | 512 'dart:_js_mirrors', |
513 'dart.js', | 513 'dart:js', |
514 'dart._metadata', | 514 'dart:_metadata', |
515 'dart.dom.html', | 515 'dart:html', |
516 'dart.dom.html_common', | 516 'dart:html_common', |
517 'dart._debugger' | 517 'dart:_debugger' |
518 // _foreign_helper is not included, as it only defines the JS builtin that | 518 // _foreign_helper is not included, as it only defines the JS builtin that |
519 // the compiler handles at compile time. | 519 // the compiler handles at compile time. |
520 ]; | 520 ].map(Uri.parse).toList(); |
521 | |
522 /// Returns the JS module name corresponding to a core library name (must be | |
523 /// from the [corelibOrder] list). | |
524 String getCorelibModuleName(String lib) { | |
525 assert(corelibOrder.contains(lib)); | |
526 switch (lib) { | |
527 case 'dart.dom.html_common': | |
528 return 'dart/html_common'; | |
529 case 'dart.dom.html': | |
530 return 'dart/html'; | |
531 default: | |
532 return lib.replaceAll('dart.', 'dart/'); | |
533 } | |
534 } | |
535 | 521 |
536 /// Runtime files added to all applications when running the compiler in the | 522 /// Runtime files added to all applications when running the compiler in the |
537 /// command line. | 523 /// command line. |
538 final defaultRuntimeFiles = () { | 524 final defaultRuntimeFiles = () { |
539 String coreToFile(String name) { | 525 String coreToFile(Uri uri) => uri.toString().replaceAll(':', '/') + '.js'; |
540 var parts = name.split('.'); | |
541 var length = parts.length; | |
542 if (length > 1) { | |
543 name = parts[0] + '/' + parts[length - 1]; | |
544 } | |
545 return name + '.js'; | |
546 } | |
547 | 526 |
548 var files = [ | 527 var files = [ |
549 'harmony_feature_check.js', | 528 'harmony_feature_check.js', |
550 'dart_library.js', | 529 'dart_library.js', |
551 'dart/_runtime.js', | 530 'dart/_runtime.js', |
552 ]; | 531 ]; |
553 files.addAll(corelibOrder.map(coreToFile)); | 532 files.addAll(corelibOrder.map(coreToFile)); |
554 return files; | 533 return files; |
555 }(); | 534 }(); |
556 | 535 |
557 final _log = new Logger('dev_compiler.src.compiler'); | 536 final _log = new Logger('dev_compiler.src.compiler'); |
OLD | NEW |