| 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 import '../common.dart'; | 5 import '../common.dart'; |
| 6 import '../common_elements.dart'; | 6 import '../common_elements.dart'; |
| 7 import '../elements/elements.dart' show Element; | 7 import '../elements/elements.dart' show Element; |
| 8 import '../elements/entities.dart'; | 8 import '../elements/entities.dart'; |
| 9 import '../elements/types.dart'; | 9 import '../elements/types.dart'; |
| 10 import '../util/util.dart' show Setlet; | 10 import '../util/util.dart' show Setlet; |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 /// `true` if `Function.apply` is used. | 115 /// `true` if `Function.apply` is used. |
| 116 bool isFunctionApplyUsed = false; | 116 bool isFunctionApplyUsed = false; |
| 117 | 117 |
| 118 /// `true` if `noSuchMethod` is used. | 118 /// `true` if `noSuchMethod` is used. |
| 119 bool isNoSuchMethodUsed = false; | 119 bool isNoSuchMethodUsed = false; |
| 120 | 120 |
| 121 BackendUsageBuilderImpl(this._commonElements); | 121 BackendUsageBuilderImpl(this._commonElements); |
| 122 | 122 |
| 123 @override | 123 @override |
| 124 void registerBackendFunctionUse(FunctionEntity element) { | 124 void registerBackendFunctionUse(FunctionEntity element) { |
| 125 assert(invariant(element, _isValidBackendUse(element), | 125 assert(_isValidBackendUse(element), |
| 126 message: "Backend use of $element is not allowed.")); | 126 failedAt(element, "Backend use of $element is not allowed.")); |
| 127 _helperFunctionsUsed.add(element); | 127 _helperFunctionsUsed.add(element); |
| 128 } | 128 } |
| 129 | 129 |
| 130 @override | 130 @override |
| 131 void registerBackendClassUse(ClassEntity element) { | 131 void registerBackendClassUse(ClassEntity element) { |
| 132 assert(invariant(element, _isValidBackendUse(element), | 132 assert(_isValidBackendUse(element), |
| 133 message: "Backend use of $element is not allowed.")); | 133 failedAt(element, "Backend use of $element is not allowed.")); |
| 134 _helperClassesUsed.add(element); | 134 _helperClassesUsed.add(element); |
| 135 } | 135 } |
| 136 | 136 |
| 137 bool _isValidBackendUse(Entity element) { | 137 bool _isValidBackendUse(Entity element) { |
| 138 if (_isValidEntity(element)) return true; | 138 if (_isValidEntity(element)) return true; |
| 139 if (element is Element) { | 139 if (element is Element) { |
| 140 assert(invariant(element, element.isDeclaration, | 140 assert(element.isDeclaration, |
| 141 message: "Backend use $element must be the declaration.")); | 141 failedAt(element, "Backend use $element must be the declaration.")); |
| 142 if (element.implementationLibrary.isPatch || | 142 if (element.implementationLibrary.isPatch || |
| 143 // Needed to detect deserialized injected elements, that is | 143 // Needed to detect deserialized injected elements, that is |
| 144 // element declared in patch files. | 144 // element declared in patch files. |
| 145 (element.library.isPlatformLibrary && | 145 (element.library.isPlatformLibrary && |
| 146 element.sourcePosition.uri.path | 146 element.sourcePosition.uri.path |
| 147 .contains('_internal/js_runtime/lib/')) || | 147 .contains('_internal/js_runtime/lib/')) || |
| 148 element.library == _commonElements.jsHelperLibrary || | 148 element.library == _commonElements.jsHelperLibrary || |
| 149 element.library == _commonElements.interceptorsLibrary || | 149 element.library == _commonElements.interceptorsLibrary || |
| 150 element.library == _commonElements.isolateHelperLibrary) { | 150 element.library == _commonElements.isolateHelperLibrary) { |
| 151 // TODO(johnniwinther): We should be more precise about these. | 151 // TODO(johnniwinther): We should be more precise about these. |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 _globalFunctionDependencies ?? const <FunctionEntity>[]; | 342 _globalFunctionDependencies ?? const <FunctionEntity>[]; |
| 343 | 343 |
| 344 @override | 344 @override |
| 345 Iterable<ClassEntity> get globalClassDependencies => | 345 Iterable<ClassEntity> get globalClassDependencies => |
| 346 _globalClassDependencies ?? const <ClassEntity>[]; | 346 _globalClassDependencies ?? const <ClassEntity>[]; |
| 347 | 347 |
| 348 Iterable<FunctionEntity> get helperFunctionsUsed => _helperFunctionsUsed; | 348 Iterable<FunctionEntity> get helperFunctionsUsed => _helperFunctionsUsed; |
| 349 | 349 |
| 350 Iterable<ClassEntity> get helperClassesUsed => _helperClassesUsed; | 350 Iterable<ClassEntity> get helperClassesUsed => _helperClassesUsed; |
| 351 } | 351 } |
| OLD | NEW |