| 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 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 ClassElement boolClass; | 299 ClassElement boolClass; |
| 300 ClassElement numClass; | 300 ClassElement numClass; |
| 301 ClassElement intClass; | 301 ClassElement intClass; |
| 302 ClassElement doubleClass; | 302 ClassElement doubleClass; |
| 303 ClassElement stringClass; | 303 ClassElement stringClass; |
| 304 ClassElement functionClass; | 304 ClassElement functionClass; |
| 305 ClassElement nullClass; | 305 ClassElement nullClass; |
| 306 ClassElement listClass; | 306 ClassElement listClass; |
| 307 ClassElement typeClass; | 307 ClassElement typeClass; |
| 308 ClassElement mapClass; | 308 ClassElement mapClass; |
| 309 ClassElement symbolClass; |
| 310 FunctionElement symbolConstructor; |
| 311 ClassElement mirrorSystemClass; |
| 312 FunctionElement mirrorSystemGetNameFunction; |
| 313 |
| 309 ClassElement jsInvocationMirrorClass; | 314 ClassElement jsInvocationMirrorClass; |
| 310 /// Document class from dart:mirrors. | 315 /// Document class from dart:mirrors. |
| 311 ClassElement documentClass; | 316 ClassElement documentClass; |
| 312 Element assertMethod; | 317 Element assertMethod; |
| 313 Element identicalFunction; | 318 Element identicalFunction; |
| 314 Element functionApplyMethod; | 319 Element functionApplyMethod; |
| 315 Element invokeOnMethod; | 320 Element invokeOnMethod; |
| 316 Element createInvocationMirrorElement; | 321 Element createInvocationMirrorElement; |
| 317 | 322 |
| 318 Element get currentElement => _currentElement; | 323 Element get currentElement => _currentElement; |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 609 */ | 614 */ |
| 610 void onLibraryScanned(LibraryElement library, Uri uri) { | 615 void onLibraryScanned(LibraryElement library, Uri uri) { |
| 611 if (dynamicClass != null) { | 616 if (dynamicClass != null) { |
| 612 // When loading the built-in libraries, dynamicClass is null. We | 617 // When loading the built-in libraries, dynamicClass is null. We |
| 613 // take advantage of this as core imports js_helper and sees [dynamic] | 618 // take advantage of this as core imports js_helper and sees [dynamic] |
| 614 // this way. | 619 // this way. |
| 615 withCurrentElement(dynamicClass, () { | 620 withCurrentElement(dynamicClass, () { |
| 616 library.addToScope(dynamicClass, this); | 621 library.addToScope(dynamicClass, this); |
| 617 }); | 622 }); |
| 618 } | 623 } |
| 624 if (uri == Uri.parse('dart:mirrors')) { |
| 625 mirrorSystemClass = library.find(const SourceString('MirrorSystem')); |
| 626 print(mirrorSystemClass); |
| 627 } |
| 628 } |
| 629 |
| 630 void onClassResolved(ClassElement cls) { |
| 631 if (mirrorSystemClass == cls) { |
| 632 mirrorSystemGetNameFunction = |
| 633 cls.lookupLocalMember(const SourceString('getName')); |
| 634 } else if (symbolClass == cls) { |
| 635 symbolConstructor = cls.constructors.head; |
| 636 } |
| 619 } | 637 } |
| 620 | 638 |
| 621 LibraryElement scanBuiltinLibrary(String filename); | 639 LibraryElement scanBuiltinLibrary(String filename); |
| 622 | 640 |
| 623 void initializeSpecialClasses() { | 641 void initializeSpecialClasses() { |
| 624 final List missingCoreClasses = []; | 642 final List missingCoreClasses = []; |
| 625 ClassElement lookupCoreClass(String name) { | 643 ClassElement lookupCoreClass(String name) { |
| 626 ClassElement result = coreLibrary.find(new SourceString(name)); | 644 ClassElement result = coreLibrary.find(new SourceString(name)); |
| 627 if (result == null) { | 645 if (result == null) { |
| 628 missingCoreClasses.add(name); | 646 missingCoreClasses.add(name); |
| 629 } | 647 } |
| 630 return result; | 648 return result; |
| 631 } | 649 } |
| 632 objectClass = lookupCoreClass('Object'); | 650 objectClass = lookupCoreClass('Object'); |
| 633 boolClass = lookupCoreClass('bool'); | 651 boolClass = lookupCoreClass('bool'); |
| 634 numClass = lookupCoreClass('num'); | 652 numClass = lookupCoreClass('num'); |
| 635 intClass = lookupCoreClass('int'); | 653 intClass = lookupCoreClass('int'); |
| 636 doubleClass = lookupCoreClass('double'); | 654 doubleClass = lookupCoreClass('double'); |
| 637 stringClass = lookupCoreClass('String'); | 655 stringClass = lookupCoreClass('String'); |
| 638 functionClass = lookupCoreClass('Function'); | 656 functionClass = lookupCoreClass('Function'); |
| 639 listClass = lookupCoreClass('List'); | 657 listClass = lookupCoreClass('List'); |
| 640 typeClass = lookupCoreClass('Type'); | 658 typeClass = lookupCoreClass('Type'); |
| 641 mapClass = lookupCoreClass('Map'); | 659 mapClass = lookupCoreClass('Map'); |
| 642 if (!missingCoreClasses.isEmpty) { | 660 if (!missingCoreClasses.isEmpty) { |
| 643 internalErrorOnElement(coreLibrary, | 661 internalErrorOnElement(coreLibrary, |
| 644 'dart:core library does not contain required classes: ' | 662 'dart:core library does not contain required classes: ' |
| 645 '$missingCoreClasses'); | 663 '$missingCoreClasses'); |
| 646 } | 664 } |
| 647 | 665 |
| 666 // The following classes may not exist. |
| 667 // TODO(ahe): It is possible that we have to require the presence |
| 668 // of Symbol as we change how we implement noSuchMethod. |
| 669 symbolClass = lookupCoreClass('Symbol'); |
| 670 |
| 648 final List missingHelperClasses = []; | 671 final List missingHelperClasses = []; |
| 649 ClassElement lookupHelperClass(String name) { | 672 ClassElement lookupHelperClass(String name) { |
| 650 ClassElement result = jsHelperLibrary.find(new SourceString(name)); | 673 ClassElement result = jsHelperLibrary.find(new SourceString(name)); |
| 651 if (result == null) { | 674 if (result == null) { |
| 652 missingHelperClasses.add(name); | 675 missingHelperClasses.add(name); |
| 653 } | 676 } |
| 654 return result; | 677 return result; |
| 655 } | 678 } |
| 656 jsInvocationMirrorClass = lookupHelperClass('JSInvocationMirror'); | 679 jsInvocationMirrorClass = lookupHelperClass('JSInvocationMirror'); |
| 657 closureClass = lookupHelperClass('Closure'); | 680 closureClass = lookupHelperClass('Closure'); |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1006 } | 1029 } |
| 1007 | 1030 |
| 1008 // TODO(ahe): Rename to reportError when that method has been removed. | 1031 // TODO(ahe): Rename to reportError when that method has been removed. |
| 1009 void reportErrorCode(Spannable node, MessageKind errorCode, | 1032 void reportErrorCode(Spannable node, MessageKind errorCode, |
| 1010 [Map arguments = const {}]) { | 1033 [Map arguments = const {}]) { |
| 1011 reportMessage(spanFromSpannable(node), | 1034 reportMessage(spanFromSpannable(node), |
| 1012 errorCode.error(arguments), | 1035 errorCode.error(arguments), |
| 1013 api.Diagnostic.ERROR); | 1036 api.Diagnostic.ERROR); |
| 1014 } | 1037 } |
| 1015 | 1038 |
| 1039 // TODO(ahe): Rename to reportWarning when that method has been removed. |
| 1040 void reportWarningCode(Spannable node, MessageKind errorCode, |
| 1041 [Map arguments = const {}]) { |
| 1042 reportMessage(spanFromSpannable(node), |
| 1043 errorCode.error(arguments), |
| 1044 api.Diagnostic.WARNING); |
| 1045 } |
| 1046 |
| 1016 void reportMessage(SourceSpan span, Diagnostic message, api.Diagnostic kind) { | 1047 void reportMessage(SourceSpan span, Diagnostic message, api.Diagnostic kind) { |
| 1017 // TODO(ahe): The names Diagnostic and api.Diagnostic are in | 1048 // TODO(ahe): The names Diagnostic and api.Diagnostic are in |
| 1018 // conflict. Fix it. | 1049 // conflict. Fix it. |
| 1019 reportDiagnostic(span, "$message", kind); | 1050 reportDiagnostic(span, "$message", kind); |
| 1020 } | 1051 } |
| 1021 | 1052 |
| 1022 /// Returns true if a diagnostic was emitted. | 1053 /// Returns true if a diagnostic was emitted. |
| 1023 bool onDeprecatedFeature(Spannable span, String feature) { | 1054 bool onDeprecatedFeature(Spannable span, String feature) { |
| 1024 if (currentElement == null) | 1055 if (currentElement == null) |
| 1025 throw new SpannableAssertionFailure(span, feature); | 1056 throw new SpannableAssertionFailure(span, feature); |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1279 | 1310 |
| 1280 void close() {} | 1311 void close() {} |
| 1281 | 1312 |
| 1282 toString() => name; | 1313 toString() => name; |
| 1283 | 1314 |
| 1284 /// Convenience method for getting an [api.CompilerOutputProvider]. | 1315 /// Convenience method for getting an [api.CompilerOutputProvider]. |
| 1285 static NullSink outputProvider(String name, String extension) { | 1316 static NullSink outputProvider(String name, String extension) { |
| 1286 return new NullSink('$name.$extension'); | 1317 return new NullSink('$name.$extension'); |
| 1287 } | 1318 } |
| 1288 } | 1319 } |
| OLD | NEW |