| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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.resolution_strategy; | 5 library dart2js.resolution_strategy; |
| 6 | 6 |
| 7 import '../common.dart'; | 7 import '../common.dart'; |
| 8 import '../common_elements.dart'; | 8 import '../common_elements.dart'; |
| 9 import '../common/backend_api.dart'; | 9 import '../common/backend_api.dart'; |
| 10 import '../common/names.dart'; | 10 import '../common/names.dart'; |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 "contain required member: '$name'."); | 287 "contain required member: '$name'."); |
| 288 } | 288 } |
| 289 return member?.declaration; | 289 return member?.declaration; |
| 290 } | 290 } |
| 291 | 291 |
| 292 @override | 292 @override |
| 293 ConstructorElement lookupConstructor(ClassElement cls, String name, | 293 ConstructorElement lookupConstructor(ClassElement cls, String name, |
| 294 {bool required: false}) { | 294 {bool required: false}) { |
| 295 cls.ensureResolved(_resolution); | 295 cls.ensureResolved(_resolution); |
| 296 ConstructorElement constructor = cls.implementation.lookupConstructor(name); | 296 ConstructorElement constructor = cls.implementation.lookupConstructor(name); |
| 297 // TODO(johnniwinther): Skip redirecting factories. |
| 297 if (constructor == null && required) { | 298 if (constructor == null && required) { |
| 298 throw new SpannableAssertionFailure( | 299 throw new SpannableAssertionFailure( |
| 299 cls, | 300 cls, |
| 300 "The class '${cls.name}' does not contain " | 301 "The class '${cls.name}' does not contain " |
| 301 "required constructor: '$name'."); | 302 "required constructor: '$name'."); |
| 302 } | 303 } |
| 303 return constructor?.declaration; | 304 return constructor?.declaration; |
| 304 } | 305 } |
| 305 | 306 |
| 306 @override | 307 @override |
| 307 void forEachClassMember( | 308 void forEachClassMember( |
| 308 ClassElement cls, void f(ClassElement declarer, MemberElement member)) { | 309 ClassElement cls, void f(ClassElement declarer, MemberElement member)) { |
| 309 cls.ensureResolved(_resolution); | 310 cls.ensureResolved(_resolution); |
| 310 cls.forEachMember((ClassElement declarer, MemberElement member) { | 311 cls.forEachMember((ClassElement declarer, MemberElement member) { |
| 311 if (member.isSynthesized) return; | 312 if (member.isSynthesized) return; |
| 312 if (member.isMalformed) return; | 313 if (member.isMalformed) return; |
| 313 if (member.isConstructor) return; | 314 if (member.isConstructor) return; |
| 314 f(declarer, member); | 315 f(declarer, member); |
| 315 }, includeSuperAndInjectedMembers: true); | 316 }, includeSuperAndInjectedMembers: true); |
| 316 } | 317 } |
| 317 | 318 |
| 318 @override | 319 @override |
| 320 void forEachConstructor( |
| 321 ClassElement cls, void f(ConstructorEntity constructor)) { |
| 322 cls.ensureResolved(_resolution); |
| 323 for (ConstructorElement constructor in cls.implementation.constructors) { |
| 324 _resolution.ensureResolved(constructor.declaration); |
| 325 if (constructor.isRedirectingFactory) continue; |
| 326 f(constructor); |
| 327 } |
| 328 } |
| 329 |
| 330 @override |
| 319 ClassEntity getSuperClass(ClassElement cls, | 331 ClassEntity getSuperClass(ClassElement cls, |
| 320 {bool skipUnnamedMixinApplications: false}) { | 332 {bool skipUnnamedMixinApplications: false}) { |
| 321 cls.ensureResolved(_resolution); | 333 cls.ensureResolved(_resolution); |
| 322 ClassElement superclass = cls.superclass; | 334 ClassElement superclass = cls.superclass; |
| 323 if (skipUnnamedMixinApplications) { | 335 if (skipUnnamedMixinApplications) { |
| 324 while (superclass != null && superclass.isUnnamedMixinApplication) { | 336 while (superclass != null && superclass.isUnnamedMixinApplication) { |
| 325 superclass = superclass.superclass; | 337 superclass = superclass.superclass; |
| 326 } | 338 } |
| 327 } | 339 } |
| 328 return superclass; | 340 return superclass; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 if (member == null && required) { | 378 if (member == null && required) { |
| 367 throw new SpannableAssertionFailure( | 379 throw new SpannableAssertionFailure( |
| 368 member, | 380 member, |
| 369 "The library '${library.libraryName}' does not " | 381 "The library '${library.libraryName}' does not " |
| 370 "contain required member: '$name'."); | 382 "contain required member: '$name'."); |
| 371 } | 383 } |
| 372 return member?.declaration; | 384 return member?.declaration; |
| 373 } | 385 } |
| 374 | 386 |
| 375 @override | 387 @override |
| 388 void forEachLibraryMember( |
| 389 LibraryElement library, void f(MemberEntity member)) { |
| 390 library.implementation.forEachLocalMember((Element element) { |
| 391 if (!element.isClass && !element.isTypedef) { |
| 392 MemberElement member = element; |
| 393 f(member); |
| 394 } |
| 395 }); |
| 396 } |
| 397 |
| 398 @override |
| 376 ClassElement lookupClass(LibraryElement library, String name, | 399 ClassElement lookupClass(LibraryElement library, String name, |
| 377 {bool required: false}) { | 400 {bool required: false}) { |
| 378 ClassElement cls = library.implementation.findLocal(name); | 401 ClassElement cls = library.implementation.findLocal(name); |
| 379 if (cls == null && required) { | 402 if (cls == null && required) { |
| 380 throw new SpannableAssertionFailure( | 403 throw new SpannableAssertionFailure( |
| 381 library, | 404 library, |
| 382 "The library '${library.libraryName}' does not " | 405 "The library '${library.libraryName}' does not " |
| 383 "contain required class: '$name'."); | 406 "contain required class: '$name'."); |
| 384 } | 407 } |
| 385 return cls?.declaration; | 408 return cls?.declaration; |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 663 @override | 686 @override |
| 664 WorkItem createWorkItem(MemberElement element) { | 687 WorkItem createWorkItem(MemberElement element) { |
| 665 assert(invariant(element, element.isDeclaration)); | 688 assert(invariant(element, element.isDeclaration)); |
| 666 if (element.isMalformed) return null; | 689 if (element.isMalformed) return null; |
| 667 | 690 |
| 668 assert(invariant(element, element is AnalyzableElement, | 691 assert(invariant(element, element is AnalyzableElement, |
| 669 message: 'Element $element is not analyzable.')); | 692 message: 'Element $element is not analyzable.')); |
| 670 return _resolution.createWorkItem(element); | 693 return _resolution.createWorkItem(element); |
| 671 } | 694 } |
| 672 } | 695 } |
| OLD | NEW |