| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 deferred_load; | 5 library deferred_load; |
| 6 | 6 |
| 7 import 'common/tasks.dart' show CompilerTask; | 7 import 'common/tasks.dart' show CompilerTask; |
| 8 import 'common.dart'; | 8 import 'common.dart'; |
| 9 import 'compiler.dart' show Compiler; | 9 import 'compiler.dart' show Compiler; |
| 10 import 'constants/expressions.dart' show ConstantExpression; | 10 import 'constants/expressions.dart' show ConstantExpression; |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 collectTypeDependencies(argumentType); | 312 collectTypeDependencies(argumentType); |
| 313 } | 313 } |
| 314 for (ResolutionDartType argumentType in type.namedParameterTypes) { | 314 for (ResolutionDartType argumentType in type.namedParameterTypes) { |
| 315 collectTypeDependencies(argumentType); | 315 collectTypeDependencies(argumentType); |
| 316 } | 316 } |
| 317 collectTypeDependencies(type.returnType); | 317 collectTypeDependencies(type.returnType); |
| 318 } else if (type is ResolutionTypedefType) { | 318 } else if (type is ResolutionTypedefType) { |
| 319 elements.add(type.element); | 319 elements.add(type.element); |
| 320 collectTypeDependencies(type.unaliased); | 320 collectTypeDependencies(type.unaliased); |
| 321 } else if (type is ResolutionInterfaceType) { | 321 } else if (type is ResolutionInterfaceType) { |
| 322 if (elements.add(type.element)) { | 322 elements.add(type.element); |
| 323 collectTypeDependencies(type.element.supertype); | |
| 324 } | |
| 325 } | 323 } |
| 326 } | 324 } |
| 327 | 325 |
| 328 /// Collects all direct dependencies of [element]. | 326 /// Collects all direct dependencies of [element]. |
| 329 /// | 327 /// |
| 330 /// The collected dependent elements and constants are are added to | 328 /// The collected dependent elements and constants are are added to |
| 331 /// [elements] and [constants] respectively. | 329 /// [elements] and [constants] respectively. |
| 332 void collectDependencies(Element element) { | 330 void collectDependencies(Element element) { |
| 333 // TODO(johnniwinther): Remove this when [AbstractFieldElement] has been | 331 // TODO(johnniwinther): Remove this when [AbstractFieldElement] has been |
| 334 // removed. | 332 // removed. |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 MemberElement element = _element; | 449 MemberElement element = _element; |
| 452 if (!compiler.resolutionWorldBuilder.isMemberUsed(element)) return; | 450 if (!compiler.resolutionWorldBuilder.isMemberUsed(element)) return; |
| 453 if (!isMirrorUsage && !element.isInstanceMember) return; | 451 if (!isMirrorUsage && !element.isInstanceMember) return; |
| 454 elements.add(element); | 452 elements.add(element); |
| 455 collectDependencies(element); | 453 collectDependencies(element); |
| 456 } | 454 } |
| 457 | 455 |
| 458 ClassElement cls = element.declaration; | 456 ClassElement cls = element.declaration; |
| 459 cls.implementation.forEachMember(addLiveInstanceMember); | 457 cls.implementation.forEachMember(addLiveInstanceMember); |
| 460 for (ResolutionInterfaceType type in cls.implementation.allSupertypes) { | 458 for (ResolutionInterfaceType type in cls.implementation.allSupertypes) { |
| 461 elements.add(type.element.implementation); | 459 collectTypeDependencies(type); |
| 462 } | 460 } |
| 463 elements.add(cls.implementation); | 461 elements.add(cls.implementation); |
| 464 } else if (Elements.isStaticOrTopLevel(element) || element.isConstructor) { | 462 } else if (Elements.isStaticOrTopLevel(element) || element.isConstructor) { |
| 465 elements.add(element); | 463 elements.add(element); |
| 466 collectDependencies(element); | 464 collectDependencies(element); |
| 467 } | 465 } |
| 468 if (element.isGenerativeConstructor) { | 466 if (element.isGenerativeConstructor) { |
| 469 // When instantiating a class, we record a reference to the | 467 // When instantiating a class, we record a reference to the |
| 470 // constructor, not the class itself. We must add all the | 468 // constructor, not the class itself. We must add all the |
| 471 // instance members of the constructor's class. | 469 // instance members of the constructor's class. |
| (...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1124 | 1122 |
| 1125 bool operator ==(other) { | 1123 bool operator ==(other) { |
| 1126 if (other is! _DeclaredDeferredImport) return false; | 1124 if (other is! _DeclaredDeferredImport) return false; |
| 1127 return declaration == other.declaration; | 1125 return declaration == other.declaration; |
| 1128 } | 1126 } |
| 1129 | 1127 |
| 1130 int get hashCode => declaration.hashCode * 17; | 1128 int get hashCode => declaration.hashCode * 17; |
| 1131 | 1129 |
| 1132 String toString() => '$declaration'; | 1130 String toString() => '$declaration'; |
| 1133 } | 1131 } |
| OLD | NEW |