| 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 dart2js.js_emitter.type_test_registry; | 5 library dart2js.js_emitter.type_test_registry; |
| 6 | 6 |
| 7 import '../common.dart'; | 7 import '../common.dart'; |
| 8 import '../common_elements.dart'; | 8 import '../common_elements.dart'; |
| 9 import '../elements/elements.dart' show MethodElement; | |
| 10 import '../elements/entities.dart'; | 9 import '../elements/entities.dart'; |
| 11 import '../elements/types.dart' show DartType; | |
| 12 import '../elements/types.dart'; | 10 import '../elements/types.dart'; |
| 13 import '../js_backend/runtime_types.dart' | 11 import '../js_backend/runtime_types.dart' |
| 14 show | 12 show |
| 15 RuntimeTypesChecks, | 13 RuntimeTypesChecks, |
| 16 RuntimeTypesChecksBuilder, | 14 RuntimeTypesChecksBuilder, |
| 17 RuntimeTypesSubstitutions, | 15 RuntimeTypesSubstitutions, |
| 18 TypeChecks; | 16 TypeChecks; |
| 19 import '../js_backend/mirrors_data.dart'; | 17 import '../js_backend/mirrors_data.dart'; |
| 20 import '../universe/world_builder.dart'; | 18 import '../universe/world_builder.dart'; |
| 21 import '../world.dart' show ClosedWorld; | 19 import '../world.dart' show ClosedWorld; |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 bool canBeReified(MemberEntity element) { | 159 bool canBeReified(MemberEntity element) { |
| 162 return (canTearOff(element) || | 160 return (canTearOff(element) || |
| 163 mirrorsData.isMemberAccessibleByReflection(element)); | 161 mirrorsData.isMemberAccessibleByReflection(element)); |
| 164 } | 162 } |
| 165 | 163 |
| 166 // Find all types referenced from the types of elements that can be | 164 // Find all types referenced from the types of elements that can be |
| 167 // reflected on 'as functions'. | 165 // reflected on 'as functions'. |
| 168 liveMembers.where((MemberEntity element) { | 166 liveMembers.where((MemberEntity element) { |
| 169 return canBeReflectedAsFunction(element) && canBeReified(element); | 167 return canBeReflectedAsFunction(element) && canBeReified(element); |
| 170 }).forEach((_function) { | 168 }).forEach((_function) { |
| 171 // TODO(redemption): Support entities. | 169 FunctionEntity function = _function; |
| 172 MethodElement function = _function; | 170 FunctionType type = _elementEnvironment.getFunctionType(function); |
| 173 FunctionType type = function.type; | |
| 174 for (ClassEntity cls in _rtiChecks.getReferencedClasses(type)) { | 171 for (ClassEntity cls in _rtiChecks.getReferencedClasses(type)) { |
| 175 while (cls != null) { | 172 while (cls != null) { |
| 176 _rtiNeededClasses.add(cls); | 173 _rtiNeededClasses.add(cls); |
| 177 cls = _elementEnvironment.getSuperClass(cls); | 174 cls = _elementEnvironment.getSuperClass(cls); |
| 178 } | 175 } |
| 179 } | 176 } |
| 180 }); | 177 }); |
| 181 } | 178 } |
| 182 | 179 |
| 183 void computeRequiredTypeChecks(RuntimeTypesChecksBuilder rtiChecksBuilder) { | 180 void computeRequiredTypeChecks(RuntimeTypesChecksBuilder rtiChecksBuilder) { |
| 184 assert(checkedClasses == null && checkedFunctionTypes == null); | 181 assert(checkedClasses == null && checkedFunctionTypes == null); |
| 185 | 182 |
| 186 rtiChecksBuilder.registerImplicitChecks( | 183 rtiChecksBuilder.registerImplicitChecks( |
| 187 _codegenWorldBuilder, classesUsingTypeVariableTests); | 184 _codegenWorldBuilder, classesUsingTypeVariableTests); |
| 188 _rtiChecks = rtiChecksBuilder.computeRequiredChecks(_codegenWorldBuilder); | 185 _rtiChecks = rtiChecksBuilder.computeRequiredChecks(_codegenWorldBuilder); |
| 189 | 186 |
| 190 checkedClasses = new Set<ClassEntity>(); | 187 checkedClasses = new Set<ClassEntity>(); |
| 191 checkedFunctionTypes = new Set<FunctionType>(); | 188 checkedFunctionTypes = new Set<FunctionType>(); |
| 192 _codegenWorldBuilder.isChecks.forEach((DartType t) { | 189 _codegenWorldBuilder.isChecks.forEach((DartType t) { |
| 193 if (t is InterfaceType) { | 190 if (t is InterfaceType) { |
| 194 checkedClasses.add(t.element); | 191 checkedClasses.add(t.element); |
| 195 } else if (t is FunctionType) { | 192 } else if (t is FunctionType) { |
| 196 checkedFunctionTypes.add(t); | 193 checkedFunctionTypes.add(t); |
| 197 } | 194 } |
| 198 }); | 195 }); |
| 199 } | 196 } |
| 200 } | 197 } |
| OLD | NEW |