| 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 'package:front_end/src/fasta/scanner.dart' show Token; | 7 import 'package:front_end/src/fasta/scanner.dart' show Token; |
| 8 | 8 |
| 9 import '../../compiler_new.dart' as api; | 9 import '../../compiler_new.dart' as api; |
| 10 import '../common.dart'; | 10 import '../common.dart'; |
| 11 import '../common_elements.dart'; | |
| 12 import '../common/backend_api.dart'; | 11 import '../common/backend_api.dart'; |
| 13 import '../common/names.dart'; | 12 import '../common/names.dart'; |
| 14 import '../common/resolution.dart'; | 13 import '../common/resolution.dart'; |
| 15 import '../common/tasks.dart'; | 14 import '../common/tasks.dart'; |
| 16 import '../common/work.dart'; | 15 import '../common/work.dart'; |
| 16 import '../common_elements.dart'; |
| 17 import '../compiler.dart'; | 17 import '../compiler.dart'; |
| 18 import '../constants/expressions.dart' show ConstantExpression; |
| 18 import '../constants/values.dart'; | 19 import '../constants/values.dart'; |
| 19 import '../elements/elements.dart'; | 20 import '../elements/elements.dart'; |
| 20 import '../elements/entities.dart'; | 21 import '../elements/entities.dart'; |
| 21 import '../elements/modelx.dart'; | 22 import '../elements/modelx.dart'; |
| 22 import '../elements/resolution_types.dart'; | 23 import '../elements/resolution_types.dart'; |
| 23 import '../elements/types.dart'; | 24 import '../elements/types.dart'; |
| 25 import '../enqueue.dart'; |
| 24 import '../environment.dart'; | 26 import '../environment.dart'; |
| 25 import '../enqueue.dart'; | |
| 26 import '../frontend_strategy.dart'; | 27 import '../frontend_strategy.dart'; |
| 27 import '../js_backend/backend.dart'; | 28 import '../js_backend/backend.dart'; |
| 28 import '../js_backend/backend_usage.dart'; | 29 import '../js_backend/backend_usage.dart'; |
| 29 import '../js_backend/interceptor_data.dart'; | 30 import '../js_backend/interceptor_data.dart'; |
| 30 import '../js_backend/mirrors_analysis.dart'; | 31 import '../js_backend/mirrors_analysis.dart'; |
| 31 import '../js_backend/mirrors_data.dart'; | 32 import '../js_backend/mirrors_data.dart'; |
| 32 import '../js_backend/native_data.dart'; | 33 import '../js_backend/native_data.dart'; |
| 33 import '../js_backend/no_such_method_registry.dart'; | 34 import '../js_backend/no_such_method_registry.dart'; |
| 34 import '../js_backend/runtime_types.dart'; | 35 import '../js_backend/runtime_types.dart'; |
| 35 import '../library_loader.dart'; | 36 import '../library_loader.dart'; |
| 36 import '../native/enqueue.dart' show NativeResolutionEnqueuer; | 37 import '../native/enqueue.dart' show NativeResolutionEnqueuer; |
| 37 import '../native/resolver.dart'; | 38 import '../native/resolver.dart'; |
| 38 import '../options.dart'; | 39 import '../options.dart'; |
| 39 import '../tree/tree.dart' show Node; | |
| 40 import '../serialization/task.dart'; | |
| 41 import '../patch_parser.dart'; | 40 import '../patch_parser.dart'; |
| 42 import '../resolved_uri_translator.dart'; | 41 import '../resolved_uri_translator.dart'; |
| 42 import '../serialization/task.dart'; |
| 43 import '../tree/tree.dart' show Node; |
| 43 import '../universe/call_structure.dart'; | 44 import '../universe/call_structure.dart'; |
| 44 import '../universe/use.dart'; | 45 import '../universe/use.dart'; |
| 45 import '../universe/world_builder.dart'; | 46 import '../universe/world_builder.dart'; |
| 46 import '../universe/world_impact.dart'; | 47 import '../universe/world_impact.dart'; |
| 47 import 'no_such_method_resolver.dart'; | 48 import 'no_such_method_resolver.dart'; |
| 48 | 49 |
| 49 /// [FrontendStrategy] that loads '.dart' files and creates a resolved element | 50 /// [FrontendStrategy] that loads '.dart' files and creates a resolved element |
| 50 /// model using the resolver. | 51 /// model using the resolver. |
| 51 class ResolutionFrontEndStrategy extends FrontendStrategyBase | 52 class ResolutionFrontEndStrategy extends FrontendStrategyBase |
| 52 with ComputeSpannableMixin { | 53 with ComputeSpannableMixin { |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 MemberElement member = _member; | 511 MemberElement member = _member; |
| 511 if (member.isSynthesized) return; | 512 if (member.isSynthesized) return; |
| 512 if (member.isMalformed) return; | 513 if (member.isMalformed) return; |
| 513 if (member.isConstructor) return; | 514 if (member.isConstructor) return; |
| 514 f(declarer, member); | 515 f(declarer, member); |
| 515 }, includeSuperAndInjectedMembers: true); | 516 }, includeSuperAndInjectedMembers: true); |
| 516 } | 517 } |
| 517 | 518 |
| 518 @override | 519 @override |
| 519 void forEachConstructor( | 520 void forEachConstructor( |
| 520 covariant ClassElement cls, void f(ConstructorEntity constructor)) { | 521 covariant ClassElement cls, void f(ConstructorEntity constructor), |
| 521 cls.ensureResolved(_resolution); | 522 {bool ensureResolved: true}) { |
| 523 if (ensureResolved) cls.ensureResolved(_resolution); |
| 522 for (ConstructorElement constructor in cls.implementation.constructors) { | 524 for (ConstructorElement constructor in cls.implementation.constructors) { |
| 523 _resolution.ensureResolved(constructor.declaration); | 525 if (ensureResolved) _resolution.ensureResolved(constructor.declaration); |
| 524 if (constructor.isRedirectingFactory) continue; | 526 if (constructor.isRedirectingFactory) continue; |
| 525 f(constructor); | 527 f(constructor); |
| 526 } | 528 } |
| 527 } | 529 } |
| 528 | 530 |
| 529 @override | 531 @override |
| 530 void forEachConstructorBody( | 532 void forEachConstructorBody( |
| 531 covariant ClassElement cls, void f(ConstructorBodyEntity constructor)) { | 533 covariant ClassElement cls, void f(ConstructorBodyEntity constructor)) { |
| 532 cls.forEachConstructorBody(f); | 534 cls.forEachConstructorBody(f); |
| 533 } | 535 } |
| 534 | 536 |
| 535 @override | 537 @override |
| 538 void forEachNestedClosure( |
| 539 covariant MemberElement member, void f(FunctionEntity closure)) { |
| 540 for (var closure in member.nestedClosures) { |
| 541 f(closure); |
| 542 } |
| 543 } |
| 544 |
| 545 @override |
| 536 ClassEntity getSuperClass(covariant ClassElement cls, | 546 ClassEntity getSuperClass(covariant ClassElement cls, |
| 537 {bool skipUnnamedMixinApplications: false}) { | 547 {bool skipUnnamedMixinApplications: false}) { |
| 538 cls.ensureResolved(_resolution); | 548 cls.ensureResolved(_resolution); |
| 539 ClassElement superclass = cls.superclass; | 549 ClassElement superclass = cls.superclass; |
| 540 if (skipUnnamedMixinApplications) { | 550 if (skipUnnamedMixinApplications) { |
| 541 while (superclass != null && superclass.isUnnamedMixinApplication) { | 551 while (superclass != null && superclass.isUnnamedMixinApplication) { |
| 542 superclass = superclass.superclass; | 552 superclass = superclass.superclass; |
| 543 } | 553 } |
| 544 } | 554 } |
| 545 return superclass; | 555 return superclass; |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 673 return field.type; | 683 return field.type; |
| 674 } | 684 } |
| 675 | 685 |
| 676 @override | 686 @override |
| 677 ResolutionFunctionType getLocalFunctionType( | 687 ResolutionFunctionType getLocalFunctionType( |
| 678 covariant LocalFunctionElement function) { | 688 covariant LocalFunctionElement function) { |
| 679 return function.type; | 689 return function.type; |
| 680 } | 690 } |
| 681 | 691 |
| 682 @override | 692 @override |
| 693 ConstantExpression getFieldConstant(covariant FieldElement field) { |
| 694 return field.constant; |
| 695 } |
| 696 |
| 697 @override |
| 683 ResolutionDartType getUnaliasedType(covariant ResolutionDartType type) { | 698 ResolutionDartType getUnaliasedType(covariant ResolutionDartType type) { |
| 684 type.computeUnaliased(_resolution); | 699 type.computeUnaliased(_resolution); |
| 685 return type.unaliased; | 700 return type.unaliased; |
| 686 } | 701 } |
| 687 | 702 |
| 688 @override | 703 @override |
| 689 Iterable<ConstantValue> getMemberMetadata(covariant MemberElement element, | 704 Iterable<ConstantValue> getMemberMetadata(covariant MemberElement element, |
| 690 {bool includeParameterMetadata: false}) { | 705 {bool includeParameterMetadata: false}) { |
| 691 List<ConstantValue> values = <ConstantValue>[]; | 706 List<ConstantValue> values = <ConstantValue>[]; |
| 692 values.addAll(_getMetadataOf(element)); | 707 values.addAll(_getMetadataOf(element)); |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 958 | 973 |
| 959 @override | 974 @override |
| 960 void forEachConstructor( | 975 void forEachConstructor( |
| 961 covariant ClassElement cls, void f(ConstructorEntity constructor)) { | 976 covariant ClassElement cls, void f(ConstructorEntity constructor)) { |
| 962 cls.constructors.forEach((Element _constructor) { | 977 cls.constructors.forEach((Element _constructor) { |
| 963 ConstructorElement constructor = _constructor; | 978 ConstructorElement constructor = _constructor; |
| 964 f(constructor); | 979 f(constructor); |
| 965 }); | 980 }); |
| 966 } | 981 } |
| 967 } | 982 } |
| OLD | NEW |