| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 js_backend.interceptor_data; | 5 library js_backend.interceptor_data; |
| 6 | 6 |
| 7 import '../common/names.dart' show Identifiers; | 7 import '../common/names.dart' show Identifiers; |
| 8 import '../common/resolution.dart' show Resolution; | 8 import '../common/resolution.dart' show Resolution; |
| 9 import '../common_elements.dart' show CommonElements; | 9 import '../common_elements.dart' show CommonElements; |
| 10 import '../elements/elements.dart'; | 10 import '../elements/elements.dart'; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 bool mayGenerateInstanceofCheck(DartType type); | 39 bool mayGenerateInstanceofCheck(DartType type); |
| 40 } | 40 } |
| 41 | 41 |
| 42 abstract class InterceptorDataBuilder { | 42 abstract class InterceptorDataBuilder { |
| 43 void addInterceptors(ClassEntity cls); | 43 void addInterceptors(ClassEntity cls); |
| 44 void addInterceptorsForNativeClassMembers(ClassEntity cls); | 44 void addInterceptorsForNativeClassMembers(ClassEntity cls); |
| 45 InterceptorData onResolutionComplete(ClosedWorld closedWorld); | 45 InterceptorData onResolutionComplete(ClosedWorld closedWorld); |
| 46 } | 46 } |
| 47 | 47 |
| 48 class InterceptorDataImpl implements InterceptorData { | 48 class InterceptorDataImpl implements InterceptorData { |
| 49 final NativeData _nativeData; | 49 final NativeClassData _nativeData; |
| 50 final BackendHelpers _helpers; | 50 final BackendHelpers _helpers; |
| 51 final ClosedWorld _closedWorld; | 51 final ClosedWorld _closedWorld; |
| 52 | 52 |
| 53 /// The members of instantiated interceptor classes: maps a member name to the | 53 /// The members of instantiated interceptor classes: maps a member name to the |
| 54 /// list of members that have that name. This map is used by the codegen to | 54 /// list of members that have that name. This map is used by the codegen to |
| 55 /// know whether a send must be intercepted or not. | 55 /// know whether a send must be intercepted or not. |
| 56 final Map<String, Set<Element>> _interceptedElements; | 56 final Map<String, Set<Element>> _interceptedElements; |
| 57 | 57 |
| 58 /// Set of classes whose methods are intercepted. | 58 /// Set of classes whose methods are intercepted. |
| 59 final Set<ClassElement> _interceptedClasses; | 59 final Set<ClassElement> _interceptedClasses; |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 | 207 |
| 208 if (!type.treatAsRaw) return false; | 208 if (!type.treatAsRaw) return false; |
| 209 InterfaceType interfaceType = type; | 209 InterfaceType interfaceType = type; |
| 210 ClassEntity classElement = interfaceType.element; | 210 ClassEntity classElement = interfaceType.element; |
| 211 if (isInterceptedClass(classElement)) return false; | 211 if (isInterceptedClass(classElement)) return false; |
| 212 return _closedWorld.hasOnlySubclasses(classElement); | 212 return _closedWorld.hasOnlySubclasses(classElement); |
| 213 } | 213 } |
| 214 } | 214 } |
| 215 | 215 |
| 216 class InterceptorDataBuilderImpl implements InterceptorDataBuilder { | 216 class InterceptorDataBuilderImpl implements InterceptorDataBuilder { |
| 217 final NativeData _nativeData; | 217 final NativeClassData _nativeData; |
| 218 final BackendHelpers _helpers; | 218 final BackendHelpers _helpers; |
| 219 final CommonElements _commonElements; | 219 final CommonElements _commonElements; |
| 220 final Resolution _resolution; | 220 final Resolution _resolution; |
| 221 | 221 |
| 222 /// The members of instantiated interceptor classes: maps a member name to the | 222 /// The members of instantiated interceptor classes: maps a member name to the |
| 223 /// list of members that have that name. This map is used by the codegen to | 223 /// list of members that have that name. This map is used by the codegen to |
| 224 /// know whether a send must be intercepted or not. | 224 /// know whether a send must be intercepted or not. |
| 225 final Map<String, Set<Element>> _interceptedElements = | 225 final Map<String, Set<Element>> _interceptedElements = |
| 226 <String, Set<Element>>{}; | 226 <String, Set<Element>>{}; |
| 227 | 227 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 jsAst.Name name = namer.nameForGetInterceptor(classes); | 332 jsAst.Name name = namer.nameForGetInterceptor(classes); |
| 333 if (classes.contains(_helpers.jsInterceptorClass)) { | 333 if (classes.contains(_helpers.jsInterceptorClass)) { |
| 334 // We can't use a specialized [getInterceptorMethod], so we make | 334 // We can't use a specialized [getInterceptorMethod], so we make |
| 335 // sure we emit the one with all checks. | 335 // sure we emit the one with all checks. |
| 336 _specializedGetInterceptors[name] = _interceptorData.interceptedClasses; | 336 _specializedGetInterceptors[name] = _interceptorData.interceptedClasses; |
| 337 } else { | 337 } else { |
| 338 _specializedGetInterceptors[name] = classes; | 338 _specializedGetInterceptors[name] = classes; |
| 339 } | 339 } |
| 340 } | 340 } |
| 341 } | 341 } |
| OLD | NEW |