| 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 'dart:async'; | |
| 8 import 'package:async_helper/async_helper.dart'; | 7 import 'package:async_helper/async_helper.dart'; |
| 9 import 'package:compiler/src/commandline_options.dart'; | 8 import 'package:compiler/src/commandline_options.dart'; |
| 10 import 'package:compiler/src/common.dart'; | 9 import 'package:compiler/src/common.dart'; |
| 11 import 'package:compiler/src/common/names.dart'; | 10 import 'package:compiler/src/common/names.dart'; |
| 12 import 'package:compiler/src/common/resolution.dart'; | 11 import 'package:compiler/src/common/resolution.dart'; |
| 13 import 'package:compiler/src/compiler.dart'; | 12 import 'package:compiler/src/compiler.dart'; |
| 13 import 'package:compiler/src/constants/expressions.dart'; |
| 14 import 'package:compiler/src/dart_types.dart'; | 14 import 'package:compiler/src/dart_types.dart'; |
| 15 import 'package:compiler/src/elements/elements.dart'; | 15 import 'package:compiler/src/elements/elements.dart'; |
| 16 import 'package:compiler/src/resolution/registry.dart'; | 16 import 'package:compiler/src/resolution/registry.dart'; |
| 17 import 'package:compiler/src/resolution/tree_elements.dart'; |
| 17 import 'package:compiler/src/ssa/kernel_impact.dart'; | 18 import 'package:compiler/src/ssa/kernel_impact.dart'; |
| 18 import 'package:compiler/src/serialization/equivalence.dart'; | 19 import 'package:compiler/src/serialization/equivalence.dart'; |
| 19 import 'package:compiler/src/universe/call_structure.dart'; | 20 import 'package:compiler/src/universe/call_structure.dart'; |
| 20 import 'package:compiler/src/universe/feature.dart'; | 21 import 'package:compiler/src/universe/feature.dart'; |
| 21 import 'package:compiler/src/universe/use.dart'; | 22 import 'package:compiler/src/universe/use.dart'; |
| 22 import 'package:expect/expect.dart'; | 23 import 'package:expect/expect.dart'; |
| 23 import '../memory_compiler.dart'; | 24 import '../memory_compiler.dart'; |
| 24 import '../serialization/test_helper.dart'; | 25 import '../serialization/test_helper.dart'; |
| 25 | 26 |
| 26 const Map<String, String> SOURCE = const <String, String>{ | 27 const Map<String, String> SOURCE = const <String, String>{ |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 testConstRedirectingFactoryInvoke(); | 145 testConstRedirectingFactoryInvoke(); |
| 145 testConstRedirectingFactoryInvokeGeneric(); | 146 testConstRedirectingFactoryInvokeGeneric(); |
| 146 testConstRedirectingFactoryInvokeGenericRaw(); | 147 testConstRedirectingFactoryInvokeGenericRaw(); |
| 147 testConstRedirectingFactoryInvokeGenericDynamic(); | 148 testConstRedirectingFactoryInvokeGenericDynamic(); |
| 148 testImplicitConstructor(); | 149 testImplicitConstructor(); |
| 149 testFactoryConstructor(); | 150 testFactoryConstructor(); |
| 150 testDefaultValuesPositional(); | 151 testDefaultValuesPositional(); |
| 151 testDefaultValuesNamed(); | 152 testDefaultValuesNamed(); |
| 152 testFieldInitializer1(); | 153 testFieldInitializer1(); |
| 153 testFieldInitializer2(); | 154 testFieldInitializer2(); |
| 155 testFieldInitializer3(); |
| 154 testInstanceFieldWithInitializer(); | 156 testInstanceFieldWithInitializer(); |
| 155 testInstanceFieldTyped(); | 157 testInstanceFieldTyped(); |
| 156 testThisInitializer(); | 158 testThisInitializer(); |
| 157 testSuperInitializer(); | 159 testSuperInitializer(); |
| 158 testGenericClass(); | 160 testGenericClass(); |
| 159 testSuperCall(); | 161 testSuperCall(); |
| 160 testSuperGet(); | 162 testSuperGet(); |
| 161 testSuperFieldSet(); | 163 testSuperFieldSet(); |
| 162 testSuperSetterSet(); | 164 testSuperSetterSet(); |
| 163 testSuperClosurization(); | 165 testSuperClosurization(); |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 class ClassFieldInitializer1 { | 473 class ClassFieldInitializer1 { |
| 472 var field; | 474 var field; |
| 473 ClassFieldInitializer1(this.field); | 475 ClassFieldInitializer1(this.field); |
| 474 } | 476 } |
| 475 testFieldInitializer1() => new ClassFieldInitializer1(42); | 477 testFieldInitializer1() => new ClassFieldInitializer1(42); |
| 476 class ClassFieldInitializer2 { | 478 class ClassFieldInitializer2 { |
| 477 var field; | 479 var field; |
| 478 ClassFieldInitializer2(value) : field = value; | 480 ClassFieldInitializer2(value) : field = value; |
| 479 } | 481 } |
| 480 testFieldInitializer2() => new ClassFieldInitializer2(42); | 482 testFieldInitializer2() => new ClassFieldInitializer2(42); |
| 483 class ClassFieldInitializer3 { |
| 484 var field; |
| 485 ClassFieldInitializer3.a(); |
| 486 ClassFieldInitializer3.b(value) : field = value; |
| 487 } |
| 488 testFieldInitializer3() { |
| 489 new ClassFieldInitializer3.a(); |
| 490 new ClassFieldInitializer3.b(42); |
| 491 } |
| 481 class ClassInstanceFieldWithInitializer { | 492 class ClassInstanceFieldWithInitializer { |
| 482 var field = false; | 493 var field = false; |
| 483 } | 494 } |
| 484 testInstanceFieldWithInitializer() => new ClassInstanceFieldWithInitializer(); | 495 testInstanceFieldWithInitializer() => new ClassInstanceFieldWithInitializer(); |
| 485 class ClassInstanceFieldTyped { | 496 class ClassInstanceFieldTyped { |
| 486 int field; | 497 int field; |
| 487 } | 498 } |
| 488 testInstanceFieldTyped() => new ClassInstanceFieldTyped(); | 499 testInstanceFieldTyped() => new ClassInstanceFieldTyped(); |
| 489 class ClassGeneric<T> { | 500 class ClassGeneric<T> { |
| 490 ClassGeneric(T arg); | 501 ClassGeneric(T arg); |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 664 for (TypeUse typeUse in impact.typeUses) { | 675 for (TypeUse typeUse in impact.typeUses) { |
| 665 builder.registerTypeUse(new TypeUse.internal( | 676 builder.registerTypeUse(new TypeUse.internal( |
| 666 const Unaliaser().visit(typeUse.type), typeUse.kind)); | 677 const Unaliaser().visit(typeUse.type), typeUse.kind)); |
| 667 } | 678 } |
| 668 impact.constantLiterals.forEach(builder.registerConstantLiteral); | 679 impact.constantLiterals.forEach(builder.registerConstantLiteral); |
| 669 impact.constSymbolNames.forEach(builder.registerConstSymbolName); | 680 impact.constSymbolNames.forEach(builder.registerConstSymbolName); |
| 670 impact.listLiterals.forEach(builder.registerListLiteral); | 681 impact.listLiterals.forEach(builder.registerListLiteral); |
| 671 impact.mapLiterals.forEach(builder.registerMapLiteral); | 682 impact.mapLiterals.forEach(builder.registerMapLiteral); |
| 672 for (Feature feature in impact.features) { | 683 for (Feature feature in impact.features) { |
| 673 switch (feature) { | 684 switch (feature) { |
| 685 case Feature.FIELD_WITHOUT_INITIALIZER: |
| 686 if (element.isInstanceMember) { |
| 687 bool missing = false; |
| 688 OUTER: |
| 689 for (ConstructorElement constructor |
| 690 in element.enclosingClass.constructors) { |
| 691 if (constructor.isGenerativeConstructor && |
| 692 !constructor.isRedirectingGenerative) { |
| 693 for (ParameterElement parameter in constructor.parameters) { |
| 694 if (parameter is InitializingFormalElement && |
| 695 parameter.fieldElement == element) { |
| 696 continue OUTER; |
| 697 } |
| 698 } |
| 699 if (constructor.resolvedAst.kind == ResolvedAstKind.PARSED) { |
| 700 var function = constructor.resolvedAst.node; |
| 701 if (function.initializers != null) { |
| 702 TreeElements elements = constructor.resolvedAst.elements; |
| 703 for (var initializer in function.initializers) { |
| 704 if (elements[initializer] == element) { |
| 705 continue OUTER; |
| 706 } |
| 707 } |
| 708 } |
| 709 } |
| 710 missing = true; |
| 711 } |
| 712 } |
| 713 if (!missing) continue; |
| 714 } |
| 715 builder.registerConstantLiteral(new NullConstantExpression()); |
| 716 break; |
| 674 case Feature.STRING_INTERPOLATION: | 717 case Feature.STRING_INTERPOLATION: |
| 675 case Feature.STRING_JUXTAPOSITION: | 718 case Feature.STRING_JUXTAPOSITION: |
| 676 // These are both converted into a string concatenation in kernel so | 719 // These are both converted into a string concatenation in kernel so |
| 677 // we cannot tell the difference. | 720 // we cannot tell the difference. |
| 678 builder.registerFeature(Feature.STRING_INTERPOLATION); | 721 builder.registerFeature(Feature.STRING_INTERPOLATION); |
| 679 builder.registerFeature(Feature.STRING_JUXTAPOSITION); | 722 builder.registerFeature(Feature.STRING_JUXTAPOSITION); |
| 680 break; | 723 break; |
| 681 case Feature.FALL_THROUGH_ERROR: | 724 case Feature.FALL_THROUGH_ERROR: |
| 682 LibraryElement library = | 725 LibraryElement library = |
| 683 compiler.libraryLoader.lookupLibrary(Uris.dart_core); | 726 compiler.libraryLoader.lookupLibrary(Uris.dart_core); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 723 @override | 766 @override |
| 724 DartType visitFunctionType(FunctionType type, _) { | 767 DartType visitFunctionType(FunctionType type, _) { |
| 725 return new FunctionType.synthesized( | 768 return new FunctionType.synthesized( |
| 726 visit(type.returnType), | 769 visit(type.returnType), |
| 727 visitList(type.parameterTypes), | 770 visitList(type.parameterTypes), |
| 728 visitList(type.optionalParameterTypes), | 771 visitList(type.optionalParameterTypes), |
| 729 type.namedParameters, | 772 type.namedParameters, |
| 730 visitList(type.namedParameterTypes)); | 773 visitList(type.namedParameterTypes)); |
| 731 } | 774 } |
| 732 } | 775 } |
| OLD | NEW |