| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 dart2js.js.enqueue; | 5 library dart2js.js.enqueue; |
| 6 | 6 |
| 7 import 'dart:collection' show Queue; | 7 import 'dart:collection' show Queue; |
| 8 | 8 |
| 9 import '../cache_strategy.dart' show CacheStrategy; | 9 import '../cache_strategy.dart' show CacheStrategy; |
| 10 import '../common/backend_api.dart' show Backend; | 10 import '../common/backend_api.dart' show Backend; |
| 11 import '../common/codegen.dart' show CodegenWorkItem; | 11 import '../common/codegen.dart' show CodegenWorkItem; |
| 12 import '../common/tasks.dart' show CompilerTask; | 12 import '../common/tasks.dart' show CompilerTask; |
| 13 import '../common/work.dart' show WorkItem; | 13 import '../common/work.dart' show WorkItem; |
| 14 import '../common.dart'; | 14 import '../common.dart'; |
| 15 import '../compiler.dart' show Compiler; | 15 import '../compiler.dart' show Compiler; |
| 16 import '../elements/resolution_types.dart' show DartType, InterfaceType; | 16 import '../elements/resolution_types.dart' |
| 17 show ResolutionDartType, ResolutionInterfaceType; |
| 17 import '../elements/elements.dart' show Entity, MemberElement, TypedElement; | 18 import '../elements/elements.dart' show Entity, MemberElement, TypedElement; |
| 18 import '../elements/entities.dart'; | 19 import '../elements/entities.dart'; |
| 19 import '../enqueue.dart'; | 20 import '../enqueue.dart'; |
| 20 import '../native/native.dart' as native; | 21 import '../native/native.dart' as native; |
| 21 import '../options.dart'; | 22 import '../options.dart'; |
| 22 import '../types/types.dart' show TypeMaskStrategy; | 23 import '../types/types.dart' show TypeMaskStrategy; |
| 23 import '../universe/world_builder.dart'; | 24 import '../universe/world_builder.dart'; |
| 24 import '../universe/use.dart' | 25 import '../universe/use.dart' |
| 25 show DynamicUse, StaticUse, StaticUseKind, TypeUse, TypeUseKind; | 26 show DynamicUse, StaticUse, StaticUseKind, TypeUse, TypeUseKind; |
| 26 import '../universe/world_impact.dart' | 27 import '../universe/world_impact.dart' |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 applyImpact(_backend.registerUsedElement(entity, forResolution: false)); | 99 applyImpact(_backend.registerUsedElement(entity, forResolution: false)); |
| 99 _queue.add(workItem); | 100 _queue.add(workItem); |
| 100 } | 101 } |
| 101 | 102 |
| 102 void applyImpact(WorldImpact worldImpact, {var impactSource}) { | 103 void applyImpact(WorldImpact worldImpact, {var impactSource}) { |
| 103 if (worldImpact.isEmpty) return; | 104 if (worldImpact.isEmpty) return; |
| 104 impactStrategy.visitImpact( | 105 impactStrategy.visitImpact( |
| 105 impactSource, worldImpact, _impactVisitor, impactUse); | 106 impactSource, worldImpact, _impactVisitor, impactUse); |
| 106 } | 107 } |
| 107 | 108 |
| 108 void _registerInstantiatedType(InterfaceType type, | 109 void _registerInstantiatedType(ResolutionInterfaceType type, |
| 109 {bool mirrorUsage: false, bool nativeUsage: false}) { | 110 {bool mirrorUsage: false, bool nativeUsage: false}) { |
| 110 task.measure(() { | 111 task.measure(() { |
| 111 _universe.registerTypeInstantiation(type, _applyClassUse, | 112 _universe.registerTypeInstantiation(type, _applyClassUse, |
| 112 byMirrors: mirrorUsage); | 113 byMirrors: mirrorUsage); |
| 113 if (nativeUsage) { | 114 if (nativeUsage) { |
| 114 nativeEnqueuer.onInstantiatedType(type); | 115 nativeEnqueuer.onInstantiatedType(type); |
| 115 } | 116 } |
| 116 _backend.registerInstantiatedType(type); | 117 _backend.registerInstantiatedType(type); |
| 117 }); | 118 }); |
| 118 } | 119 } |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 case StaticUseKind.CONST_CONSTRUCTOR_INVOKE: | 177 case StaticUseKind.CONST_CONSTRUCTOR_INVOKE: |
| 177 case StaticUseKind.REDIRECTION: | 178 case StaticUseKind.REDIRECTION: |
| 178 processTypeUse(new TypeUse.instantiation(staticUse.type)); | 179 processTypeUse(new TypeUse.instantiation(staticUse.type)); |
| 179 break; | 180 break; |
| 180 default: | 181 default: |
| 181 break; | 182 break; |
| 182 } | 183 } |
| 183 } | 184 } |
| 184 | 185 |
| 185 void processTypeUse(TypeUse typeUse) { | 186 void processTypeUse(TypeUse typeUse) { |
| 186 DartType type = typeUse.type; | 187 ResolutionDartType type = typeUse.type; |
| 187 switch (typeUse.kind) { | 188 switch (typeUse.kind) { |
| 188 case TypeUseKind.INSTANTIATION: | 189 case TypeUseKind.INSTANTIATION: |
| 189 _registerInstantiatedType(type); | 190 _registerInstantiatedType(type); |
| 190 break; | 191 break; |
| 191 case TypeUseKind.MIRROR_INSTANTIATION: | 192 case TypeUseKind.MIRROR_INSTANTIATION: |
| 192 _registerInstantiatedType(type, mirrorUsage: true); | 193 _registerInstantiatedType(type, mirrorUsage: true); |
| 193 break; | 194 break; |
| 194 case TypeUseKind.NATIVE_INSTANTIATION: | 195 case TypeUseKind.NATIVE_INSTANTIATION: |
| 195 _registerInstantiatedType(type, nativeUsage: true); | 196 _registerInstantiatedType(type, nativeUsage: true); |
| 196 break; | 197 break; |
| 197 case TypeUseKind.IS_CHECK: | 198 case TypeUseKind.IS_CHECK: |
| 198 case TypeUseKind.AS_CAST: | 199 case TypeUseKind.AS_CAST: |
| 199 case TypeUseKind.CATCH_TYPE: | 200 case TypeUseKind.CATCH_TYPE: |
| 200 _registerIsCheck(type); | 201 _registerIsCheck(type); |
| 201 break; | 202 break; |
| 202 case TypeUseKind.CHECKED_MODE_CHECK: | 203 case TypeUseKind.CHECKED_MODE_CHECK: |
| 203 if (_options.enableTypeAssertions) { | 204 if (_options.enableTypeAssertions) { |
| 204 _registerIsCheck(type); | 205 _registerIsCheck(type); |
| 205 } | 206 } |
| 206 break; | 207 break; |
| 207 case TypeUseKind.TYPE_LITERAL: | 208 case TypeUseKind.TYPE_LITERAL: |
| 208 break; | 209 break; |
| 209 } | 210 } |
| 210 } | 211 } |
| 211 | 212 |
| 212 void _registerIsCheck(DartType type) { | 213 void _registerIsCheck(ResolutionDartType type) { |
| 213 type = _universe.registerIsCheck(type); | 214 type = _universe.registerIsCheck(type); |
| 214 // Even in checked mode, type annotations for return type and argument | 215 // Even in checked mode, type annotations for return type and argument |
| 215 // types do not imply type checks, so there should never be a check | 216 // types do not imply type checks, so there should never be a check |
| 216 // against the type variable of a typedef. | 217 // against the type variable of a typedef. |
| 217 assert(!type.isTypeVariable || !type.element.enclosingElement.isTypedef); | 218 assert(!type.isTypeVariable || !type.element.enclosingElement.isTypedef); |
| 218 } | 219 } |
| 219 | 220 |
| 220 void _registerClosurizedMember(TypedElement element) { | 221 void _registerClosurizedMember(TypedElement element) { |
| 221 assert(element.isInstanceMember); | 222 assert(element.isInstanceMember); |
| 222 if (element.type.containsTypeVariables) { | 223 if (element.type.containsTypeVariables) { |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 // code for checked setters. | 295 // code for checked setters. |
| 295 if (element.isField && element.isInstanceMember) { | 296 if (element.isField && element.isInstanceMember) { |
| 296 if (!_options.enableTypeAssertions || | 297 if (!_options.enableTypeAssertions || |
| 297 element.enclosingElement.isClosure) { | 298 element.enclosingElement.isClosure) { |
| 298 return null; | 299 return null; |
| 299 } | 300 } |
| 300 } | 301 } |
| 301 return new CodegenWorkItem(_backend, element); | 302 return new CodegenWorkItem(_backend, element); |
| 302 } | 303 } |
| 303 } | 304 } |
| OLD | NEW |