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 kernel.tree_shaker; | 5 library kernel.tree_shaker; |
6 | 6 |
7 import '../ast.dart'; | 7 import '../ast.dart'; |
8 import '../class_hierarchy.dart'; | 8 import '../class_hierarchy.dart'; |
9 import '../core_types.dart'; | 9 import '../core_types.dart'; |
10 import '../type_environment.dart'; | 10 import '../type_environment.dart'; |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 this._usedMembersWithHost = | 215 this._usedMembersWithHost = |
216 new List<Set<Member>>(hierarchy.classes.length), | 216 new List<Set<Member>>(hierarchy.classes.length), |
217 this._classRetention = new List<ClassRetention>.filled( | 217 this._classRetention = new List<ClassRetention>.filled( |
218 hierarchy.classes.length, ClassRetention.None) { | 218 hierarchy.classes.length, ClassRetention.None) { |
219 _visitor = new _TreeShakerVisitor(this); | 219 _visitor = new _TreeShakerVisitor(this); |
220 _covariantVisitor = new _ExternalTypeVisitor(this, isCovariant: true); | 220 _covariantVisitor = new _ExternalTypeVisitor(this, isCovariant: true); |
221 _contravariantVisitor = | 221 _contravariantVisitor = |
222 new _ExternalTypeVisitor(this, isContravariant: true); | 222 new _ExternalTypeVisitor(this, isContravariant: true); |
223 _invariantVisitor = new _ExternalTypeVisitor(this, | 223 _invariantVisitor = new _ExternalTypeVisitor(this, |
224 isCovariant: true, isContravariant: true); | 224 isCovariant: true, isContravariant: true); |
225 _mirrorsLibrary = coreTypes.tryGetLibrary('dart:mirrors'); | 225 _mirrorsLibrary = coreTypes.mirrorsLibrary; |
226 try { | 226 try { |
227 _build(); | 227 _build(); |
228 } on _UsingMirrorsException { | 228 } on _UsingMirrorsException { |
229 isUsingMirrors = true; | 229 isUsingMirrors = true; |
230 } | 230 } |
231 } | 231 } |
232 | 232 |
233 void _build() { | 233 void _build() { |
234 if (program.mainMethod == null) { | 234 if (program.mainMethod == null) { |
235 throw 'Cannot perform tree shaking on a program without a main method'; | 235 throw 'Cannot perform tree shaking on a program without a main method'; |
(...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1082 classNode == coreTypes.futureClass || | 1082 classNode == coreTypes.futureClass || |
1083 classNode == coreTypes.streamClass || | 1083 classNode == coreTypes.streamClass || |
1084 classNode == coreTypes.listClass || | 1084 classNode == coreTypes.listClass || |
1085 classNode == coreTypes.mapClass; | 1085 classNode == coreTypes.mapClass; |
1086 } | 1086 } |
1087 } | 1087 } |
1088 | 1088 |
1089 /// Exception that is thrown to stop the tree shaking analysis when a use | 1089 /// Exception that is thrown to stop the tree shaking analysis when a use |
1090 /// of `dart:mirrors` is found. | 1090 /// of `dart:mirrors` is found. |
1091 class _UsingMirrorsException {} | 1091 class _UsingMirrorsException {} |
OLD | NEW |