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