| 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/backend_api.dart' show Backend; | 7 import 'common/backend_api.dart' show Backend; |
| 8 import 'common/tasks.dart' show CompilerTask; | 8 import 'common/tasks.dart' show CompilerTask; |
| 9 import 'common.dart'; | 9 import 'common.dart'; |
| 10 import 'compiler.dart' show Compiler; | 10 import 'compiler.dart' show Compiler; |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 /// | 271 /// |
| 272 /// Adds the results to [elements] and [constants]. | 272 /// Adds the results to [elements] and [constants]. |
| 273 void _collectAllElementsAndConstantsResolvedFrom(Element element, | 273 void _collectAllElementsAndConstantsResolvedFrom(Element element, |
| 274 Set<Element> elements, Set<ConstantValue> constants, isMirrorUsage) { | 274 Set<Element> elements, Set<ConstantValue> constants, isMirrorUsage) { |
| 275 if (element.isMalformed) { | 275 if (element.isMalformed) { |
| 276 // Malformed elements are ignored. | 276 // Malformed elements are ignored. |
| 277 return; | 277 return; |
| 278 } | 278 } |
| 279 | 279 |
| 280 /// Recursively collects all the dependencies of [type]. | 280 /// Recursively collects all the dependencies of [type]. |
| 281 void collectTypeDependencies(DartType type) { | 281 void collectTypeDependencies(ResolutionDartType type) { |
| 282 // TODO(het): we would like to separate out types that are only needed for | 282 // TODO(het): we would like to separate out types that are only needed for |
| 283 // rti from types that are needed for their members. | 283 // rti from types that are needed for their members. |
| 284 if (type is GenericType) { | 284 if (type is GenericType) { |
| 285 type.typeArguments.forEach(collectTypeDependencies); | 285 type.typeArguments.forEach(collectTypeDependencies); |
| 286 } | 286 } |
| 287 if (type is FunctionType) { | 287 if (type is ResolutionFunctionType) { |
| 288 for (DartType argumentType in type.parameterTypes) { | 288 for (ResolutionDartType argumentType in type.parameterTypes) { |
| 289 collectTypeDependencies(argumentType); | 289 collectTypeDependencies(argumentType); |
| 290 } | 290 } |
| 291 for (DartType argumentType in type.optionalParameterTypes) { | 291 for (ResolutionDartType argumentType in type.optionalParameterTypes) { |
| 292 collectTypeDependencies(argumentType); | 292 collectTypeDependencies(argumentType); |
| 293 } | 293 } |
| 294 for (DartType argumentType in type.namedParameterTypes) { | 294 for (ResolutionDartType argumentType in type.namedParameterTypes) { |
| 295 collectTypeDependencies(argumentType); | 295 collectTypeDependencies(argumentType); |
| 296 } | 296 } |
| 297 collectTypeDependencies(type.returnType); | 297 collectTypeDependencies(type.returnType); |
| 298 } else if (type is TypedefType) { | 298 } else if (type is ResolutionTypedefType) { |
| 299 elements.add(type.element); | 299 elements.add(type.element); |
| 300 collectTypeDependencies(type.unaliased); | 300 collectTypeDependencies(type.unaliased); |
| 301 } else if (type is InterfaceType) { | 301 } else if (type is ResolutionInterfaceType) { |
| 302 elements.add(type.element); | 302 elements.add(type.element); |
| 303 } | 303 } |
| 304 } | 304 } |
| 305 | 305 |
| 306 /// Collects all direct dependencies of [element]. | 306 /// Collects all direct dependencies of [element]. |
| 307 /// | 307 /// |
| 308 /// The collected dependent elements and constants are are added to | 308 /// The collected dependent elements and constants are are added to |
| 309 /// [elements] and [constants] respectively. | 309 /// [elements] and [constants] respectively. |
| 310 void collectDependencies(Element element) { | 310 void collectDependencies(Element element) { |
| 311 // TODO(johnniwinther): Remove this when [AbstractFieldElement] has been | 311 // TODO(johnniwinther): Remove this when [AbstractFieldElement] has been |
| (...skipping 19 matching lines...) Expand all Loading... |
| 331 new WorldImpactVisitorImpl(visitStaticUse: (StaticUse staticUse) { | 331 new WorldImpactVisitorImpl(visitStaticUse: (StaticUse staticUse) { |
| 332 elements.add(staticUse.element); | 332 elements.add(staticUse.element); |
| 333 switch (staticUse.kind) { | 333 switch (staticUse.kind) { |
| 334 case StaticUseKind.CONSTRUCTOR_INVOKE: | 334 case StaticUseKind.CONSTRUCTOR_INVOKE: |
| 335 case StaticUseKind.CONST_CONSTRUCTOR_INVOKE: | 335 case StaticUseKind.CONST_CONSTRUCTOR_INVOKE: |
| 336 collectTypeDependencies(staticUse.type); | 336 collectTypeDependencies(staticUse.type); |
| 337 break; | 337 break; |
| 338 default: | 338 default: |
| 339 } | 339 } |
| 340 }, visitTypeUse: (TypeUse typeUse) { | 340 }, visitTypeUse: (TypeUse typeUse) { |
| 341 DartType type = typeUse.type; | 341 ResolutionDartType type = typeUse.type; |
| 342 switch (typeUse.kind) { | 342 switch (typeUse.kind) { |
| 343 case TypeUseKind.TYPE_LITERAL: | 343 case TypeUseKind.TYPE_LITERAL: |
| 344 if (type.isTypedef || type.isInterfaceType) { | 344 if (type.isTypedef || type.isInterfaceType) { |
| 345 elements.add(type.element); | 345 elements.add(type.element); |
| 346 } | 346 } |
| 347 break; | 347 break; |
| 348 case TypeUseKind.INSTANTIATION: | 348 case TypeUseKind.INSTANTIATION: |
| 349 case TypeUseKind.MIRROR_INSTANTIATION: | 349 case TypeUseKind.MIRROR_INSTANTIATION: |
| 350 case TypeUseKind.NATIVE_INSTANTIATION: | 350 case TypeUseKind.NATIVE_INSTANTIATION: |
| 351 case TypeUseKind.IS_CHECK: | 351 case TypeUseKind.IS_CHECK: |
| (...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1049 | 1049 |
| 1050 bool operator ==(other) { | 1050 bool operator ==(other) { |
| 1051 if (other is! _DeclaredDeferredImport) return false; | 1051 if (other is! _DeclaredDeferredImport) return false; |
| 1052 return declaration == other.declaration; | 1052 return declaration == other.declaration; |
| 1053 } | 1053 } |
| 1054 | 1054 |
| 1055 int get hashCode => declaration.hashCode * 17; | 1055 int get hashCode => declaration.hashCode * 17; |
| 1056 | 1056 |
| 1057 String toString() => '$declaration'; | 1057 String toString() => '$declaration'; |
| 1058 } | 1058 } |
| OLD | NEW |