| 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 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 } | 439 } |
| 440 visitList(classNode.annotations, _visitor); | 440 visitList(classNode.annotations, _visitor); |
| 441 } | 441 } |
| 442 | 442 |
| 443 /// Registers the given root as being used. | 443 /// Registers the given root as being used. |
| 444 void _addUsedRoot(ProgramRoot root, LibraryIndex table) { | 444 void _addUsedRoot(ProgramRoot root, LibraryIndex table) { |
| 445 if (root.kind == ProgramRootKind.ExternallyInstantiatedClass) { | 445 if (root.kind == ProgramRootKind.ExternallyInstantiatedClass) { |
| 446 Class class_ = root.getClass(table); | 446 Class class_ = root.getClass(table); |
| 447 | 447 |
| 448 // This is a class which will be instantiated by non-Dart code (whether it | 448 // This is a class which will be instantiated by non-Dart code (whether it |
| 449 // has a valid generative construtor or not). | 449 // has a valid generative constructor or not). |
| 450 _addInstantiatedClass(class_); | 450 _addInstantiatedClass(class_); |
| 451 | 451 |
| 452 // We keep all the constructors of externally instantiated classes. | 452 // We keep all the constructors of externally instantiated classes. |
| 453 // Sometimes the runtime might do a constructor call and sometimes it | 453 // Sometimes the runtime might do a constructor call and sometimes it |
| 454 // might just allocate the class without invoking the constructor. | 454 // might just allocate the class without invoking the constructor. |
| 455 // So we try to be on the safe side here! | 455 // So we try to be on the safe side here! |
| 456 for (var constructor in class_.constructors) { | 456 for (var constructor in class_.constructors) { |
| 457 _addUsedMember(class_, constructor); | 457 _addUsedMember(class_, constructor); |
| 458 } | 458 } |
| 459 | 459 |
| (...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1078 classNode == coreTypes.futureClass || | 1078 classNode == coreTypes.futureClass || |
| 1079 classNode == coreTypes.streamClass || | 1079 classNode == coreTypes.streamClass || |
| 1080 classNode == coreTypes.listClass || | 1080 classNode == coreTypes.listClass || |
| 1081 classNode == coreTypes.mapClass; | 1081 classNode == coreTypes.mapClass; |
| 1082 } | 1082 } |
| 1083 } | 1083 } |
| 1084 | 1084 |
| 1085 /// Exception that is thrown to stop the tree shaking analysis when a use | 1085 /// Exception that is thrown to stop the tree shaking analysis when a use |
| 1086 /// of `dart:mirrors` is found. | 1086 /// of `dart:mirrors` is found. |
| 1087 class _UsingMirrorsException {} | 1087 class _UsingMirrorsException {} |
| OLD | NEW |