| 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'; | 7 import 'dart:async'; |
| 8 import 'package:async_helper/async_helper.dart'; | 8 import 'package:async_helper/async_helper.dart'; |
| 9 import 'package:compiler/src/commandline_options.dart'; | 9 import 'package:compiler/src/commandline_options.dart'; |
| 10 import 'package:compiler/src/common.dart'; | 10 import 'package:compiler/src/common.dart'; |
| (...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 Compiler compiler = compilerFor( | 595 Compiler compiler = compilerFor( |
| 596 entryPoint: entryPoint, | 596 entryPoint: entryPoint, |
| 597 memorySourceFiles: SOURCE, | 597 memorySourceFiles: SOURCE, |
| 598 options: [ | 598 options: [ |
| 599 Flags.analyzeAll, | 599 Flags.analyzeAll, |
| 600 Flags.useKernel, | 600 Flags.useKernel, |
| 601 Flags.enableAssertMessage | 601 Flags.enableAssertMessage |
| 602 ]); | 602 ]); |
| 603 compiler.resolution.retainCachesForTesting = true; | 603 compiler.resolution.retainCachesForTesting = true; |
| 604 await compiler.run(entryPoint); | 604 await compiler.run(entryPoint); |
| 605 checkLibrary(compiler, compiler.mainApp); | 605 compiler.libraryLoader.libraries.forEach((LibraryElement library) { |
| 606 checkLibrary(compiler, library); |
| 607 }); |
| 606 }); | 608 }); |
| 607 } | 609 } |
| 608 | 610 |
| 609 void checkLibrary(Compiler compiler, LibraryElement library) { | 611 void checkLibrary(Compiler compiler, LibraryElement library) { |
| 610 library.forEachLocalMember((AstElement element) { | 612 library.forEachLocalMember((AstElement element) { |
| 611 if (element.isClass) { | 613 if (element.isClass) { |
| 612 ClassElement cls = element; | 614 ClassElement cls = element; |
| 613 cls.forEachLocalMember((AstElement member) { | 615 cls.forEachLocalMember((AstElement member) { |
| 614 checkElement(compiler, member); | 616 checkElement(compiler, member); |
| 615 }); | 617 }); |
| 616 } else if (element.isTypedef) { | 618 } else if (element.isTypedef) { |
| 617 // Skip typedefs. | 619 // Skip typedefs. |
| 618 } else { | 620 } else { |
| 619 checkElement(compiler, element); | 621 checkElement(compiler, element); |
| 620 } | 622 } |
| 621 }); | 623 }); |
| 622 } | 624 } |
| 623 | 625 |
| 624 void checkElement(Compiler compiler, AstElement element) { | 626 void checkElement(Compiler compiler, AstElement element) { |
| 627 if (compiler.backend.isNative(element)) { |
| 628 // Skip native functions for now; kernel does not provide their |
| 629 // signature which we need to derive their native behavior. |
| 630 return; |
| 631 } |
| 632 if (element.isConstructor) { |
| 633 ConstructorElement constructor = element; |
| 634 if (constructor.isRedirectingFactory) { |
| 635 // Skip redirecting constructors for now; they might not be supported. |
| 636 return; |
| 637 } |
| 638 } |
| 625 ResolutionImpact astImpact = compiler.resolution.getResolutionImpact(element); | 639 ResolutionImpact astImpact = compiler.resolution.getResolutionImpact(element); |
| 626 astImpact = laxImpact(compiler, element, astImpact); | 640 astImpact = laxImpact(compiler, element, astImpact); |
| 627 ResolutionImpact kernelImpact = build(compiler, element.resolvedAst); | 641 ResolutionImpact kernelImpact = build(compiler, element.resolvedAst); |
| 628 Expect.isNotNull(kernelImpact, 'No impact computed for $element'); | 642 Expect.isNotNull(kernelImpact, 'No impact computed for $element'); |
| 629 testResolutionImpactEquivalence( | 643 testResolutionImpactEquivalence( |
| 630 astImpact, kernelImpact, const CheckStrategy()); | 644 astImpact, kernelImpact, const CheckStrategy()); |
| 631 } | 645 } |
| 632 | 646 |
| 633 /// Lax the precision of [impact] to meet expectancy of the corresponding impact | 647 /// Lax the precision of [impact] to meet expectancy of the corresponding impact |
| 634 /// generated from kernel. | 648 /// generated from kernel. |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 714 @override | 728 @override |
| 715 DartType visitFunctionType(FunctionType type, _) { | 729 DartType visitFunctionType(FunctionType type, _) { |
| 716 return new FunctionType.synthesized( | 730 return new FunctionType.synthesized( |
| 717 visit(type.returnType), | 731 visit(type.returnType), |
| 718 visitList(type.parameterTypes), | 732 visitList(type.parameterTypes), |
| 719 visitList(type.optionalParameterTypes), | 733 visitList(type.optionalParameterTypes), |
| 720 type.namedParameters, | 734 type.namedParameters, |
| 721 visitList(type.namedParameterTypes)); | 735 visitList(type.namedParameterTypes)); |
| 722 } | 736 } |
| 723 } | 737 } |
| OLD | NEW |