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

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

Issue 1525593002: Introduce benign errors. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comments. Created 5 years 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
« no previous file with comments | « no previous file | tests/compiler/dart2js/benign_error_test.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 library dart2js.compiler_base; 5 library dart2js.compiler_base;
6 6
7 import 'dart:async' show 7 import 'dart:async' show
8 EventSink, 8 EventSink,
9 Future; 9 Future;
10 10
(...skipping 1232 matching lines...) Expand 10 before | Expand all | Expand 10 after
1243 } 1243 }
1244 1244
1245 void reportDiagnostic(DiagnosticMessage message, 1245 void reportDiagnostic(DiagnosticMessage message,
1246 List<DiagnosticMessage> infos, 1246 List<DiagnosticMessage> infos,
1247 api.Diagnostic kind); 1247 api.Diagnostic kind);
1248 1248
1249 void reportCrashInUserCode(String message, exception, stackTrace) { 1249 void reportCrashInUserCode(String message, exception, stackTrace) {
1250 _reporter.onCrashInUserCode(message, exception, stackTrace); 1250 _reporter.onCrashInUserCode(message, exception, stackTrace);
1251 } 1251 }
1252 1252
1253 /// Messages for which compile-time errors are reported but compilation
1254 /// continues regardless.
1255 static const List<MessageKind> BENIGN_ERRORS = const <MessageKind>[
1256 MessageKind.INVALID_METADATA,
1257 MessageKind.INVALID_METADATA_GENERIC,
1258 ];
1259
1260 bool markCompilationAsFailed(DiagnosticMessage message, api.Diagnostic kind) {
1261 if (testMode) {
1262 // When in test mode, i.e. on the build-bot, we always stop compilation.
1263 return true;
1264 }
1265 if (reporter.options.fatalWarnings) {
1266 return true;
1267 }
1268 return !BENIGN_ERRORS.contains(message.message.kind);
1269 }
1270
1271 void fatalDiagnosticReported(DiagnosticMessage message,
1272 List<DiagnosticMessage> infos,
1273 api.Diagnostic kind) {
1274 if (markCompilationAsFailed(message, kind)) {
1275 compilationFailed = true;
1276 }
1277 }
1278
1253 /** 1279 /**
1254 * Translates the [resolvedUri] into a readable URI. 1280 * Translates the [resolvedUri] into a readable URI.
1255 * 1281 *
1256 * The [importingLibrary] holds the library importing [resolvedUri] or 1282 * The [importingLibrary] holds the library importing [resolvedUri] or
1257 * [:null:] if [resolvedUri] is loaded as the main library. The 1283 * [:null:] if [resolvedUri] is loaded as the main library. The
1258 * [importingLibrary] is used to grant access to internal libraries from 1284 * [importingLibrary] is used to grant access to internal libraries from
1259 * platform libraries and patch libraries. 1285 * platform libraries and patch libraries.
1260 * 1286 *
1261 * If the [resolvedUri] is not accessible from [importingLibrary], this method 1287 * If the [resolvedUri] is not accessible from [importingLibrary], this method
1262 * is responsible for reporting errors. 1288 * is responsible for reporting errors.
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
1694 break; 1720 break;
1695 } 1721 }
1696 } 1722 }
1697 lastDiagnosticWasFiltered = false; 1723 lastDiagnosticWasFiltered = false;
1698 reportDiagnostic(message, infos, kind); 1724 reportDiagnostic(message, infos, kind);
1699 } 1725 }
1700 1726
1701 void reportDiagnostic(DiagnosticMessage message, 1727 void reportDiagnostic(DiagnosticMessage message,
1702 List<DiagnosticMessage> infos, 1728 List<DiagnosticMessage> infos,
1703 api.Diagnostic kind) { 1729 api.Diagnostic kind) {
1730 compiler.reportDiagnostic(message, infos, kind);
1704 if (kind == api.Diagnostic.ERROR || 1731 if (kind == api.Diagnostic.ERROR ||
1705 kind == api.Diagnostic.CRASH || 1732 kind == api.Diagnostic.CRASH ||
1706 (options.fatalWarnings && 1733 (options.fatalWarnings &&
1707 kind == api.Diagnostic.WARNING)) { 1734 kind == api.Diagnostic.WARNING)) {
1708 compiler.compilationFailed = true; 1735 compiler.fatalDiagnosticReported(message, infos, kind);
1709 } 1736 }
1710 compiler.reportDiagnostic(message, infos, kind);
1711 } 1737 }
1712 1738
1713 /** 1739 /**
1714 * Perform an operation, [f], returning the return value from [f]. If an 1740 * Perform an operation, [f], returning the return value from [f]. If an
1715 * error occurs then report it as having occurred during compilation of 1741 * error occurs then report it as having occurred during compilation of
1716 * [element]. Can be nested. 1742 * [element]. Can be nested.
1717 */ 1743 */
1718 withCurrentElement(Element element, f()) { 1744 withCurrentElement(Element element, f()) {
1719 Element old = currentElement; 1745 Element old = currentElement;
1720 _currentElement = element; 1746 _currentElement = element;
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
2098 if (_otherDependencies == null) { 2124 if (_otherDependencies == null) {
2099 _otherDependencies = new Setlet<Element>(); 2125 _otherDependencies = new Setlet<Element>();
2100 } 2126 }
2101 _otherDependencies.add(element.implementation); 2127 _otherDependencies.add(element.implementation);
2102 } 2128 }
2103 2129
2104 Iterable<Element> get otherDependencies { 2130 Iterable<Element> get otherDependencies {
2105 return _otherDependencies != null ? _otherDependencies : const <Element>[]; 2131 return _otherDependencies != null ? _otherDependencies : const <Element>[];
2106 } 2132 }
2107 } 2133 }
OLDNEW
« no previous file with comments | « no previous file | tests/compiler/dart2js/benign_error_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698