| 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 fasta.kernel_target; | 5 library fasta.kernel_target; |
| 6 | 6 |
| 7 import 'dart:async' show Future; | 7 import 'dart:async' show Future; |
| 8 | 8 |
| 9 import 'dart:io' show File; | 9 import 'dart:io' show File; |
| 10 | 10 |
| (...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 688 var toShake = | 688 var toShake = |
| 689 dillTarget.loader.libraries.map((lib) => lib.importUri).toSet(); | 689 dillTarget.loader.libraries.map((lib) => lib.importUri).toSet(); |
| 690 var isIncluded = (Uri uri) => !toShake.contains(uri); | 690 var isIncluded = (Uri uri) => !toShake.contains(uri); |
| 691 var data = new RetainedDataBuilder(); | 691 var data = new RetainedDataBuilder(); |
| 692 // TODO(sigmund): replace this step with data that is directly computed from | 692 // TODO(sigmund): replace this step with data that is directly computed from |
| 693 // the builders: we should know the tree-shaking roots without having to do | 693 // the builders: we should know the tree-shaking roots without having to do |
| 694 // a second visit over the tree. | 694 // a second visit over the tree. |
| 695 new RootsMarker(data).run(_program, isIncluded); | 695 new RootsMarker(data).run(_program, isIncluded); |
| 696 trimProgram(_program, data, isIncluded); | 696 trimProgram(_program, data, isIncluded); |
| 697 } | 697 } |
| 698 |
| 699 /// Return `true` if the given [library] was built by this [KernelTarget] |
| 700 /// from sources, and not loaded from a [DillTarget]. |
| 701 bool isSourceLibrary(Library library) { |
| 702 return loader.libraries.contains(library); |
| 703 } |
| 698 } | 704 } |
| 699 | 705 |
| 700 /// Looks for a constructor call that matches `super()` from a constructor in | 706 /// Looks for a constructor call that matches `super()` from a constructor in |
| 701 /// [cls]. Such a constructor may have optional arguments, but no required | 707 /// [cls]. Such a constructor may have optional arguments, but no required |
| 702 /// arguments. | 708 /// arguments. |
| 703 Constructor defaultSuperConstructor(Class cls) { | 709 Constructor defaultSuperConstructor(Class cls) { |
| 704 Class superclass = cls.superclass; | 710 Class superclass = cls.superclass; |
| 705 while (superclass != null && superclass.isMixinApplication) { | 711 while (superclass != null && superclass.isMixinApplication) { |
| 706 superclass = superclass.superclass; | 712 superclass = superclass.superclass; |
| 707 } | 713 } |
| 708 for (Constructor constructor in superclass.constructors) { | 714 for (Constructor constructor in superclass.constructors) { |
| 709 if (constructor.name.name.isEmpty) { | 715 if (constructor.name.name.isEmpty) { |
| 710 return constructor.function.requiredParameterCount == 0 | 716 return constructor.function.requiredParameterCount == 0 |
| 711 ? constructor | 717 ? constructor |
| 712 : null; | 718 : null; |
| 713 } | 719 } |
| 714 } | 720 } |
| 715 return null; | 721 return null; |
| 716 } | 722 } |
| OLD | NEW |