Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(258)

Side by Side Diff: dart/pkg/compiler/lib/src/compiler.dart

Issue 848003002: Remove CompilerCancelledException. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Merged with r42861 Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | dart/pkg/compiler/lib/src/use_unused_api.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 734 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 /// Incremental compilation is basically calling [run] more than once. 745 /// Incremental compilation is basically calling [run] more than once.
746 final bool hasIncrementalSupport; 746 final bool hasIncrementalSupport;
747 747
748 /// If `true` native extension syntax is supported by the frontend. 748 /// If `true` native extension syntax is supported by the frontend.
749 final bool allowNativeExtensions; 749 final bool allowNativeExtensions;
750 750
751 api.CompilerOutputProvider outputProvider; 751 api.CompilerOutputProvider outputProvider;
752 752
753 bool disableInlining = false; 753 bool disableInlining = false;
754 754
755 /// True if compilation was aborted with a [CompilerCancelledException]. Only
756 /// set after Future retuned by [run] has completed.
757 bool compilerWasCancelled = false;
758
759 List<Uri> librariesToAnalyzeWhenRun; 755 List<Uri> librariesToAnalyzeWhenRun;
760 756
761 Tracer tracer; 757 Tracer tracer;
762 758
763 CompilerTask measuredTask; 759 CompilerTask measuredTask;
764 Element _currentElement; 760 Element _currentElement;
765 LibraryElement coreLibrary; 761 LibraryElement coreLibrary;
766 762
767 LibraryElement mainApp; 763 LibraryElement mainApp;
768 FunctionElement mainFunction; 764 FunctionElement mainFunction;
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
859 _currentElement = element; 855 _currentElement = element;
860 try { 856 try {
861 return f(); 857 return f();
862 } on SpannableAssertionFailure catch (ex) { 858 } on SpannableAssertionFailure catch (ex) {
863 if (!hasCrashed) { 859 if (!hasCrashed) {
864 reportAssertionFailure(ex); 860 reportAssertionFailure(ex);
865 pleaseReportCrash(); 861 pleaseReportCrash();
866 } 862 }
867 hasCrashed = true; 863 hasCrashed = true;
868 rethrow; 864 rethrow;
869 } on CompilerCancelledException catch (ex) {
870 rethrow;
871 } on StackOverflowError catch (ex) { 865 } on StackOverflowError catch (ex) {
872 // We cannot report anything useful in this case, because we 866 // We cannot report anything useful in this case, because we
873 // do not have enough stack space. 867 // do not have enough stack space.
874 rethrow; 868 rethrow;
875 } catch (ex) { 869 } catch (ex) {
876 if (hasCrashed) rethrow; 870 if (hasCrashed) rethrow;
877 try { 871 try {
878 unhandledExceptionOnElement(element); 872 unhandledExceptionOnElement(element);
879 } catch (doubleFault) { 873 } catch (doubleFault) {
880 // Ignoring exceptions in exception handling. 874 // Ignoring exceptions in exception handling.
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
1155 void log(message) { 1149 void log(message) {
1156 reportDiagnostic(null, 1150 reportDiagnostic(null,
1157 MessageKind.GENERIC.message({'text': '$message'}), 1151 MessageKind.GENERIC.message({'text': '$message'}),
1158 api.Diagnostic.VERBOSE_INFO); 1152 api.Diagnostic.VERBOSE_INFO);
1159 } 1153 }
1160 1154
1161 Future<bool> run(Uri uri) { 1155 Future<bool> run(Uri uri) {
1162 totalCompileTime.start(); 1156 totalCompileTime.start();
1163 1157
1164 return new Future.sync(() => runCompiler(uri)).catchError((error) { 1158 return new Future.sync(() => runCompiler(uri)).catchError((error) {
1165 if (error is CompilerCancelledException) {
1166 compilerWasCancelled = true;
1167 log('Error: $error');
1168 return false;
1169 }
1170
1171 try { 1159 try {
1172 if (!hasCrashed) { 1160 if (!hasCrashed) {
1173 hasCrashed = true; 1161 hasCrashed = true;
1174 if (error is SpannableAssertionFailure) { 1162 if (error is SpannableAssertionFailure) {
1175 reportAssertionFailure(error); 1163 reportAssertionFailure(error);
1176 } else { 1164 } else {
1177 reportDiagnostic(new SourceSpan(uri, 0, 0), 1165 reportDiagnostic(new SourceSpan(uri, 0, 0),
1178 MessageKind.COMPILER_CRASHED.message(), 1166 MessageKind.COMPILER_CRASHED.message(),
1179 api.Diagnostic.CRASH); 1167 api.Diagnostic.CRASH);
1180 } 1168 }
(...skipping 941 matching lines...) Expand 10 before | Expand all | Expand 10 after
2122 if (previous != null) previous.watch.start(); 2110 if (previous != null) previous.watch.start();
2123 compiler.measuredTask = previous; 2111 compiler.measuredTask = previous;
2124 } 2112 }
2125 } 2113 }
2126 2114
2127 measureElement(Element element, action()) { 2115 measureElement(Element element, action()) {
2128 compiler.withCurrentElement(element, () => measure(action)); 2116 compiler.withCurrentElement(element, () => measure(action));
2129 } 2117 }
2130 } 2118 }
2131 2119
2132 /// Don't throw this error. It immediately aborts the compiler which causes the
2133 /// following problems:
2134 ///
2135 /// 1. No further errors and warnings are reported.
2136 /// 2. Breaks incremental compilation.
2137 class CompilerCancelledException extends Error {
2138 final String reason;
2139 CompilerCancelledException(this.reason);
2140
2141 String toString() {
2142 String banner = 'compiler cancelled';
2143 return (reason != null) ? '$banner: $reason' : '$banner';
2144 }
2145 }
2146
2147 class SourceSpan implements Spannable { 2120 class SourceSpan implements Spannable {
2148 final Uri uri; 2121 final Uri uri;
2149 final int begin; 2122 final int begin;
2150 final int end; 2123 final int end;
2151 2124
2152 const SourceSpan(this.uri, this.begin, this.end); 2125 const SourceSpan(this.uri, this.begin, this.end);
2153 2126
2154 static withCharacterOffsets(Token begin, Token end, 2127 static withCharacterOffsets(Token begin, Token end,
2155 f(int beginOffset, int endOffset)) { 2128 f(int beginOffset, int endOffset)) {
2156 final beginOffset = begin.charOffset; 2129 final beginOffset = begin.charOffset;
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
2383 InterfaceType get nullType => nullClass.computeType(compiler); 2356 InterfaceType get nullType => nullClass.computeType(compiler);
2384 2357
2385 @override 2358 @override
2386 InterfaceType get numType => numClass.computeType(compiler); 2359 InterfaceType get numType => numClass.computeType(compiler);
2387 2360
2388 @override 2361 @override
2389 InterfaceType get stringType => stringClass.computeType(compiler); 2362 InterfaceType get stringType => stringClass.computeType(compiler);
2390 } 2363 }
2391 2364
2392 typedef void InternalErrorFunction(Spannable location, String message); 2365 typedef void InternalErrorFunction(Spannable location, String message);
OLDNEW
« no previous file with comments | « no previous file | dart/pkg/compiler/lib/src/use_unused_api.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698