| 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 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 void unhandledExceptionOnElement(Element element) { | 402 void unhandledExceptionOnElement(Element element) { |
| 403 if (hasCrashed) return; | 403 if (hasCrashed) return; |
| 404 hasCrashed = true; | 404 hasCrashed = true; |
| 405 reportDiagnostic(spanFromElement(element), | 405 reportDiagnostic(spanFromElement(element), |
| 406 MessageKind.COMPILER_CRASHED.error().toString(), | 406 MessageKind.COMPILER_CRASHED.error().toString(), |
| 407 api.Diagnostic.CRASH); | 407 api.Diagnostic.CRASH); |
| 408 pleaseReportCrash(); | 408 pleaseReportCrash(); |
| 409 } | 409 } |
| 410 | 410 |
| 411 void pleaseReportCrash() { | 411 void pleaseReportCrash() { |
| 412 print(MessageKind.PLEASE_REPORT_THE_CRASH.message([BUILD_ID])); | 412 print(MessageKind.PLEASE_REPORT_THE_CRASH.message({'buildId': BUILD_ID})); |
| 413 } | 413 } |
| 414 | 414 |
| 415 void cancel(String reason, {Node node, Token token, | 415 void cancel(String reason, {Node node, Token token, |
| 416 HInstruction instruction, Element element}) { | 416 HInstruction instruction, Element element}) { |
| 417 assembledCode = null; // Compilation failed. Make sure that we | 417 assembledCode = null; // Compilation failed. Make sure that we |
| 418 // don't return a bogus result. | 418 // don't return a bogus result. |
| 419 SourceSpan span = null; | 419 SourceSpan span = null; |
| 420 if (node != null) { | 420 if (node != null) { |
| 421 span = spanFromNode(node); | 421 span = spanFromNode(node); |
| 422 } else if (token != null) { | 422 } else if (token != null) { |
| 423 span = spanFromTokens(token, token); | 423 span = spanFromTokens(token, token); |
| 424 } else if (instruction != null) { | 424 } else if (instruction != null) { |
| 425 span = spanFromHInstruction(instruction); | 425 span = spanFromHInstruction(instruction); |
| 426 } else if (element != null) { | 426 } else if (element != null) { |
| 427 span = spanFromElement(element); | 427 span = spanFromElement(element); |
| 428 } else { | 428 } else { |
| 429 throw 'No error location for error: $reason'; | 429 throw 'No error location for error: $reason'; |
| 430 } | 430 } |
| 431 reportDiagnostic(span, reason, api.Diagnostic.ERROR); | 431 reportDiagnostic(span, reason, api.Diagnostic.ERROR); |
| 432 throw new CompilerCancelledException(reason); | 432 throw new CompilerCancelledException(reason); |
| 433 } | 433 } |
| 434 | 434 |
| 435 SourceSpan spanFromSpannable(Spannable node, [Uri uri]) { | 435 SourceSpan spanFromSpannable(Spannable node, [Uri uri]) { |
| 436 if (node == CURRENT_ELEMENT_SPANNABLE) { |
| 437 node = currentElement; |
| 438 } |
| 436 if (node is Node) { | 439 if (node is Node) { |
| 437 return spanFromNode(node, uri); | 440 return spanFromNode(node, uri); |
| 438 } else if (node is Token) { | 441 } else if (node is Token) { |
| 439 return spanFromTokens(node, node, uri); | 442 return spanFromTokens(node, node, uri); |
| 440 } else if (node is HInstruction) { | 443 } else if (node is HInstruction) { |
| 441 return spanFromHInstruction(node); | 444 return spanFromHInstruction(node); |
| 442 } else if (node is Element) { | 445 } else if (node is Element) { |
| 443 return spanFromElement(node); | 446 return spanFromElement(node); |
| 444 } else { | 447 } else { |
| 445 throw 'No error location.'; | 448 throw 'No error location.'; |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 855 bool onDeprecatedFeature(Spannable span, String feature) { | 858 bool onDeprecatedFeature(Spannable span, String feature) { |
| 856 if (currentElement == null) | 859 if (currentElement == null) |
| 857 throw new SpannableAssertionFailure(span, feature); | 860 throw new SpannableAssertionFailure(span, feature); |
| 858 if (!checkDeprecationInSdk && | 861 if (!checkDeprecationInSdk && |
| 859 currentElement.getLibrary().isPlatformLibrary) { | 862 currentElement.getLibrary().isPlatformLibrary) { |
| 860 return false; | 863 return false; |
| 861 } | 864 } |
| 862 var kind = rejectDeprecatedFeatures | 865 var kind = rejectDeprecatedFeatures |
| 863 ? api.Diagnostic.ERROR : api.Diagnostic.WARNING; | 866 ? api.Diagnostic.ERROR : api.Diagnostic.WARNING; |
| 864 var message = rejectDeprecatedFeatures | 867 var message = rejectDeprecatedFeatures |
| 865 ? MessageKind.DEPRECATED_FEATURE_ERROR.error([feature]) | 868 ? MessageKind.DEPRECATED_FEATURE_ERROR.error({'featureName': feature}) |
| 866 : MessageKind.DEPRECATED_FEATURE_WARNING.error([feature]); | 869 : MessageKind.DEPRECATED_FEATURE_WARNING.error( |
| 870 {'featureName': feature}); |
| 867 reportMessage(spanFromSpannable(span), message, kind); | 871 reportMessage(spanFromSpannable(span), message, kind); |
| 868 return true; | 872 return true; |
| 869 } | 873 } |
| 870 | 874 |
| 871 void reportDiagnostic(SourceSpan span, String message, api.Diagnostic kind); | 875 void reportDiagnostic(SourceSpan span, String message, api.Diagnostic kind); |
| 872 | 876 |
| 873 SourceSpan spanFromTokens(Token begin, Token end, [Uri uri]) { | 877 SourceSpan spanFromTokens(Token begin, Token end, [Uri uri]) { |
| 874 if (begin == null || end == null) { | 878 if (begin == null || end == null) { |
| 875 // TODO(ahe): We can almost always do better. Often it is only | 879 // TODO(ahe): We can almost always do better. Often it is only |
| 876 // end that is null. Otherwise, we probably know the current | 880 // end that is null. Otherwise, we probably know the current |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1080 // TODO(johnniwinther): Use [spannable] and [message] to provide better | 1084 // TODO(johnniwinther): Use [spannable] and [message] to provide better |
| 1081 // information on assertion errors. | 1085 // information on assertion errors. |
| 1082 if (condition is Function){ | 1086 if (condition is Function){ |
| 1083 condition = condition(); | 1087 condition = condition(); |
| 1084 } | 1088 } |
| 1085 if (spannable == null || !condition) { | 1089 if (spannable == null || !condition) { |
| 1086 throw new SpannableAssertionFailure(spannable, message); | 1090 throw new SpannableAssertionFailure(spannable, message); |
| 1087 } | 1091 } |
| 1088 return true; | 1092 return true; |
| 1089 } | 1093 } |
| OLD | NEW |