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 part of dart2js; | 5 part of dart2js; |
6 | 6 |
7 /** | 7 /** |
8 * If true, print a warning for each method that was resolved, but not | 8 * If true, print a warning for each method that was resolved, but not |
9 * compiled. | 9 * compiled. |
10 */ | 10 */ |
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 return f(); | 506 return f(); |
507 } on SpannableAssertionFailure catch (ex, s) { | 507 } on SpannableAssertionFailure catch (ex, s) { |
508 if (!hasCrashed) { | 508 if (!hasCrashed) { |
509 String message = (ex.message != null) ? tryToString(ex.message) | 509 String message = (ex.message != null) ? tryToString(ex.message) |
510 : tryToString(ex); | 510 : tryToString(ex); |
511 SourceSpan span = spanFromSpannable(ex.node); | 511 SourceSpan span = spanFromSpannable(ex.node); |
512 reportError(ex.node, MessageKind.GENERIC, {'text': message}); | 512 reportError(ex.node, MessageKind.GENERIC, {'text': message}); |
513 pleaseReportCrash(s, 'The compiler crashed: $message.'); | 513 pleaseReportCrash(s, 'The compiler crashed: $message.'); |
514 } | 514 } |
515 hasCrashed = true; | 515 hasCrashed = true; |
516 throw new CompilerCancelledException('The compiler crashed.'); | 516 rethrow; |
517 } on CompilerCancelledException catch (ex) { | 517 } on CompilerCancelledException catch (ex) { |
518 rethrow; | 518 rethrow; |
519 } on StackOverflowError catch (ex) { | 519 } on StackOverflowError catch (ex) { |
520 // We cannot report anything useful in this case, because we | 520 // We cannot report anything useful in this case, because we |
521 // do not have enough stack space. | 521 // do not have enough stack space. |
522 rethrow; | 522 rethrow; |
523 } catch (ex, s) { | 523 } catch (ex, s) { |
524 if (hasCrashed) rethrow; | 524 if (hasCrashed) rethrow; |
525 String message = 'The compiler crashed: ${tryToString(ex)}.'; | 525 String message = 'The compiler crashed: ${tryToString(ex)}.'; |
526 try { | 526 try { |
527 unhandledExceptionOnElement(element, s, message); | 527 unhandledExceptionOnElement(element, s, message); |
528 } catch (doubleFault) { | 528 } catch (doubleFault) { |
529 // Ignoring exceptions in exception handling. | 529 // Ignoring exceptions in exception handling. |
530 } | 530 } |
531 throw new CompilerCancelledException(message); | 531 rethrow; |
532 } finally { | 532 } finally { |
533 _currentElement = old; | 533 _currentElement = old; |
534 } | 534 } |
535 } | 535 } |
536 | 536 |
537 List<CompilerTask> tasks; | 537 List<CompilerTask> tasks; |
538 ScannerTask scanner; | 538 ScannerTask scanner; |
539 DietParserTask dietParser; | 539 DietParserTask dietParser; |
540 ParserTask parser; | 540 ParserTask parser; |
541 PatchParserTask patchParser; | 541 PatchParserTask patchParser; |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
708 if (hasCrashed) return; | 708 if (hasCrashed) return; |
709 hasCrashed = true; | 709 hasCrashed = true; |
710 reportDiagnostic(spanFromElement(element), | 710 reportDiagnostic(spanFromElement(element), |
711 MessageKind.COMPILER_CRASHED.error().toString(), | 711 MessageKind.COMPILER_CRASHED.error().toString(), |
712 api.Diagnostic.CRASH); | 712 api.Diagnostic.CRASH); |
713 pleaseReportCrash(stackTrace, message); | 713 pleaseReportCrash(stackTrace, message); |
714 } | 714 } |
715 | 715 |
716 void pleaseReportCrash(StackTrace stackTrace, String message) { | 716 void pleaseReportCrash(StackTrace stackTrace, String message) { |
717 print(MessageKind.PLEASE_REPORT_THE_CRASH.message({'buildId': buildId})); | 717 print(MessageKind.PLEASE_REPORT_THE_CRASH.message({'buildId': buildId})); |
718 if (message != null) { | |
719 print(message); | |
720 } | |
721 if (stackTrace != null) { | |
722 print(stackTrace); | |
723 } | |
724 } | 718 } |
725 | 719 |
726 void cancel(String reason, {Node node, Token token, | 720 void cancel(String reason, {Node node, Token token, |
727 HInstruction instruction, Element element}) { | 721 HInstruction instruction, Element element}) { |
728 assembledCode = null; // Compilation failed. Make sure that we | 722 assembledCode = null; // Compilation failed. Make sure that we |
729 // don't return a bogus result. | 723 // don't return a bogus result. |
730 Spannable spannable = null; | 724 Spannable spannable = null; |
731 if (node != null) { | 725 if (node != null) { |
732 spannable = node; | 726 spannable = node; |
733 } else if (token != null) { | 727 } else if (token != null) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
768 } | 762 } |
769 | 763 |
770 void log(message) { | 764 void log(message) { |
771 reportDiagnostic(null, message, api.Diagnostic.VERBOSE_INFO); | 765 reportDiagnostic(null, message, api.Diagnostic.VERBOSE_INFO); |
772 } | 766 } |
773 | 767 |
774 Future<bool> run(Uri uri) { | 768 Future<bool> run(Uri uri) { |
775 totalCompileTime.start(); | 769 totalCompileTime.start(); |
776 | 770 |
777 return new Future.sync(() => runCompiler(uri)).catchError((error, trace) { | 771 return new Future.sync(() => runCompiler(uri)).catchError((error, trace) { |
778 if (error is CompilerCancelledException) { | 772 if (!hasCrashed && error is CompilerCancelledException) { |
779 log('Error: $error'); | 773 log('Error: $error'); |
780 return false; | 774 return false; |
781 } | 775 } |
782 | 776 |
783 try { | 777 try { |
784 if (!hasCrashed) { | 778 if (!hasCrashed) { |
785 hasCrashed = true; | 779 hasCrashed = true; |
786 reportDiagnostic(new SourceSpan(uri, 0, 0), | 780 reportDiagnostic(new SourceSpan(uri, 0, 0), |
787 MessageKind.COMPILER_CRASHED.error().toString(), | 781 MessageKind.COMPILER_CRASHED.error().toString(), |
788 api.Diagnostic.CRASH); | 782 api.Diagnostic.CRASH); |
(...skipping 867 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1656 | 1650 |
1657 void close() {} | 1651 void close() {} |
1658 | 1652 |
1659 toString() => name; | 1653 toString() => name; |
1660 | 1654 |
1661 /// Convenience method for getting an [api.CompilerOutputProvider]. | 1655 /// Convenience method for getting an [api.CompilerOutputProvider]. |
1662 static NullSink outputProvider(String name, String extension) { | 1656 static NullSink outputProvider(String name, String extension) { |
1663 return new NullSink('$name.$extension'); | 1657 return new NullSink('$name.$extension'); |
1664 } | 1658 } |
1665 } | 1659 } |
OLD | NEW |