| 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_elements.dart' show CommonElements, ElementEnvironment; | 8 import '../common_elements.dart' show CommonElements, ElementEnvironment; |
| 9 import '../elements/elements.dart' show MemberElement; | 9 import '../elements/elements.dart' show MemberElement; |
| 10 import '../elements/entities.dart'; | 10 import '../elements/entities.dart'; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 /// Whether the compiler can use the native `instanceof` check to test for | 39 /// Whether the compiler can use the native `instanceof` check to test for |
| 40 /// instances of [type]. This is true for types that are not used as mixins or | 40 /// instances of [type]. This is true for types that are not used as mixins or |
| 41 /// interfaces. | 41 /// interfaces. |
| 42 bool mayGenerateInstanceofCheck(DartType type, ClosedWorld closedWorld); | 42 bool mayGenerateInstanceofCheck(DartType type, ClosedWorld closedWorld); |
| 43 } | 43 } |
| 44 | 44 |
| 45 abstract class InterceptorDataBuilder { | 45 abstract class InterceptorDataBuilder { |
| 46 void addInterceptors(ClassEntity cls); | 46 void addInterceptors(ClassEntity cls); |
| 47 void addInterceptorsForNativeClassMembers(ClassEntity cls); | 47 void addInterceptorsForNativeClassMembers(ClassEntity cls); |
| 48 InterceptorData onResolutionComplete(); | 48 InterceptorData close(); |
| 49 } | 49 } |
| 50 | 50 |
| 51 class InterceptorDataImpl implements InterceptorData { | 51 class InterceptorDataImpl implements InterceptorData { |
| 52 final NativeBasicData _nativeData; | 52 final NativeBasicData _nativeData; |
| 53 final CommonElements _commonElements; | 53 final CommonElements _commonElements; |
| 54 | 54 |
| 55 /// The members of instantiated interceptor classes: maps a member name to the | 55 /// The members of instantiated interceptor classes: maps a member name to the |
| 56 /// list of members that have that name. This map is used by the codegen to | 56 /// list of members that have that name. This map is used by the codegen to |
| 57 /// know whether a send must be intercepted or not. | 57 /// know whether a send must be intercepted or not. |
| 58 final Map<String, Set<MemberEntity>> _interceptedElements; | 58 final Map<String, Set<MemberEntity>> _interceptedElements; |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 | 232 |
| 233 /// Set of classes used as mixins on intercepted (native and primitive) | 233 /// Set of classes used as mixins on intercepted (native and primitive) |
| 234 /// classes. Methods on these classes might also be mixed in to regular Dart | 234 /// classes. Methods on these classes might also be mixed in to regular Dart |
| 235 /// (unintercepted) classes. | 235 /// (unintercepted) classes. |
| 236 final Set<ClassEntity> _classesMixedIntoInterceptedClasses = | 236 final Set<ClassEntity> _classesMixedIntoInterceptedClasses = |
| 237 new Set<ClassEntity>(); | 237 new Set<ClassEntity>(); |
| 238 | 238 |
| 239 InterceptorDataBuilderImpl( | 239 InterceptorDataBuilderImpl( |
| 240 this._nativeData, this._elementEnvironment, this._commonElements); | 240 this._nativeData, this._elementEnvironment, this._commonElements); |
| 241 | 241 |
| 242 InterceptorData onResolutionComplete() { | 242 InterceptorData close() { |
| 243 return new InterceptorDataImpl( | 243 return new InterceptorDataImpl( |
| 244 _nativeData, | 244 _nativeData, |
| 245 _commonElements, | 245 _commonElements, |
| 246 _interceptedElements, | 246 _interceptedElements, |
| 247 _interceptedClasses, | 247 _interceptedClasses, |
| 248 _classesMixedIntoInterceptedClasses); | 248 _classesMixedIntoInterceptedClasses); |
| 249 } | 249 } |
| 250 | 250 |
| 251 void addInterceptorsForNativeClassMembers(ClassEntity cls) { | 251 void addInterceptorsForNativeClassMembers(ClassEntity cls) { |
| 252 _elementEnvironment.forEachClassMember(cls, | 252 _elementEnvironment.forEachClassMember(cls, |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 jsAst.Name name = namer.nameForGetInterceptor(classes); | 328 jsAst.Name name = namer.nameForGetInterceptor(classes); |
| 329 if (classes.contains(_commonElements.jsInterceptorClass)) { | 329 if (classes.contains(_commonElements.jsInterceptorClass)) { |
| 330 // We can't use a specialized [getInterceptorMethod], so we make | 330 // We can't use a specialized [getInterceptorMethod], so we make |
| 331 // sure we emit the one with all checks. | 331 // sure we emit the one with all checks. |
| 332 _specializedGetInterceptors[name] = _interceptorData.interceptedClasses; | 332 _specializedGetInterceptors[name] = _interceptorData.interceptedClasses; |
| 333 } else { | 333 } else { |
| 334 _specializedGetInterceptors[name] = classes; | 334 _specializedGetInterceptors[name] = classes; |
| 335 } | 335 } |
| 336 } | 336 } |
| 337 } | 337 } |
| OLD | NEW |