| 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 library dart2js.backend_api; | 5 library dart2js.backend_api; |
| 6 | 6 |
| 7 import 'dart:async' show Future; | 7 import 'dart:async' show Future; |
| 8 | 8 |
| 9 import '../common.dart'; | 9 import '../common.dart'; |
| 10 import '../common/codegen.dart' show CodegenImpact; | 10 import '../common/codegen.dart' show CodegenImpact; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 /// supported by the backend. | 124 /// supported by the backend. |
| 125 bool enableCodegenWithErrorsIfSupported(Spannable node); | 125 bool enableCodegenWithErrorsIfSupported(Spannable node); |
| 126 | 126 |
| 127 /// Enable deferred loading. Returns `true` if the backend supports deferred | 127 /// Enable deferred loading. Returns `true` if the backend supports deferred |
| 128 /// loading. | 128 /// loading. |
| 129 bool enableDeferredLoadingIfSupported(Spannable node, Registry registry); | 129 bool enableDeferredLoadingIfSupported(Spannable node, Registry registry); |
| 130 | 130 |
| 131 /// Called during codegen when [constant] has been used. | 131 /// Called during codegen when [constant] has been used. |
| 132 void registerCompileTimeConstant(ConstantValue constant, Registry registry) {} | 132 void registerCompileTimeConstant(ConstantValue constant, Registry registry) {} |
| 133 | 133 |
| 134 /// Called during resolution when a constant value for [metadata] on |
| 135 /// [annotatedElement] has been evaluated. |
| 136 void registerMetadataConstant(MetadataAnnotation metadata, |
| 137 Element annotatedElement, Registry registry) {} |
| 138 |
| 134 /// Called to notify to the backend that a class is being instantiated. | 139 /// Called to notify to the backend that a class is being instantiated. |
| 135 // TODO(johnniwinther): Remove this. It's only called once for each [cls] and | 140 // TODO(johnniwinther): Remove this. It's only called once for each [cls] and |
| 136 // only with [Compiler.globalDependencies] as [registry]. | 141 // only with [Compiler.globalDependencies] as [registry]. |
| 137 void registerInstantiatedClass( | 142 void registerInstantiatedClass( |
| 138 ClassElement cls, Enqueuer enqueuer, Registry registry) {} | 143 ClassElement cls, Enqueuer enqueuer, Registry registry) {} |
| 139 | 144 |
| 140 /// Called to notify to the backend that a class is implemented by an | 145 /// Called to notify to the backend that a class is implemented by an |
| 141 /// instantiated class. | 146 /// instantiated class. |
| 142 void registerImplementedClass( | 147 void registerImplementedClass( |
| 143 ClassElement cls, Enqueuer enqueuer, Registry registry) {} | 148 ClassElement cls, Enqueuer enqueuer, Registry registry) {} |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 void registerStaticUse(Element element, Enqueuer enqueuer) {} | 271 void registerStaticUse(Element element, Enqueuer enqueuer) {} |
| 267 | 272 |
| 268 /// This method is called immediately after the [LibraryElement] [library] has | 273 /// This method is called immediately after the [LibraryElement] [library] has |
| 269 /// been created. | 274 /// been created. |
| 270 void onLibraryCreated(LibraryElement library) {} | 275 void onLibraryCreated(LibraryElement library) {} |
| 271 | 276 |
| 272 /// This method is called immediately after the [library] and its parts have | 277 /// This method is called immediately after the [library] and its parts have |
| 273 /// been scanned. | 278 /// been scanned. |
| 274 Future onLibraryScanned(LibraryElement library, LibraryLoader loader) { | 279 Future onLibraryScanned(LibraryElement library, LibraryLoader loader) { |
| 275 // TODO(johnniwinther): Move this to [JavaScriptBackend]. | 280 // TODO(johnniwinther): Move this to [JavaScriptBackend]. |
| 276 if (!compiler.serialization.isDeserialized(library)) { | 281 if (canLibraryUseNative(library)) { |
| 277 if (canLibraryUseNative(library)) { | |
| 278 library.forEachLocalMember((Element element) { | |
| 279 if (element.isClass) { | |
| 280 checkNativeAnnotation(compiler, element); | |
| 281 } | |
| 282 }); | |
| 283 } | |
| 284 checkJsInteropAnnotation(compiler, library); | |
| 285 library.forEachLocalMember((Element element) { | 282 library.forEachLocalMember((Element element) { |
| 286 checkJsInteropAnnotation(compiler, element); | 283 if (element.isClass) { |
| 287 if (element.isClass && isJsInterop(element)) { | 284 checkNativeAnnotation(compiler, element); |
| 288 ClassElement classElement = element; | |
| 289 classElement.forEachMember((_, memberElement) { | |
| 290 checkJsInteropAnnotation(compiler, memberElement); | |
| 291 }); | |
| 292 } | 285 } |
| 293 }); | 286 }); |
| 294 } | 287 } |
| 288 checkJsInteropAnnotation(compiler, library); |
| 289 library.forEachLocalMember((Element element) { |
| 290 checkJsInteropAnnotation(compiler, element); |
| 291 if (element.isClass && isJsInterop(element)) { |
| 292 ClassElement classElement = element; |
| 293 classElement.forEachMember((_, memberElement) { |
| 294 checkJsInteropAnnotation(compiler, memberElement); |
| 295 }); |
| 296 } |
| 297 }); |
| 295 return new Future.value(); | 298 return new Future.value(); |
| 296 } | 299 } |
| 297 | 300 |
| 298 /// This method is called when all new libraries loaded through | 301 /// This method is called when all new libraries loaded through |
| 299 /// [LibraryLoader.loadLibrary] has been loaded and their imports/exports | 302 /// [LibraryLoader.loadLibrary] has been loaded and their imports/exports |
| 300 /// have been computed. | 303 /// have been computed. |
| 301 Future onLibrariesLoaded(LoadedLibraries loadedLibraries) { | 304 Future onLibrariesLoaded(LoadedLibraries loadedLibraries) { |
| 302 return new Future.value(); | 305 return new Future.value(); |
| 303 } | 306 } |
| 304 | 307 |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 } | 438 } |
| 436 } | 439 } |
| 437 | 440 |
| 438 /// Interface for serialization of backend specific data. | 441 /// Interface for serialization of backend specific data. |
| 439 class BackendSerialization { | 442 class BackendSerialization { |
| 440 const BackendSerialization(); | 443 const BackendSerialization(); |
| 441 | 444 |
| 442 SerializerPlugin get serializer => const SerializerPlugin(); | 445 SerializerPlugin get serializer => const SerializerPlugin(); |
| 443 DeserializerPlugin get deserializer => const DeserializerPlugin(); | 446 DeserializerPlugin get deserializer => const DeserializerPlugin(); |
| 444 } | 447 } |
| OLD | NEW |