| 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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 /// Interface for registration of element dependencies. | 211 /// Interface for registration of element dependencies. |
| 212 abstract class Registry { | 212 abstract class Registry { |
| 213 // TODO(johnniwinther): Remove this getter when [Registry] creates a | 213 // TODO(johnniwinther): Remove this getter when [Registry] creates a |
| 214 // dependency node. | 214 // dependency node. |
| 215 Iterable<Element> get otherDependencies; | 215 Iterable<Element> get otherDependencies; |
| 216 | 216 |
| 217 void registerDependency(Element element); | 217 void registerDependency(Element element); |
| 218 | 218 |
| 219 bool get isForResolution; | 219 bool get isForResolution; |
| 220 | 220 |
| 221 void registerDynamicInvocation(Selector selector); |
| 222 |
| 223 void registerDynamicGetter(Selector selector); |
| 224 |
| 225 void registerDynamicSetter(Selector selector); |
| 226 |
| 221 void registerStaticInvocation(Element element); | 227 void registerStaticInvocation(Element element); |
| 222 | 228 |
| 223 void registerInstantiation(InterfaceType type); | 229 void registerInstantiation(InterfaceType type); |
| 224 | 230 |
| 225 void registerGetOfStaticFunction(FunctionElement element); | 231 void registerGetOfStaticFunction(FunctionElement element); |
| 226 } | 232 } |
| 227 | 233 |
| 228 abstract class Backend { | 234 abstract class Backend { |
| 229 final Compiler compiler; | 235 final Compiler compiler; |
| 230 | 236 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 | 287 |
| 282 /// Called during codegen when [constant] has been used. | 288 /// Called during codegen when [constant] has been used. |
| 283 void registerCompileTimeConstant(ConstantValue constant, Registry registry) {} | 289 void registerCompileTimeConstant(ConstantValue constant, Registry registry) {} |
| 284 | 290 |
| 285 /// Called during resolution when a constant value for [metadata] on | 291 /// Called during resolution when a constant value for [metadata] on |
| 286 /// [annotatedElement] has been evaluated. | 292 /// [annotatedElement] has been evaluated. |
| 287 void registerMetadataConstant(MetadataAnnotation metadata, | 293 void registerMetadataConstant(MetadataAnnotation metadata, |
| 288 Element annotatedElement, | 294 Element annotatedElement, |
| 289 Registry registry) {} | 295 Registry registry) {} |
| 290 | 296 |
| 291 /// Called during resolution to notify to the backend that a class is | 297 /// Called to notify to the backend that a class is being instantiated. |
| 292 /// being instantiated. | 298 // TODO(johnniwinther): Remove this. It's only called once for each [cls] and |
| 299 // only with [Compiler.globalDependencies] as [registry]. |
| 293 void registerInstantiatedClass(ClassElement cls, | 300 void registerInstantiatedClass(ClassElement cls, |
| 294 Enqueuer enqueuer, | 301 Enqueuer enqueuer, |
| 295 Registry registry) {} | 302 Registry registry) {} |
| 296 | 303 |
| 304 /// Called to notify to the backend that an interface type has been |
| 305 /// instantiated. |
| 306 void registerInstantiatedType(InterfaceType type, Registry registry) {} |
| 307 |
| 297 /// Register an is check to the backend. | 308 /// Register an is check to the backend. |
| 298 void registerIsCheckForCodegen(DartType type, | 309 void registerIsCheckForCodegen(DartType type, |
| 299 Enqueuer enqueuer, | 310 Enqueuer enqueuer, |
| 300 Registry registry) {} | 311 Registry registry) {} |
| 301 | 312 |
| 302 /// Register a runtime type variable bound tests between [typeArgument] and | 313 /// Register a runtime type variable bound tests between [typeArgument] and |
| 303 /// [bound]. | 314 /// [bound]. |
| 304 void registerTypeVariableBoundsSubtypeCheck(DartType typeArgument, | 315 void registerTypeVariableBoundsSubtypeCheck(DartType typeArgument, |
| 305 DartType bound) {} | 316 DartType bound) {} |
| 306 | 317 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 ClassElement classElement = element.enclosingClass; | 393 ClassElement classElement = element.enclosingClass; |
| 383 return classElement == compiler.objectClass; | 394 return classElement == compiler.objectClass; |
| 384 } | 395 } |
| 385 | 396 |
| 386 bool isInterceptorClass(ClassElement element) => false; | 397 bool isInterceptorClass(ClassElement element) => false; |
| 387 | 398 |
| 388 /// Returns `true` if [element] is a foreign element, that is, that the | 399 /// Returns `true` if [element] is a foreign element, that is, that the |
| 389 /// backend has specialized handling for the element. | 400 /// backend has specialized handling for the element. |
| 390 bool isForeign(Element element) => false; | 401 bool isForeign(Element element) => false; |
| 391 | 402 |
| 403 /// Processes [element] for resolution and returns the [FunctionElement] that |
| 404 /// defines the implementation of [element]. |
| 405 FunctionElement resolveExternalFunction(FunctionElement element) => element; |
| 406 |
| 392 /// Returns `true` if [library] is a backend specific library whose members | 407 /// Returns `true` if [library] is a backend specific library whose members |
| 393 /// have special treatment, such as being allowed to extends blacklisted | 408 /// have special treatment, such as being allowed to extends blacklisted |
| 394 /// classes or member being eagerly resolved. | 409 /// classes or member being eagerly resolved. |
| 395 bool isBackendLibrary(LibraryElement library) { | 410 bool isBackendLibrary(LibraryElement library) { |
| 396 // TODO(johnnwinther): Remove this when patching is only done by the | 411 // TODO(johnnwinther): Remove this when patching is only done by the |
| 397 // JavaScript backend. | 412 // JavaScript backend. |
| 398 Uri canonicalUri = library.canonicalUri; | 413 Uri canonicalUri = library.canonicalUri; |
| 399 if (canonicalUri == js_backend.JavaScriptBackend.DART_JS_HELPER || | 414 if (canonicalUri == js_backend.JavaScriptBackend.DART_JS_HELPER || |
| 400 canonicalUri == js_backend.JavaScriptBackend.DART_INTERCEPTORS) { | 415 canonicalUri == js_backend.JavaScriptBackend.DART_INTERCEPTORS) { |
| 401 return true; | 416 return true; |
| 402 } | 417 } |
| 403 return false; | 418 return false; |
| 404 } | 419 } |
| 405 | 420 |
| 406 void registerStaticUse(Element element, Enqueuer enqueuer) {} | 421 void registerStaticUse(Element element, Enqueuer enqueuer) {} |
| 407 | 422 |
| 408 /// This method is called immediately after the [LibraryElement] [library] has | 423 /// This method is called immediately after the [LibraryElement] [library] has |
| 409 /// been created. | 424 /// been created. |
| 410 void onLibraryCreated(LibraryElement library) {} | 425 void onLibraryCreated(LibraryElement library) {} |
| 411 | 426 |
| 412 /// This method is called immediately after the [library] and its parts have | 427 /// This method is called immediately after the [library] and its parts have |
| 413 /// been scanned. | 428 /// been scanned. |
| 414 Future onLibraryScanned(LibraryElement library, LibraryLoader loader) { | 429 Future onLibraryScanned(LibraryElement library, LibraryLoader loader) { |
| 415 if (library.isPlatformLibrary && !library.isPatched) { | |
| 416 // Apply patch, if any. | |
| 417 Uri patchUri = compiler.resolvePatchUri(library.canonicalUri.path); | |
| 418 if (patchUri != null) { | |
| 419 return compiler.patchParser.patchLibrary(loader, patchUri, library); | |
| 420 } | |
| 421 } | |
| 422 if (library.canUseNative) { | 430 if (library.canUseNative) { |
| 423 library.forEachLocalMember((Element element) { | 431 library.forEachLocalMember((Element element) { |
| 424 if (element.isClass) { | 432 if (element.isClass) { |
| 425 checkNativeAnnotation(compiler, element); | 433 checkNativeAnnotation(compiler, element); |
| 426 } | 434 } |
| 427 }); | 435 }); |
| 428 } | 436 } |
| 429 return new Future.value(); | 437 return new Future.value(); |
| 430 } | 438 } |
| 431 | 439 |
| (...skipping 1895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2327 } | 2335 } |
| 2328 | 2336 |
| 2329 /// A code location that contains any uri. | 2337 /// A code location that contains any uri. |
| 2330 class AnyLocation implements CodeLocation { | 2338 class AnyLocation implements CodeLocation { |
| 2331 const AnyLocation(); | 2339 const AnyLocation(); |
| 2332 | 2340 |
| 2333 bool inSameLocation(Uri uri) => true; | 2341 bool inSameLocation(Uri uri) => true; |
| 2334 | 2342 |
| 2335 String relativize(Uri baseUri) => '$baseUri'; | 2343 String relativize(Uri baseUri) => '$baseUri'; |
| 2336 } | 2344 } |
| OLD | NEW |