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 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 * maps. | 322 * maps. |
323 */ | 323 */ |
324 final Uri sourceMapUri; | 324 final Uri sourceMapUri; |
325 | 325 |
326 /** | 326 /** |
327 * The name to use for the global JS object in JS output. Default | 327 * The name to use for the global JS object in JS output. Default |
328 * value is "$". | 328 * value is "$". |
329 */ | 329 */ |
330 final String globalJsName; | 330 final String globalJsName; |
331 | 331 |
| 332 /// Emit terse diagnostics without howToFix. |
| 333 final bool terseDiagnostics; |
| 334 |
332 final api.CompilerOutputProvider outputProvider; | 335 final api.CompilerOutputProvider outputProvider; |
333 | 336 |
334 bool disableInlining = false; | 337 bool disableInlining = false; |
335 | 338 |
336 List<Uri> librariesToAnalyzeWhenRun; | 339 List<Uri> librariesToAnalyzeWhenRun; |
337 | 340 |
338 final Tracer tracer; | 341 final Tracer tracer; |
339 | 342 |
340 CompilerTask measuredTask; | 343 CompilerTask measuredTask; |
341 Element _currentElement; | 344 Element _currentElement; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 | 381 |
379 // Initialized after mirrorSystemClass has been resolved. | 382 // Initialized after mirrorSystemClass has been resolved. |
380 FunctionElement mirrorSystemGetNameFunction; | 383 FunctionElement mirrorSystemGetNameFunction; |
381 | 384 |
382 // Initialized when dart:_collection-dev is loaded. | 385 // Initialized when dart:_collection-dev is loaded. |
383 ClassElement symbolImplementationClass; | 386 ClassElement symbolImplementationClass; |
384 | 387 |
385 // Initialized when symbolImplementationClass has been resolved. | 388 // Initialized when symbolImplementationClass has been resolved. |
386 FunctionElement symbolValidatedConstructor; | 389 FunctionElement symbolValidatedConstructor; |
387 | 390 |
| 391 // Initialized when mirrorsUsedClass has been resolved. |
| 392 FunctionElement mirrorsUsedConstructor; |
| 393 |
388 // Initialized when dart:mirrors is loaded. | 394 // Initialized when dart:mirrors is loaded. |
389 ClassElement deferredLibraryClass; | 395 ClassElement deferredLibraryClass; |
390 | 396 |
391 ClassElement jsInvocationMirrorClass; | 397 ClassElement jsInvocationMirrorClass; |
392 /// Document class from dart:mirrors. | 398 /// Document class from dart:mirrors. |
393 ClassElement documentClass; | 399 ClassElement documentClass; |
394 Element assertMethod; | 400 Element assertMethod; |
395 Element identicalFunction; | 401 Element identicalFunction; |
396 Element functionApplyMethod; | 402 Element functionApplyMethod; |
397 Element invokeOnMethod; | 403 Element invokeOnMethod; |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 bool generateSourceMap: true, | 520 bool generateSourceMap: true, |
515 bool disallowUnsafeEval: false, | 521 bool disallowUnsafeEval: false, |
516 this.analyzeAllFlag: false, | 522 this.analyzeAllFlag: false, |
517 bool analyzeOnly: false, | 523 bool analyzeOnly: false, |
518 bool analyzeSignaturesOnly: false, | 524 bool analyzeSignaturesOnly: false, |
519 this.preserveComments: false, | 525 this.preserveComments: false, |
520 this.verbose: false, | 526 this.verbose: false, |
521 this.sourceMapUri: null, | 527 this.sourceMapUri: null, |
522 this.buildId: UNDETERMINED_BUILD_ID, | 528 this.buildId: UNDETERMINED_BUILD_ID, |
523 this.globalJsName: r'$', | 529 this.globalJsName: r'$', |
| 530 this.terseDiagnostics: false, |
524 outputProvider, | 531 outputProvider, |
525 List<String> strips: const []}) | 532 List<String> strips: const []}) |
526 : this.analyzeOnly = analyzeOnly || analyzeSignaturesOnly, | 533 : this.analyzeOnly = analyzeOnly || analyzeSignaturesOnly, |
527 this.analyzeSignaturesOnly = analyzeSignaturesOnly, | 534 this.analyzeSignaturesOnly = analyzeSignaturesOnly, |
528 this.outputProvider = (outputProvider == null) | 535 this.outputProvider = (outputProvider == null) |
529 ? NullSink.outputProvider | 536 ? NullSink.outputProvider |
530 : outputProvider { | 537 : outputProvider { |
531 world = new World(this); | 538 world = new World(this); |
532 | 539 |
533 closureMapping.ClosureNamer closureNamer; | 540 closureMapping.ClosureNamer closureNamer; |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
735 | 742 |
736 void onClassResolved(ClassElement cls) { | 743 void onClassResolved(ClassElement cls) { |
737 if (mirrorSystemClass == cls) { | 744 if (mirrorSystemClass == cls) { |
738 mirrorSystemGetNameFunction = | 745 mirrorSystemGetNameFunction = |
739 cls.lookupLocalMember(const SourceString('getName')); | 746 cls.lookupLocalMember(const SourceString('getName')); |
740 } else if (symbolClass == cls) { | 747 } else if (symbolClass == cls) { |
741 symbolConstructor = cls.constructors.head; | 748 symbolConstructor = cls.constructors.head; |
742 } else if (symbolImplementationClass == cls) { | 749 } else if (symbolImplementationClass == cls) { |
743 symbolValidatedConstructor = symbolImplementationClass.lookupConstructor( | 750 symbolValidatedConstructor = symbolImplementationClass.lookupConstructor( |
744 symbolValidatedConstructorSelector); | 751 symbolValidatedConstructorSelector); |
| 752 } else if (mirrorsUsedClass == cls) { |
| 753 mirrorsUsedConstructor = cls.constructors.head; |
745 } | 754 } |
746 } | 755 } |
747 | 756 |
748 LibraryElement scanBuiltinLibrary(String filename); | 757 LibraryElement scanBuiltinLibrary(String filename); |
749 | 758 |
750 void initializeSpecialClasses() { | 759 void initializeSpecialClasses() { |
751 final List missingCoreClasses = []; | 760 final List missingCoreClasses = []; |
752 ClassElement lookupCoreClass(String name) { | 761 ClassElement lookupCoreClass(String name) { |
753 ClassElement result = coreLibrary.find(new SourceString(name)); | 762 ClassElement result = coreLibrary.find(new SourceString(name)); |
754 if (result == null) { | 763 if (result == null) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
790 boundClosureClass = lookupHelperClass('BoundClosure'); | 799 boundClosureClass = lookupHelperClass('BoundClosure'); |
791 closureClass = lookupHelperClass('Closure'); | 800 closureClass = lookupHelperClass('Closure'); |
792 dynamicClass = lookupHelperClass('Dynamic_'); | 801 dynamicClass = lookupHelperClass('Dynamic_'); |
793 nullClass = lookupHelperClass('Null'); | 802 nullClass = lookupHelperClass('Null'); |
794 if (!missingHelperClasses.isEmpty) { | 803 if (!missingHelperClasses.isEmpty) { |
795 internalErrorOnElement(jsHelperLibrary, | 804 internalErrorOnElement(jsHelperLibrary, |
796 'dart:_js_helper library does not contain required classes: ' | 805 'dart:_js_helper library does not contain required classes: ' |
797 '$missingHelperClasses'); | 806 '$missingHelperClasses'); |
798 } | 807 } |
799 | 808 |
800 types = new Types(this, dynamicClass); | 809 if (types == null) { |
| 810 types = new Types(this, dynamicClass); |
| 811 } |
801 backend.initializeHelperClasses(); | 812 backend.initializeHelperClasses(); |
802 | 813 |
803 dynamicClass.ensureResolved(this); | 814 dynamicClass.ensureResolved(this); |
804 } | 815 } |
805 | 816 |
806 Element _unnamedListConstructor; | 817 Element _unnamedListConstructor; |
807 Element get unnamedListConstructor { | 818 Element get unnamedListConstructor { |
808 if (_unnamedListConstructor != null) return _unnamedListConstructor; | 819 if (_unnamedListConstructor != null) return _unnamedListConstructor; |
809 Selector callConstructor = new Selector.callConstructor( | 820 Selector callConstructor = new Selector.callConstructor( |
810 const SourceString(""), listClass.getLibrary()); | 821 const SourceString(""), listClass.getLibrary()); |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1160 } | 1171 } |
1161 SourceSpan span = spanFromNode(node); | 1172 SourceSpan span = spanFromNode(node); |
1162 | 1173 |
1163 reportDiagnostic(span, '$message', api.Diagnostic.WARNING); | 1174 reportDiagnostic(span, '$message', api.Diagnostic.WARNING); |
1164 } | 1175 } |
1165 | 1176 |
1166 void reportError(Spannable node, | 1177 void reportError(Spannable node, |
1167 MessageKind errorCode, | 1178 MessageKind errorCode, |
1168 [Map arguments = const {}]) { | 1179 [Map arguments = const {}]) { |
1169 reportMessage(spanFromSpannable(node), | 1180 reportMessage(spanFromSpannable(node), |
1170 errorCode.error(arguments), | 1181 errorCode.error(arguments, terseDiagnostics), |
1171 api.Diagnostic.ERROR); | 1182 api.Diagnostic.ERROR); |
1172 } | 1183 } |
1173 | 1184 |
1174 void reportFatalError(Spannable node, MessageKind errorCode, | 1185 void reportFatalError(Spannable node, MessageKind errorCode, |
1175 [Map arguments = const {}]) { | 1186 [Map arguments = const {}]) { |
1176 reportError(node, errorCode, arguments); | 1187 reportError(node, errorCode, arguments); |
1177 // TODO(ahe): Make this only abort the current method. | 1188 // TODO(ahe): Make this only abort the current method. |
1178 throw new CompilerCancelledException( | 1189 throw new CompilerCancelledException( |
1179 'Error: Cannot continue due to previous error.'); | 1190 'Error: Cannot continue due to previous error.'); |
1180 } | 1191 } |
1181 | 1192 |
1182 // TODO(ahe): Rename to reportWarning when that method has been removed. | 1193 // TODO(ahe): Rename to reportWarning when that method has been removed. |
1183 void reportWarningCode(Spannable node, MessageKind errorCode, | 1194 void reportWarningCode(Spannable node, MessageKind errorCode, |
1184 [Map arguments = const {}]) { | 1195 [Map arguments = const {}]) { |
1185 reportMessage(spanFromSpannable(node), | 1196 reportMessage(spanFromSpannable(node), |
1186 errorCode.error(arguments), | 1197 errorCode.error(arguments, terseDiagnostics), |
1187 api.Diagnostic.WARNING); | 1198 api.Diagnostic.WARNING); |
1188 } | 1199 } |
1189 | 1200 |
1190 void reportInfo(Spannable node, MessageKind errorCode, | 1201 void reportInfo(Spannable node, MessageKind errorCode, |
1191 [Map arguments = const {}]) { | 1202 [Map arguments = const {}]) { |
1192 reportMessage(spanFromSpannable(node), | 1203 reportMessage(spanFromSpannable(node), |
1193 errorCode.error(arguments), | 1204 errorCode.error(arguments, terseDiagnostics), |
1194 api.Diagnostic.INFO); | 1205 api.Diagnostic.INFO); |
1195 } | 1206 } |
1196 | 1207 |
1197 void reportHint(Spannable node, MessageKind errorCode, | 1208 void reportHint(Spannable node, MessageKind errorCode, |
1198 [Map arguments = const {}]) { | 1209 [Map arguments = const {}]) { |
1199 reportMessage(spanFromSpannable(node), | 1210 reportMessage(spanFromSpannable(node), |
1200 errorCode.error(arguments), | 1211 errorCode.error(arguments, terseDiagnostics), |
1201 api.Diagnostic.HINT); | 1212 api.Diagnostic.HINT); |
1202 } | 1213 } |
1203 | 1214 |
1204 /// For debugging only, print a message with a source location. | 1215 /// For debugging only, print a message with a source location. |
1205 void reportHere(Spannable node, String debugMessage) { | 1216 void reportHere(Spannable node, String debugMessage) { |
1206 reportInfo(node, MessageKind.GENERIC, {'text': 'HERE: $debugMessage'}); | 1217 reportInfo(node, MessageKind.GENERIC, {'text': 'HERE: $debugMessage'}); |
1207 } | 1218 } |
1208 | 1219 |
1209 void reportInternalError(Spannable node, String message) { | 1220 void reportInternalError(Spannable node, String message) { |
1210 reportError( | 1221 reportError( |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1464 | 1475 |
1465 void close() {} | 1476 void close() {} |
1466 | 1477 |
1467 toString() => name; | 1478 toString() => name; |
1468 | 1479 |
1469 /// Convenience method for getting an [api.CompilerOutputProvider]. | 1480 /// Convenience method for getting an [api.CompilerOutputProvider]. |
1470 static NullSink outputProvider(String name, String extension) { | 1481 static NullSink outputProvider(String name, String extension) { |
1471 return new NullSink('$name.$extension'); | 1482 return new NullSink('$name.$extension'); |
1472 } | 1483 } |
1473 } | 1484 } |
OLD | NEW |