| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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.kernel.impact_test; | 5 library dart2js.kernel.impact_test; |
| 6 | 6 |
| 7 import 'package:async_helper/async_helper.dart'; | 7 import 'package:async_helper/async_helper.dart'; |
| 8 import 'package:compiler/src/commandline_options.dart'; | 8 import 'package:compiler/src/commandline_options.dart'; |
| 9 import 'package:compiler/src/common.dart'; | 9 import 'package:compiler/src/common.dart'; |
| 10 import 'package:compiler/src/common/names.dart'; | 10 import 'package:compiler/src/common/names.dart'; |
| (...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 700 ResolutionImpact laxImpact( | 700 ResolutionImpact laxImpact( |
| 701 Compiler compiler, AstElement element, ResolutionImpact impact) { | 701 Compiler compiler, AstElement element, ResolutionImpact impact) { |
| 702 ResolutionWorldImpactBuilder builder = | 702 ResolutionWorldImpactBuilder builder = |
| 703 new ResolutionWorldImpactBuilder('Lax impact of ${element}'); | 703 new ResolutionWorldImpactBuilder('Lax impact of ${element}'); |
| 704 for (StaticUse staticUse in impact.staticUses) { | 704 for (StaticUse staticUse in impact.staticUses) { |
| 705 switch (staticUse.kind) { | 705 switch (staticUse.kind) { |
| 706 case StaticUseKind.CONSTRUCTOR_INVOKE: | 706 case StaticUseKind.CONSTRUCTOR_INVOKE: |
| 707 case StaticUseKind.CONST_CONSTRUCTOR_INVOKE: | 707 case StaticUseKind.CONST_CONSTRUCTOR_INVOKE: |
| 708 ConstructorElement constructor = staticUse.element; | 708 ConstructorElement constructor = staticUse.element; |
| 709 ConstructorElement effectiveTarget = constructor.effectiveTarget; | 709 ConstructorElement effectiveTarget = constructor.effectiveTarget; |
| 710 DartType effectiveTargetType = | 710 ResolutionDartType effectiveTargetType = |
| 711 constructor.computeEffectiveTargetType(staticUse.type); | 711 constructor.computeEffectiveTargetType(staticUse.type); |
| 712 builder.registerStaticUse( | 712 builder.registerStaticUse( |
| 713 staticUse.kind == StaticUseKind.CONST_CONSTRUCTOR_INVOKE | 713 staticUse.kind == StaticUseKind.CONST_CONSTRUCTOR_INVOKE |
| 714 ? new StaticUse.constConstructorInvoke( | 714 ? new StaticUse.constConstructorInvoke( |
| 715 effectiveTarget.declaration, null, effectiveTargetType) | 715 effectiveTarget.declaration, null, effectiveTargetType) |
| 716 : new StaticUse.typedConstructorInvoke( | 716 : new StaticUse.typedConstructorInvoke( |
| 717 effectiveTarget.declaration, null, effectiveTargetType)); | 717 effectiveTarget.declaration, null, effectiveTargetType)); |
| 718 break; | 718 break; |
| 719 default: | 719 default: |
| 720 builder.registerStaticUse(staticUse); | 720 builder.registerStaticUse(staticUse); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 784 default: | 784 default: |
| 785 builder.registerFeature(feature); | 785 builder.registerFeature(feature); |
| 786 break; | 786 break; |
| 787 } | 787 } |
| 788 } | 788 } |
| 789 impact.nativeData.forEach(builder.registerNativeData); | 789 impact.nativeData.forEach(builder.registerNativeData); |
| 790 return builder; | 790 return builder; |
| 791 } | 791 } |
| 792 | 792 |
| 793 /// Visitor the performers unaliasing of all typedefs nested within a | 793 /// Visitor the performers unaliasing of all typedefs nested within a |
| 794 /// [DartType]. | 794 /// [ResolutionDartType]. |
| 795 class Unaliaser extends BaseDartTypeVisitor<dynamic, DartType> { | 795 class Unaliaser extends BaseDartTypeVisitor<dynamic, ResolutionDartType> { |
| 796 const Unaliaser(); | 796 const Unaliaser(); |
| 797 | 797 |
| 798 @override | 798 @override |
| 799 DartType visit(DartType type, [_]) => type.accept(this, null); | 799 ResolutionDartType visit(ResolutionDartType type, [_]) => |
| 800 type.accept(this, null); |
| 800 | 801 |
| 801 @override | 802 @override |
| 802 DartType visitType(DartType type, _) => type; | 803 ResolutionDartType visitType(ResolutionDartType type, _) => type; |
| 803 | 804 |
| 804 List<DartType> visitList(List<DartType> types) => types.map(visit).toList(); | 805 List<ResolutionDartType> visitList(List<ResolutionDartType> types) => |
| 806 types.map(visit).toList(); |
| 805 | 807 |
| 806 @override | 808 @override |
| 807 DartType visitInterfaceType(InterfaceType type, _) { | 809 ResolutionDartType visitInterfaceType(ResolutionInterfaceType type, _) { |
| 808 return type.createInstantiation(visitList(type.typeArguments)); | 810 return type.createInstantiation(visitList(type.typeArguments)); |
| 809 } | 811 } |
| 810 | 812 |
| 811 @override | 813 @override |
| 812 DartType visitTypedefType(TypedefType type, _) { | 814 ResolutionDartType visitTypedefType(ResolutionTypedefType type, _) { |
| 813 return visit(type.unaliased); | 815 return visit(type.unaliased); |
| 814 } | 816 } |
| 815 | 817 |
| 816 @override | 818 @override |
| 817 DartType visitFunctionType(FunctionType type, _) { | 819 ResolutionDartType visitFunctionType(ResolutionFunctionType type, _) { |
| 818 return new FunctionType.synthesized( | 820 return new ResolutionFunctionType.synthesized( |
| 819 visit(type.returnType), | 821 visit(type.returnType), |
| 820 visitList(type.parameterTypes), | 822 visitList(type.parameterTypes), |
| 821 visitList(type.optionalParameterTypes), | 823 visitList(type.optionalParameterTypes), |
| 822 type.namedParameters, | 824 type.namedParameters, |
| 823 visitList(type.namedParameterTypes)); | 825 visitList(type.namedParameterTypes)); |
| 824 } | 826 } |
| 825 } | 827 } |
| 826 | 828 |
| 827 /// Perform unaliasing of all typedefs nested within a [DartType]. | 829 /// Perform unaliasing of all typedefs nested within a [ResolutionDartType]. |
| 828 DartType unalias(DartType type) { | 830 ResolutionDartType unalias(ResolutionDartType type) { |
| 829 return const Unaliaser().visit(type); | 831 return const Unaliaser().visit(type); |
| 830 } | 832 } |
| OLD | NEW |