| 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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 /// constants. | 244 /// constants. |
| 245 BackendConstantEnvironment get constants; | 245 BackendConstantEnvironment get constants; |
| 246 | 246 |
| 247 /// The compiler task responsible for the compilation of constants for both | 247 /// The compiler task responsible for the compilation of constants for both |
| 248 /// the frontend and the backend. | 248 /// the frontend and the backend. |
| 249 ConstantCompilerTask get constantCompilerTask; | 249 ConstantCompilerTask get constantCompilerTask; |
| 250 | 250 |
| 251 /// Backend callback methods for the resolution phase. | 251 /// Backend callback methods for the resolution phase. |
| 252 ResolutionCallbacks get resolutionCallbacks; | 252 ResolutionCallbacks get resolutionCallbacks; |
| 253 | 253 |
| 254 // TODO(johnniwinther): Move this to the JavaScriptBackend. |
| 255 String get patchVersion => null; |
| 256 |
| 254 /// Set of classes that need to be considered for reflection although not | 257 /// Set of classes that need to be considered for reflection although not |
| 255 /// otherwise visible during resolution. | 258 /// otherwise visible during resolution. |
| 256 Iterable<ClassElement> classesRequiredForReflection = const []; | 259 Iterable<ClassElement> classesRequiredForReflection = const []; |
| 257 | 260 |
| 258 // Given a [FunctionElement], return a buffer with the code generated for it | 261 // Given a [FunctionElement], return a buffer with the code generated for it |
| 259 // or null if no code was generated. | 262 // or null if no code was generated. |
| 260 CodeBuffer codeOf(Element element) => null; | 263 CodeBuffer codeOf(Element element) => null; |
| 261 | 264 |
| 262 void initializeHelperClasses() {} | 265 void initializeHelperClasses() {} |
| 263 | 266 |
| (...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 793 ClassElement get streamClass => _coreTypes.streamClass; | 796 ClassElement get streamClass => _coreTypes.streamClass; |
| 794 | 797 |
| 795 CoreTypes get coreTypes => _coreTypes; | 798 CoreTypes get coreTypes => _coreTypes; |
| 796 | 799 |
| 797 ClassElement typedDataClass; | 800 ClassElement typedDataClass; |
| 798 | 801 |
| 799 /// The constant for the [proxy] variable defined in dart:core. | 802 /// The constant for the [proxy] variable defined in dart:core. |
| 800 ConstantValue proxyConstant; | 803 ConstantValue proxyConstant; |
| 801 | 804 |
| 802 // TODO(johnniwinther): Move this to the JavaScriptBackend. | 805 // TODO(johnniwinther): Move this to the JavaScriptBackend. |
| 803 /// The constant for the [patch] variable defined in dart:_js_helper. | 806 /// The class for patch annotation defined in dart:_js_helper. |
| 804 ConstantValue patchConstant; | 807 ClassElement patchAnnotationClass; |
| 805 | 808 |
| 806 // TODO(johnniwinther): Move this to the JavaScriptBackend. | 809 // TODO(johnniwinther): Move this to the JavaScriptBackend. |
| 807 ClassElement nativeAnnotationClass; | 810 ClassElement nativeAnnotationClass; |
| 808 | 811 |
| 809 // Initialized after symbolClass has been resolved. | 812 // Initialized after symbolClass has been resolved. |
| 810 FunctionElement symbolConstructor; | 813 FunctionElement symbolConstructor; |
| 811 | 814 |
| 812 // Initialized when dart:mirrors is loaded. | 815 // Initialized when dart:mirrors is loaded. |
| 813 ClassElement mirrorSystemClass; | 816 ClassElement mirrorSystemClass; |
| 814 | 817 |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1238 } else if (uri == DART_MIRRORS) { | 1241 } else if (uri == DART_MIRRORS) { |
| 1239 mirrorSystemClass = findRequiredElement(library, 'MirrorSystem'); | 1242 mirrorSystemClass = findRequiredElement(library, 'MirrorSystem'); |
| 1240 mirrorsUsedClass = findRequiredElement(library, 'MirrorsUsed'); | 1243 mirrorsUsedClass = findRequiredElement(library, 'MirrorsUsed'); |
| 1241 } else if (uri == DART_ASYNC) { | 1244 } else if (uri == DART_ASYNC) { |
| 1242 deferredLibraryClass = findRequiredElement(library, 'DeferredLibrary'); | 1245 deferredLibraryClass = findRequiredElement(library, 'DeferredLibrary'); |
| 1243 _coreTypes.futureClass = findRequiredElement(library, 'Future'); | 1246 _coreTypes.futureClass = findRequiredElement(library, 'Future'); |
| 1244 _coreTypes.streamClass = findRequiredElement(library, 'Stream'); | 1247 _coreTypes.streamClass = findRequiredElement(library, 'Stream'); |
| 1245 } else if (uri == DART_NATIVE_TYPED_DATA) { | 1248 } else if (uri == DART_NATIVE_TYPED_DATA) { |
| 1246 typedDataClass = findRequiredElement(library, 'NativeTypedData'); | 1249 typedDataClass = findRequiredElement(library, 'NativeTypedData'); |
| 1247 } else if (uri == js_backend.JavaScriptBackend.DART_JS_HELPER) { | 1250 } else if (uri == js_backend.JavaScriptBackend.DART_JS_HELPER) { |
| 1251 patchAnnotationClass = findRequiredElement(library, '_Patch'); |
| 1248 nativeAnnotationClass = findRequiredElement(library, 'Native'); | 1252 nativeAnnotationClass = findRequiredElement(library, 'Native'); |
| 1249 } | 1253 } |
| 1250 return backend.onLibraryScanned(library, loader); | 1254 return backend.onLibraryScanned(library, loader); |
| 1251 } | 1255 } |
| 1252 | 1256 |
| 1253 /// This method is called when all new libraries loaded through | 1257 /// This method is called when all new libraries loaded through |
| 1254 /// [LibraryLoader.loadLibrary] has been loaded and their imports/exports | 1258 /// [LibraryLoader.loadLibrary] has been loaded and their imports/exports |
| 1255 /// have been computed. | 1259 /// have been computed. |
| 1256 /// | 1260 /// |
| 1257 /// [loadedLibraries] contains the newly loaded libraries. | 1261 /// [loadedLibraries] contains the newly loaded libraries. |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1320 MessageKind.IMPORT_EXPERIMENTAL_MIRRORS_PADDING)}); | 1324 MessageKind.IMPORT_EXPERIMENTAL_MIRRORS_PADDING)}); |
| 1321 } | 1325 } |
| 1322 | 1326 |
| 1323 functionClass.ensureResolved(this); | 1327 functionClass.ensureResolved(this); |
| 1324 functionApplyMethod = functionClass.lookupLocalMember('apply'); | 1328 functionApplyMethod = functionClass.lookupLocalMember('apply'); |
| 1325 | 1329 |
| 1326 proxyConstant = | 1330 proxyConstant = |
| 1327 resolver.constantCompiler.compileConstant( | 1331 resolver.constantCompiler.compileConstant( |
| 1328 coreLibrary.find('proxy')).value; | 1332 coreLibrary.find('proxy')).value; |
| 1329 | 1333 |
| 1330 // TODO(johnniwinther): Move this to the JavaScript backend. | |
| 1331 LibraryElement jsHelperLibrary = loadedLibraries.getLibrary( | |
| 1332 js_backend.JavaScriptBackend.DART_JS_HELPER); | |
| 1333 if (jsHelperLibrary != null) { | |
| 1334 patchConstant = resolver.constantCompiler.compileConstant( | |
| 1335 jsHelperLibrary.find('patch')).value; | |
| 1336 } | |
| 1337 | |
| 1338 if (preserveComments) { | 1334 if (preserveComments) { |
| 1339 return libraryLoader.loadLibrary(DART_MIRRORS) | 1335 return libraryLoader.loadLibrary(DART_MIRRORS) |
| 1340 .then((LibraryElement libraryElement) { | 1336 .then((LibraryElement libraryElement) { |
| 1341 documentClass = libraryElement.find('Comment'); | 1337 documentClass = libraryElement.find('Comment'); |
| 1342 }); | 1338 }); |
| 1343 } | 1339 } |
| 1344 }).then((_) => backend.onLibrariesLoaded(loadedLibraries)); | 1340 }).then((_) => backend.onLibrariesLoaded(loadedLibraries)); |
| 1345 } | 1341 } |
| 1346 | 1342 |
| 1347 Element findRequiredElement(LibraryElement library, String name) { | 1343 Element findRequiredElement(LibraryElement library, String name) { |
| 1348 var element = library.find(name); | 1344 var element = library.find(name); |
| 1349 if (element == null) { | 1345 if (element == null) { |
| 1350 internalError(library, | 1346 internalError(library, |
| 1351 "The library '${library.canonicalUri}' does not contain required " | 1347 "The library '${library.canonicalUri}' does not contain required " |
| 1352 "element: '$name'."); | 1348 "element: '$name'."); |
| 1353 } | 1349 } |
| 1354 return element; | 1350 return element; |
| 1355 } | 1351 } |
| 1356 | 1352 |
| 1353 // TODO(johnniwinther): Move this to [PatchParser] when it is moved to the |
| 1354 // [JavaScriptBackend]. Currently needed for testing. |
| 1355 String get patchVersion => backend.patchVersion; |
| 1356 |
| 1357 void onClassResolved(ClassElement cls) { | 1357 void onClassResolved(ClassElement cls) { |
| 1358 if (mirrorSystemClass == cls) { | 1358 if (mirrorSystemClass == cls) { |
| 1359 mirrorSystemGetNameFunction = | 1359 mirrorSystemGetNameFunction = |
| 1360 cls.lookupLocalMember('getName'); | 1360 cls.lookupLocalMember('getName'); |
| 1361 } else if (symbolClass == cls) { | 1361 } else if (symbolClass == cls) { |
| 1362 symbolConstructor = cls.constructors.head; | 1362 symbolConstructor = cls.constructors.head; |
| 1363 } else if (symbolImplementationClass == cls) { | 1363 } else if (symbolImplementationClass == cls) { |
| 1364 symbolValidatedConstructor = symbolImplementationClass.lookupConstructor( | 1364 symbolValidatedConstructor = symbolImplementationClass.lookupConstructor( |
| 1365 symbolValidatedConstructorSelector); | 1365 symbolValidatedConstructorSelector); |
| 1366 } else if (mirrorsUsedClass == cls) { | 1366 } else if (mirrorsUsedClass == cls) { |
| (...skipping 1029 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2396 InterfaceType get nullType => nullClass.computeType(compiler); | 2396 InterfaceType get nullType => nullClass.computeType(compiler); |
| 2397 | 2397 |
| 2398 @override | 2398 @override |
| 2399 InterfaceType get numType => numClass.computeType(compiler); | 2399 InterfaceType get numType => numClass.computeType(compiler); |
| 2400 | 2400 |
| 2401 @override | 2401 @override |
| 2402 InterfaceType get stringType => stringClass.computeType(compiler); | 2402 InterfaceType get stringType => stringClass.computeType(compiler); |
| 2403 } | 2403 } |
| 2404 | 2404 |
| 2405 typedef void InternalErrorFunction(Spannable location, String message); | 2405 typedef void InternalErrorFunction(Spannable location, String message); |
| OLD | NEW |