| 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 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 * error occurs then report it as having occurred during compilation of | 492 * error occurs then report it as having occurred during compilation of |
| 493 * [element]. Can be nested. | 493 * [element]. Can be nested. |
| 494 */ | 494 */ |
| 495 withCurrentElement(Element element, f()) { | 495 withCurrentElement(Element element, f()) { |
| 496 Element old = currentElement; | 496 Element old = currentElement; |
| 497 _currentElement = element; | 497 _currentElement = element; |
| 498 try { | 498 try { |
| 499 return f(); | 499 return f(); |
| 500 } on SpannableAssertionFailure catch (ex) { | 500 } on SpannableAssertionFailure catch (ex) { |
| 501 if (!hasCrashed) { | 501 if (!hasCrashed) { |
| 502 String message = (ex.message != null) ? tryToString(ex.message) | 502 reportAssertionFailure(ex); |
| 503 : tryToString(ex); | |
| 504 SourceSpan span = spanFromSpannable(ex.node); | |
| 505 reportError(ex.node, MessageKind.GENERIC, {'text': message}); | |
| 506 pleaseReportCrash(); | 503 pleaseReportCrash(); |
| 507 } | 504 } |
| 508 hasCrashed = true; | 505 hasCrashed = true; |
| 509 rethrow; | 506 rethrow; |
| 510 } on CompilerCancelledException catch (ex) { | 507 } on CompilerCancelledException catch (ex) { |
| 511 rethrow; | 508 rethrow; |
| 512 } on StackOverflowError catch (ex) { | 509 } on StackOverflowError catch (ex) { |
| 513 // We cannot report anything useful in this case, because we | 510 // We cannot report anything useful in this case, because we |
| 514 // do not have enough stack space. | 511 // do not have enough stack space. |
| 515 rethrow; | 512 rethrow; |
| (...skipping 874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1390 } | 1387 } |
| 1391 | 1388 |
| 1392 void reportMessage(SourceSpan span, Diagnostic message, api.Diagnostic kind) { | 1389 void reportMessage(SourceSpan span, Diagnostic message, api.Diagnostic kind) { |
| 1393 // TODO(ahe): The names Diagnostic and api.Diagnostic are in | 1390 // TODO(ahe): The names Diagnostic and api.Diagnostic are in |
| 1394 // conflict. Fix it. | 1391 // conflict. Fix it. |
| 1395 reportDiagnostic(span, "$message", kind); | 1392 reportDiagnostic(span, "$message", kind); |
| 1396 } | 1393 } |
| 1397 | 1394 |
| 1398 void reportDiagnostic(SourceSpan span, String message, api.Diagnostic kind); | 1395 void reportDiagnostic(SourceSpan span, String message, api.Diagnostic kind); |
| 1399 | 1396 |
| 1397 void reportAssertionFailure(SpannableAssertionFailure ex) { |
| 1398 String message = (ex.message != null) ? tryToString(ex.message) |
| 1399 : tryToString(ex); |
| 1400 SourceSpan span = spanFromSpannable(ex.node); |
| 1401 reportError(ex.node, MessageKind.GENERIC, {'text': message}); |
| 1402 } |
| 1403 |
| 1400 SourceSpan spanFromTokens(Token begin, Token end, [Uri uri]) { | 1404 SourceSpan spanFromTokens(Token begin, Token end, [Uri uri]) { |
| 1401 if (begin == null || end == null) { | 1405 if (begin == null || end == null) { |
| 1402 // TODO(ahe): We can almost always do better. Often it is only | 1406 // TODO(ahe): We can almost always do better. Often it is only |
| 1403 // end that is null. Otherwise, we probably know the current | 1407 // end that is null. Otherwise, we probably know the current |
| 1404 // URI. | 1408 // URI. |
| 1405 throw 'Cannot find tokens to produce error message.'; | 1409 throw 'Cannot find tokens to produce error message.'; |
| 1406 } | 1410 } |
| 1407 if (uri == null && currentElement != null) { | 1411 if (uri == null && currentElement != null) { |
| 1408 uri = currentElement.getCompilationUnit().script.uri; | 1412 uri = currentElement.getCompilationUnit().script.uri; |
| 1409 } | 1413 } |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1730 | 1734 |
| 1731 void close() {} | 1735 void close() {} |
| 1732 | 1736 |
| 1733 toString() => name; | 1737 toString() => name; |
| 1734 | 1738 |
| 1735 /// Convenience method for getting an [api.CompilerOutputProvider]. | 1739 /// Convenience method for getting an [api.CompilerOutputProvider]. |
| 1736 static NullSink outputProvider(String name, String extension) { | 1740 static NullSink outputProvider(String name, String extension) { |
| 1737 return new NullSink('$name.$extension'); | 1741 return new NullSink('$name.$extension'); |
| 1738 } | 1742 } |
| 1739 } | 1743 } |
| OLD | NEW |