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 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 /// Called during resolution to notify to the backend that the | 262 /// Called during resolution to notify to the backend that the |
263 /// program has a global variable with a lazy initializer. | 263 /// program has a global variable with a lazy initializer. |
264 void registerLazyField(Registry registry) {} | 264 void registerLazyField(Registry registry) {} |
265 | 265 |
266 /// Called during resolution to notify to the backend that the | 266 /// Called during resolution to notify to the backend that the |
267 /// program uses a type variable as an expression. | 267 /// program uses a type variable as an expression. |
268 void registerTypeVariableExpression(Registry registry) {} | 268 void registerTypeVariableExpression(Registry registry) {} |
269 | 269 |
270 /// Called during resolution to notify to the backend that the | 270 /// Called during resolution to notify to the backend that the |
271 /// program uses a type literal. | 271 /// program uses a type literal. |
272 void registerTypeLiteral(Element element, | 272 void registerTypeLiteral(DartType type, |
273 Enqueuer enqueuer, | 273 Enqueuer enqueuer, |
274 Registry registry) {} | 274 Registry registry) {} |
275 | 275 |
276 /// Called during resolution to notify to the backend that the | 276 /// Called during resolution to notify to the backend that the |
277 /// program has a catch statement with a stack trace. | 277 /// program has a catch statement with a stack trace. |
278 void registerStackTraceInCatch(Registry registry) {} | 278 void registerStackTraceInCatch(Registry registry) {} |
279 | 279 |
280 /// Register an is check to the backend. | 280 /// Register an is check to the backend. |
281 void registerIsCheck(DartType type, | 281 void registerIsCheck(DartType type, |
282 Enqueuer enqueuer, | 282 Enqueuer enqueuer, |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 | 579 |
580 /// Initialized when dart:mirrors is loaded. | 580 /// Initialized when dart:mirrors is loaded. |
581 LibraryElement mirrorsLibrary; | 581 LibraryElement mirrorsLibrary; |
582 | 582 |
583 /// Initialized when dart:typed_data is loaded. | 583 /// Initialized when dart:typed_data is loaded. |
584 LibraryElement typedDataLibrary; | 584 LibraryElement typedDataLibrary; |
585 | 585 |
586 ClassElement objectClass; | 586 ClassElement objectClass; |
587 ClassElement closureClass; | 587 ClassElement closureClass; |
588 ClassElement boundClosureClass; | 588 ClassElement boundClosureClass; |
589 ClassElement dynamicClass; | |
590 ClassElement boolClass; | 589 ClassElement boolClass; |
591 ClassElement numClass; | 590 ClassElement numClass; |
592 ClassElement intClass; | 591 ClassElement intClass; |
593 ClassElement doubleClass; | 592 ClassElement doubleClass; |
594 ClassElement stringClass; | 593 ClassElement stringClass; |
595 ClassElement functionClass; | 594 ClassElement functionClass; |
596 ClassElement nullClass; | 595 ClassElement nullClass; |
597 ClassElement listClass; | 596 ClassElement listClass; |
598 ClassElement typeClass; | 597 ClassElement typeClass; |
599 ClassElement mapClass; | 598 ClassElement mapClass; |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
953 }); | 952 }); |
954 } | 953 } |
955 | 954 |
956 bool hasIsolateSupport() => isolateLibrary != null; | 955 bool hasIsolateSupport() => isolateLibrary != null; |
957 | 956 |
958 /** | 957 /** |
959 * This method is called before [library] import and export scopes have been | 958 * This method is called before [library] import and export scopes have been |
960 * set up. | 959 * set up. |
961 */ | 960 */ |
962 Future onLibraryLoaded(LibraryElement library, Uri uri) { | 961 Future onLibraryLoaded(LibraryElement library, Uri uri) { |
963 if (dynamicClass != null) { | |
964 // When loading the built-in libraries, dynamicClass is null. We | |
965 // take advantage of this as core imports js_helper and sees [dynamic] | |
966 // this way. | |
967 withCurrentElement(dynamicClass, () { | |
968 library.addToScope(dynamicClass, this); | |
969 }); | |
970 } | |
971 if (uri == new Uri(scheme: 'dart', path: 'mirrors')) { | 962 if (uri == new Uri(scheme: 'dart', path: 'mirrors')) { |
972 mirrorsLibrary = library; | 963 mirrorsLibrary = library; |
973 mirrorSystemClass = | 964 mirrorSystemClass = |
974 findRequiredElement(library, 'MirrorSystem'); | 965 findRequiredElement(library, 'MirrorSystem'); |
975 mirrorsUsedClass = | 966 mirrorsUsedClass = |
976 findRequiredElement(library, 'MirrorsUsed'); | 967 findRequiredElement(library, 'MirrorsUsed'); |
977 } else if (uri == new Uri(scheme: 'dart', path: '_native_typed_data')) { | 968 } else if (uri == new Uri(scheme: 'dart', path: '_native_typed_data')) { |
978 typedDataLibrary = library; | 969 typedDataLibrary = library; |
979 typedDataClass = | 970 typedDataClass = |
980 findRequiredElement(library, 'NativeTypedData'); | 971 findRequiredElement(library, 'NativeTypedData'); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1063 ClassElement lookupHelperClass(String name) { | 1054 ClassElement lookupHelperClass(String name) { |
1064 ClassElement result = jsHelperLibrary.find(name); | 1055 ClassElement result = jsHelperLibrary.find(name); |
1065 if (result == null) { | 1056 if (result == null) { |
1066 missingHelperClasses.add(name); | 1057 missingHelperClasses.add(name); |
1067 } | 1058 } |
1068 return result; | 1059 return result; |
1069 } | 1060 } |
1070 jsInvocationMirrorClass = lookupHelperClass('JSInvocationMirror'); | 1061 jsInvocationMirrorClass = lookupHelperClass('JSInvocationMirror'); |
1071 boundClosureClass = lookupHelperClass('BoundClosure'); | 1062 boundClosureClass = lookupHelperClass('BoundClosure'); |
1072 closureClass = lookupHelperClass('Closure'); | 1063 closureClass = lookupHelperClass('Closure'); |
1073 dynamicClass = lookupHelperClass('Dynamic_'); | |
1074 if (!missingHelperClasses.isEmpty) { | 1064 if (!missingHelperClasses.isEmpty) { |
1075 internalError(jsHelperLibrary, | 1065 internalError(jsHelperLibrary, |
1076 'dart:_js_helper library does not contain required classes: ' | 1066 'dart:_js_helper library does not contain required classes: ' |
1077 '$missingHelperClasses'); | 1067 '$missingHelperClasses'); |
1078 } | 1068 } |
1079 | 1069 |
1080 if (types == null) { | 1070 if (types == null) { |
1081 types = new Types(this, dynamicClass); | 1071 types = new Types(this); |
1082 } | 1072 } |
1083 backend.initializeHelperClasses(); | 1073 backend.initializeHelperClasses(); |
1084 | 1074 |
1085 dynamicClass.ensureResolved(this); | |
1086 | |
1087 proxyConstant = | 1075 proxyConstant = |
1088 resolver.constantCompiler.compileConstant(coreLibrary.find('proxy')); | 1076 resolver.constantCompiler.compileConstant(coreLibrary.find('proxy')); |
1089 } | 1077 } |
1090 | 1078 |
1091 Element _unnamedListConstructor; | 1079 Element _unnamedListConstructor; |
1092 Element get unnamedListConstructor { | 1080 Element get unnamedListConstructor { |
1093 if (_unnamedListConstructor != null) return _unnamedListConstructor; | 1081 if (_unnamedListConstructor != null) return _unnamedListConstructor; |
1094 Selector callConstructor = new Selector.callConstructor( | 1082 Selector callConstructor = new Selector.callConstructor( |
1095 "", listClass.library); | 1083 "", listClass.library); |
1096 return _unnamedListConstructor = | 1084 return _unnamedListConstructor = |
(...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1921 static NullSink outputProvider(String name, String extension) { | 1909 static NullSink outputProvider(String name, String extension) { |
1922 return new NullSink('$name.$extension'); | 1910 return new NullSink('$name.$extension'); |
1923 } | 1911 } |
1924 } | 1912 } |
1925 | 1913 |
1926 /// Information about suppressed warnings and hints for a given library. | 1914 /// Information about suppressed warnings and hints for a given library. |
1927 class SuppressionInfo { | 1915 class SuppressionInfo { |
1928 int warnings = 0; | 1916 int warnings = 0; |
1929 int hints = 0; | 1917 int hints = 0; |
1930 } | 1918 } |
OLD | NEW |