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 library kernel.target.vm; | 4 library kernel.target.vm; |
5 | 5 |
6 import '../ast.dart'; | 6 import '../ast.dart'; |
7 import '../class_hierarchy.dart'; | 7 import '../class_hierarchy.dart'; |
8 import '../core_types.dart'; | 8 import '../core_types.dart'; |
9 import '../transformations/continuation.dart' as cont; | 9 import '../transformations/continuation.dart' as cont; |
10 import '../transformations/erasure.dart'; | 10 import '../transformations/erasure.dart'; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 var coreTypes = new CoreTypes(program); | 67 var coreTypes = new CoreTypes(program); |
68 | 68 |
69 if (strongMode) { | 69 if (strongMode) { |
70 new InsertTypeChecks(hierarchy: _hierarchy, coreTypes: coreTypes) | 70 new InsertTypeChecks(hierarchy: _hierarchy, coreTypes: coreTypes) |
71 .transformProgram(program); | 71 .transformProgram(program); |
72 new InsertCovarianceChecks(hierarchy: _hierarchy, coreTypes: coreTypes) | 72 new InsertCovarianceChecks(hierarchy: _hierarchy, coreTypes: coreTypes) |
73 .transformProgram(program); | 73 .transformProgram(program); |
74 } | 74 } |
75 | 75 |
76 if (flags.treeShake) { | 76 if (flags.treeShake) { |
77 new TreeShaker(program, | 77 performTreeShaking(program); |
78 hierarchy: _hierarchy, | |
79 coreTypes: coreTypes, | |
80 strongMode: strongMode, | |
81 programRoots: flags.programRoots) | |
82 .transform(program); | |
83 _hierarchy = null; // Hierarchy must be recomputed. | |
84 } | 78 } |
85 | 79 |
86 cont.transformProgram(program); | 80 cont.transformProgram(program); |
87 | 81 |
88 // Repair `_getMainClosure()` function in dart:_builtin. | 82 // Repair `_getMainClosure()` function in dart:_builtin. |
89 setup_builtin_library.transformProgram(program); | 83 setup_builtin_library.transformProgram(program); |
90 | 84 |
91 if (strongMode) { | 85 if (strongMode) { |
92 new Erasure().transform(program); | 86 new Erasure().transform(program); |
93 } | 87 } |
94 | 88 |
95 new SanitizeForVM().transform(program); | 89 new SanitizeForVM().transform(program); |
96 } | 90 } |
| 91 |
| 92 void performTreeShaking(Program program) { |
| 93 var coreTypes = new CoreTypes(program); |
| 94 new TreeShaker(program, |
| 95 hierarchy: _hierarchy, |
| 96 coreTypes: coreTypes, |
| 97 strongMode: strongMode, |
| 98 programRoots: flags.programRoots) |
| 99 .transform(program); |
| 100 _hierarchy = null; // Hierarchy must be recomputed. |
| 101 } |
97 } | 102 } |
OLD | NEW |