| 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 int nextFreeClassId = 0; | 97 int nextFreeClassId = 0; |
| 98 World world; | 98 World world; |
| 99 String assembledCode; | 99 String assembledCode; |
| 100 Types types; | 100 Types types; |
| 101 | 101 |
| 102 final bool enableMinification; | 102 final bool enableMinification; |
| 103 final bool enableTypeAssertions; | 103 final bool enableTypeAssertions; |
| 104 final bool enableUserAssertions; | 104 final bool enableUserAssertions; |
| 105 final bool enableConcreteTypeInference; | 105 final bool enableConcreteTypeInference; |
| 106 final bool analyzeAll; | 106 final bool analyzeAll; |
| 107 final bool rejectDeprecatedFeatures; |
| 108 final bool omgThisIsALongOptionName; |
| 107 | 109 |
| 108 bool disableInlining = false; | 110 bool disableInlining = false; |
| 109 | 111 |
| 110 final Tracer tracer; | 112 final Tracer tracer; |
| 111 | 113 |
| 112 CompilerTask measuredTask; | 114 CompilerTask measuredTask; |
| 113 Element _currentElement; | 115 Element _currentElement; |
| 114 LibraryElement coreLibrary; | 116 LibraryElement coreLibrary; |
| 115 LibraryElement isolateLibrary; | 117 LibraryElement isolateLibrary; |
| 116 LibraryElement jsHelperLibrary; | 118 LibraryElement jsHelperLibrary; |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 | 210 |
| 209 Compiler({this.tracer: const Tracer(), | 211 Compiler({this.tracer: const Tracer(), |
| 210 this.enableTypeAssertions: false, | 212 this.enableTypeAssertions: false, |
| 211 this.enableUserAssertions: false, | 213 this.enableUserAssertions: false, |
| 212 this.enableConcreteTypeInference: false, | 214 this.enableConcreteTypeInference: false, |
| 213 this.enableMinification: false, | 215 this.enableMinification: false, |
| 214 bool emitJavaScript: true, | 216 bool emitJavaScript: true, |
| 215 bool generateSourceMap: true, | 217 bool generateSourceMap: true, |
| 216 bool disallowUnsafeEval: false, | 218 bool disallowUnsafeEval: false, |
| 217 this.analyzeAll: false, | 219 this.analyzeAll: false, |
| 220 this.rejectDeprecatedFeatures: false, |
| 221 this.omgThisIsALongOptionName: false, |
| 218 List<String> strips: const []}) | 222 List<String> strips: const []}) |
| 219 : libraries = new Map<String, LibraryElement>(), | 223 : libraries = new Map<String, LibraryElement>(), |
| 220 progress = new Stopwatch() { | 224 progress = new Stopwatch() { |
| 221 progress.start(); | 225 progress.start(); |
| 222 world = new World(this); | 226 world = new World(this); |
| 223 scanner = new ScannerTask(this); | 227 scanner = new ScannerTask(this); |
| 224 dietParser = new DietParserTask(this); | 228 dietParser = new DietParserTask(this); |
| 225 parser = new ParserTask(this); | 229 parser = new ParserTask(this); |
| 226 patchParser = new PatchParserTask(this); | 230 patchParser = new PatchParserTask(this); |
| 227 libraryLoader = new LibraryLoaderTask(this); | 231 libraryLoader = new LibraryLoaderTask(this); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 } | 328 } |
| 325 | 329 |
| 326 void log(message) { | 330 void log(message) { |
| 327 reportDiagnostic(null, message, api.Diagnostic.VERBOSE_INFO); | 331 reportDiagnostic(null, message, api.Diagnostic.VERBOSE_INFO); |
| 328 } | 332 } |
| 329 | 333 |
| 330 bool run(Uri uri) { | 334 bool run(Uri uri) { |
| 331 try { | 335 try { |
| 332 runCompiler(uri); | 336 runCompiler(uri); |
| 333 } on CompilerCancelledException catch (exception) { | 337 } on CompilerCancelledException catch (exception) { |
| 334 log(exception.toString()); | 338 log('Error: $exception'); |
| 335 log('compilation failed'); | |
| 336 return false; | 339 return false; |
| 337 } | 340 } |
| 338 tracer.close(); | 341 tracer.close(); |
| 339 log('compilation succeeded'); | |
| 340 return true; | 342 return true; |
| 341 } | 343 } |
| 342 | 344 |
| 343 void enableNoSuchMethod(Element element) { | 345 void enableNoSuchMethod(Element element) { |
| 344 // TODO(ahe): Move this method to Enqueuer. | 346 // TODO(ahe): Move this method to Enqueuer. |
| 345 if (enabledNoSuchMethod) return; | 347 if (enabledNoSuchMethod) return; |
| 346 if (identical(element.getEnclosingClass(), objectClass)) { | 348 if (identical(element.getEnclosingClass(), objectClass)) { |
| 347 enqueuer.resolution.registerDynamicInvocationOf(element); | 349 enqueuer.resolution.registerDynamicInvocationOf(element); |
| 348 return; | 350 return; |
| 349 } | 351 } |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 750 reportDiagnostic(span, 'Error: $message', api.Diagnostic.ERROR); | 752 reportDiagnostic(span, 'Error: $message', api.Diagnostic.ERROR); |
| 751 throw new CompilerCancelledException(message.toString()); | 753 throw new CompilerCancelledException(message.toString()); |
| 752 } | 754 } |
| 753 | 755 |
| 754 void reportMessage(SourceSpan span, Diagnostic message, api.Diagnostic kind) { | 756 void reportMessage(SourceSpan span, Diagnostic message, api.Diagnostic kind) { |
| 755 // TODO(ahe): The names Diagnostic and api.Diagnostic are in | 757 // TODO(ahe): The names Diagnostic and api.Diagnostic are in |
| 756 // conflict. Fix it. | 758 // conflict. Fix it. |
| 757 reportDiagnostic(span, "$message", kind); | 759 reportDiagnostic(span, "$message", kind); |
| 758 } | 760 } |
| 759 | 761 |
| 762 void onDeprecatedFeature(Spannable span, String feature) { |
| 763 if (!omgThisIsALongOptionName && |
| 764 currentElement.getLibrary().isPlatformLibrary) { |
| 765 return; |
| 766 } |
| 767 var kind = rejectDeprecatedFeatures |
| 768 ? api.Diagnostic.ERROR : api.Diagnostic.WARNING; |
| 769 var message = rejectDeprecatedFeatures |
| 770 ? MessageKind.DEPRECATED_FEATURE_ERROR.error([feature]) |
| 771 : MessageKind.DEPRECATED_FEATURE_WARNING.error([feature]); |
| 772 reportMessage(spanFromSpannable(span), message, kind); |
| 773 } |
| 774 |
| 760 void reportDiagnostic(SourceSpan span, String message, api.Diagnostic kind); | 775 void reportDiagnostic(SourceSpan span, String message, api.Diagnostic kind); |
| 761 | 776 |
| 762 SourceSpan spanFromTokens(Token begin, Token end, [Uri uri]) { | 777 SourceSpan spanFromTokens(Token begin, Token end, [Uri uri]) { |
| 763 if (begin == null || end == null) { | 778 if (begin == null || end == null) { |
| 764 // TODO(ahe): We can almost always do better. Often it is only | 779 // TODO(ahe): We can almost always do better. Often it is only |
| 765 // end that is null. Otherwise, we probably know the current | 780 // end that is null. Otherwise, we probably know the current |
| 766 // URI. | 781 // URI. |
| 767 throw 'Cannot find tokens to produce error message.'; | 782 throw 'Cannot find tokens to produce error message.'; |
| 768 } | 783 } |
| 769 if (uri == null && currentElement != null) { | 784 if (uri == null && currentElement != null) { |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 914 // TODO(johnniwinther): Use [spannable] and [message] to provide better | 929 // TODO(johnniwinther): Use [spannable] and [message] to provide better |
| 915 // information on assertion errors. | 930 // information on assertion errors. |
| 916 if (condition is Function){ | 931 if (condition is Function){ |
| 917 condition = condition(); | 932 condition = condition(); |
| 918 } | 933 } |
| 919 if (spannable == null || !condition) { | 934 if (spannable == null || !condition) { |
| 920 throw new SpannableAssertionFailure(spannable, message); | 935 throw new SpannableAssertionFailure(spannable, message); |
| 921 } | 936 } |
| 922 return true; | 937 return true; |
| 923 } | 938 } |
| OLD | NEW |